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

libgenaro

v4.0.3

Published

Node.js library for encrypted file transfer on the Genaro network.

Downloads

19

Readme

node-libgenaro

Node.js library for encrypted file transfer on the GenaroNetwork network via bindings to libgenaro.

Example Usage

Install via npm:

npm install libgenaro

First setup the storj environment with authentication and encryption options:

const { Environment } = require('libgenaro');

const libgenaro = new Environment({
    bridgeUrl: 'http://111.111.111.111:8080',
    keyFile: `{
        "address": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
        "crypto":{"ciphertext":"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
        "cipherparams":{"iv":"cccccccccccccccccccccccccccccccc"},"cipher":"aes-128-ctr",
        "kdf":"scrypt","kdfparams":{"dklen":32,"salt":"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd","n":262144,"r":8,
        "p":1},"mac":"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"},
        "id": "ffffffff-1111-2222-3333-444444444444",
        "version": 3
    }
    `,
    passphrase: '123456',
});

Upload a file to a bucket:

const bucketId = '368be0816766b28fd5f43af5';
const filePath = './test-upload.data';

const keyCtr = env.generateEncryptionInfo(bucketId);
const index = keyCtr.index;
const key = keyCtr.key;
const ctr = keyCtr.ctr;

const rsaKey = xxxxxx; // encrypted key with rsa
const rsaCtr = xxxxxx; // encrypted ctr with rsa

const state = libgenaro.storeFile(bucketId, fileOrData, isFilePath, {
  filename: 'test-upload.data',
  progressCallback: function(progress, fileBytes) {
    console.log('Progress:', progress);
  },
  finishedCallback: function(err, fileId, fileBytes, sha256_of_encrypted) {
    if (err) {
      return console.error(err);
    }
    console.log('File complete:', fileId);
  },
  index: index,
  key: key,
  ctr: ctr,
  rsaKey: rsaKey,
  rsaCtr: rsaCtr,
});

Download a file from a bucket:

const bucketId = '368be0816766b28fd5f43af5';
const fileId = '998960317b6725a3f8080c2b';
const downloadFilePath = './test-download.data';

const key = xxxxxx; // the file encryption key
const ctr = xxxxxx; // the file encryption ctr

const state = libgenaro.resolveFile(bucketId, fileId, filePath, {
  key: key,
  ctr: ctr,
  overwrite: overwrite,
  decrypt: decrypt,
  progressCallback: function(progress, fileBytes) {
    console.log('progress:', progress);
  },
  finishedCallback: function(err, fileBytes, sha256) {
    if (err) {
      return console.error(err);
    }
    console.log('File download complete');
  }
});

Once finished, you should call to zero and free memory holding encryption keys:

libgenaro.destroy();

API

  • Environment(options) - A constructor for keeping encryption options and other environment settings, see available methods below

Methods available on an instance of Environment:

  • getInfo(function(err, result) {}) - Get general API info`
  • getBuckets(function(err, result) {}) - Get list of available buckets
  • deleteBucket(bucketId, function(err, result) {}) - Delete a bucket
  • renameBucket(bucketId, function(err) {}) - Rename a bucket
  • listFiles(bucketId, function(err, result) {}) - List files in a bucket
  • storeFile(bucketId, fileOrData, isFilePath, options) - Upload a file, return state object
  • storeFileCancel(state) - Cancel an upload
  • resolveFile(bucketId, fileId, filePath, options) - Download a file, return state object
  • resolveFileCancel(state) - Cancel a download
  • deleteFile(bucketId, fileId, function(err, result) {}) - Delete a file from a bucket
  • generateEncryptionInfo(bucketId) - Generate the key and ctr of AES-256-CTR for file encryption, and also the index related to the key and ctr, return undefined if fail
  • decryptFile(filePath, key, ctr) - Decrypt the undecrypted file use the key and ctr of AES-256-CTR, return the decrypted data if success, undefined if fail
  • encryptMeta(meta) - Encrypt the meta use AES-256-GCM combined with HMAC-SHA512, return the encrypted meta if success, undefined if fail
  • encryptMetaToFile(meta, filePath) - Encrypt the meta use AES-256-GCM combined with HMAC-SHA512 to filePath
  • decryptMeta(encryptedMeta) - Decrypt the encryptedMeta, return the decrypted meta if success, undefined if fail
  • decryptMetaFromFile(filePath) - Decrypt the data in filePath, return the decrypted data if success, undefined if fail
  • destroy() - Zero and free memory of encryption keys and the environment