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 🙏

© 2026 – Pkg Stats / Ryan Hefner

micro-encrypt

v1.6.1

Published

Small library to create micro-services with AES-256-CTR encryption

Readme

A small library to create micro-services with AES-256-CTR encryption on top of micro.

Install

npm i micro-encrypt

Usage

auths

To use this library the first thing you have to do is create a json file where you define all of your authentications/users. The format is key/value.

Every key of the json is an user. We will call it API_KEY, and the value of that API_KEY is the API_SECRET. You can add as much as you want. Use just one API_KEY for each client you connect with.

Example:

{
    "04f8996da763b7a969b211da63548b10": "my_password",
    "[email protected]": "password2",
    ...
}

/micro

This module is a wrapper of micro with the difference that you have to pass an object with two mandatory parameters:

  • auths: Object

  • endpoints: Array

const micro = require('micro-encrypt/micro')
const { create } = require('micro-encrypt/endpoints')
const auths = {
    user1213151: 'the_password'
}
const endpoints = []
endpoints.push(create('/hello', () => 'world'))

const server = micro({ auths, endpoints })
server.listen(3000)

/endpoints

to do

/request

This module is just a function that creates a wrapper of request-promise which is also a promise wrapper of request.

const request = require('micro-encrypt/request')
const encryption = { API_KEY, API_SECRET } // Any of those you have defined previously in auths.json
const body = { symbol: 'BTC' }
const address = await request(`${url}/getAddressForDeposit`, { body, encryption })

If you want to use request as standalone you can do it this way:

const request = require('request')
const { encrypt, decrypt } = require('micro-encrypt/encryption')
const body = encrypt({ symbol: 'BTC' }, API_SECRET)
const headers = { authorization: API_KEY }
request(
    `${url}/getAddressForDeposit`,
    { body, headers },
    (error, response, body) => {
        const address = decrypt(body, API_SECRET)
    }
)

Error handling

A successful request always gets 2XX as statusCode. Any other statusCode will be an error. And you must handle it with try-catch.

const request = require('micro-encrypt/request')
try {
    const address = await request(`${url}/helloWorld`)
} catch(e) {
    console.log(e.statusCode) // 404
    console.log(e.error) // { "message": "Not Found" }
}

If you want to use request

const request = require('request')
request(`${url}/helloWorld`, (error, response, body) => {
    console.log(response.statusCode) // 404
    console.log(body) // '{ "message": "Not Found" }'
})

/encryption

to do