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

nermal

v1.1.3

Published

The cutest secure JavaScript authenticated encryption container.

Downloads

8

Readme

Nermal!

Nermal secures your JavaScript application's data easily.

Nermal does private-key authenticated encryption with a trusted algorithm (AES-256/GCM) implemented by a trusted library (SJCL) with a pretty good key-derivation system (scrypt). It keeps track of salts for its keys, and automatically generates random nonces. It also pads the data with a random number of random bytes, which makes it harder to determine what sort of operations are being performed on the data: inserts and deletions become harder to detect as the file length is known to randomly fluctuate.

Authenticated encryption basically means that when you decrypt the data, you can be confident that it's something which you encrypted, in the format that you encrypted it in. Nermal also authenticates and stores a namespace string, so that there is a nice place for you to store version numbers so that you can reorganize your data format later.

Nermal boxes are newline-separated ASCII strings[note 1], so you can save them to disk or transmit them as JSON or whatever you want, interoperably.

License

Nermal is licensed under the Mozilla Public License v2.0. This is a by-file copyleft license: so if you do not modify the source files of Nermal you may release your code under any license you like; but any modified source files continue to be free software under the MPL. I find it to be much more readable and easier to reason about than the LGPL.

Installation

Nermal was written to be interoperable with Node.js, but also to work client-side in the browser. To use with node:

npm install nermal

To use with the browser, you will need to load the files for SJCL and scrypt in your HTML file first, then include nermal.js or nermal-1.1.2_browser.min.js with a script tag -- it will initialize scrypt for you. I may eventually release a packed version which contains all of the source for the browser.

Usage

Nermal has a minimalist API. A nermal box is ultimately just a JavaScript string and can be transmitted or stored easily as as such. Nermal only encrypts JavaScript strings and Uint8Arrays, leaving questions of how your data is serialized to you. Other than putting data into/out of the box with encrypt and decrypt, nermal provides newKey and getKey for applications which want to manage keys (so that you don't have to wait for scrypt twice), and some developer functions are exposed with leading underscores.

Full docs are available in nermal/API.md. The types and argument orders of the most common functions are:

encrypt: (ns: string, data: $bin, key: string | $key, nonce: $bin?) -> $nermal_box!
decrypt: (box: $nermal_box, key: string | $key, raw: boolean?) -> $bin
newKey:  (pass: string) -> $key!
getKey:  (box: $nermal_box, pass: string) -> $key
version: string

Notes

  1. This is not quite true: nermal never adds non-ASCII characters but the namespace of a nermal box may contain non-ASCII characters. Nermal only forbids namespaces containing leading spaces, for embeddability reasons. However, nermal serializes namespaces with JSON.stringify(ns).slice(1, -1) so that you don't have to worry about, say, control characters in the resulting string.