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

terces

v1.0.2

Published

A library and command-line tool to encode and decode JWT tokens using a key in the local filesystem

Downloads

8

Readme

terces

A library and CLI tool to encrypt and decrypt sensitive application secrets, and manage encryption keys.

Install

To use programatically in your project

$ npm install --save terces

To use as a CLI tool to manage secret keys an create secret tokens:

$ npm install -g terces

How to Use

terces CLI

$ terces

  Usage: terces [options] [command]


  Commands:

    decode|token <token>       decode the given JWT token
    encode|payload <JSONData>  encode the given JSON payload string
    set-key|key <key>          Set the key value at key-path (~/.terces, by default)

  Options:

    -h, --help             output usage information
    -V, --version          output the version number
    -k, --key <key>        use key string
    -S, --key-path <path>  path to key file, (~/.terces, by default)
    -D, --dryrun           no writes to the filesystem
    -v, --verbose          log extra info to console

First, set a key for your host with

$ terces set-key <your key>

or copy a key from another host. Default path for the key file is ~/.terces and the default permissions set is 640.

Then you'll need to encode your application secrets that you want to consume in your node project:

$ terces encode '{"applicationSecret":"secret12345"}'

this command will output a JWT token encoded with your terces key. This token can be packaged with your application build or set on an ENV variable and then decoded during run time, where the sensitive, decoded JSON data can be stored in memory.

terces Library

In you application code import the terces module to decode the token.

var terces = require('terces');
var secretData = terces.decode(jwtToken);
secretData.applicationSecret; // 'secret12345';

terces.decode will use the key located at ~/.terces by default, but you target a different path using

terces.decode(jwtToken, { path: '/etc/terces/mykeyfile' });

or if you want to use your own in-memory keyValue, without terces caching it, use

terces.decode(jwtToken, { noCache: true }, myKeyValue);

...or you can use any JWT library since it's just a valid JWT token. :)_