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

keypairs-cli

v1.2.5

Published

CLI for Keypairs.js

Downloads

5

Readme

Keypairs CLI

The most useful and easy-to-use crypto cli on the planet (because openssl is confusing).

  • [x] Universal Standards-based Crypto Support:
    • [x] RSA (2048, 3072, 4096, 8192)
    • [x] EC (NIST ECDSA) P-256 (prime256v1, secp256r1), P-384 (secp384r1)
  • [x] Supported Encodings: PEM, JSON
  • [x] Private Key Formats: PKCS1, SEC1, PKCS8, JWK, OpenSSH
  • [x] Public Key Formats: PKCS1, PKIX (SPKI), SSH
  • [x] Create JWT tokens
  • [x] Sign JWT/JWS claims/tokens/payloads
  • [x] Decode JWTs (without verifying)
  • [x] Verify JWT/JWS tokens/json (by fetching public key)

Install

You must have node.js installed.

npm install --global keypairs-cli

Usage

Guess and check.

The keypairs CLI is pretty fuzzy. If you just type at it, it'll probably work.

That said, the fuzzy behavior is not API-stable and is subject to change, so you should only script to the documented syntax. ;)

Overview

  • Generate: keypairs gen
  • Convert: keypairs ./priv.pem
  • Sign: keypairs sign ./priv.pem https://example.com/ '{"sub":"[email protected]"}'
  • Verify: keypairs verify 'xxxxx.yyyyy.zzzzz'
  • Decode: keypairs decode 'xxxxx.yyyyy.zzzzz'
  • Debug: prefix any option with debug such as keypairs debug gen pem key.pem jwk pub.json

Generate a New Key

No arguments - generates a universally compatible key of more-than-sufficient entropy.

keypairs gen

Generate an ecdsa key:

keypairs gen ec P-256

Generate an RSA key:

keypairs gen rsa 2048

Parse/Convert an existing key

keypairs ./priv.pem
keypairs '{"kty":"EC",...}'
keypairs ./priv.jwk.json

Syntax: keypairs <in> [priv-out opts...] [pub-out opts...]

keypairs <inkey> [[encoding|scheme] [priv-out]] [[encoding|scheme] [pub-out]] [public|private]

Note: If you specify a private and a public key, and you want to specify the schema/encoding of the public key, you must also specify the scheme and encoding of the public key. Order matters. Private keys come first.

JWK Keypair to PEM-encoded Private and Public keys:

keypairs ./priv.json pem pkcs1 ./priv.pem pem spki ./pub.pem
keypairs ./priv.json pem ./priv.pem ssh ./pub.json
keypairs ./priv.json pkcs8 ./priv.pem spki ./pub.json

PEM Keypair to JSON-encoded JWK (Public Key Only):

keypairs ./priv.pem jwk ./priv.pem public
keypairs ./priv.pem json ./priv.pem public

Generic PEM to JWK:

keypairs priv.pem priv.jwk.json
keypairs priv.pem priv.jwk.json pub.jwk.json
keypairs priv.pem pub.jwk.json public
# fails if the input is public
keypairs priv.pem priv.jwk.json private

Generic JWK to PEM:

keypairs '{"kty":"EC",...}' priv.pem
keypairs priv.json priv.pem

Sign a Token (JWT)

Syntax:

keypairs [key] sign [issuer url] <claims> [exp] [nbf]

Note: The issuer url can be omitted if it's already included among the claims.

Example:

keypairs ./priv.pem sign https://example.com/ '{"sub":"[email protected]"}' 1h -5m
keypairs '{"kty":"EC",...}' sign https://example.com/ '{"sub":"[email protected]"}' 1h -5m

Verify a JWT (Token)

Verify a JWT based on its issuer

keypairs verify 'xxx.yyy.zzz'