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

ts-nkeys

v1.0.16

Published

A public-key signature system based on Ed25519 for the NATS ecosystem in typescript for ts-nats and node-nats

Downloads

125,783

Readme

ts-nkeys

A public-key signature system based on Ed25519 for the NATS ecosystem system in JavaScript and Typescript.

license Build Status Coveralls github branch npm npm

ts-nkeys is a typescript nats library for node that for generating nkeys.

Installation

npm install ts-nkeys

Basic Usage

    // create an user nkey - also possible to create accounts, clusters, servers.
    let user = createUser();

    // once you have an nkey you can generate various keys.
    // A seed is the public and private keys together.
    // Seeds are strings, and start with the letter 'S'. 
    // Seeds need to be kept safe and never shared.
    let seed = user.getSeed();
    t.true(Buffer.isBuffer(seed));
    t.is(seed[0], 'S'.charCodeAt(0));
    
    // the second letter in the seed represents its type:
    // `U` for user, 
    // `A` for account, 
    // `C` for cluster
    // `N` for severs
    t.is(seed[1], 'U'.charCodeAt(0));

    // public keys can be shared and can be used to verify signed content
    let publicKey = user.getPublicKey();
    t.true(Buffer.isBuffer(publicKey));
    // first letter represents the type of public key
    // `U` for user, 
    // `A` for account, 
    // `C` for cluster
    // `N` for severs
    t.is(publicKey[0], 'U'.charCodeAt(0));


    // To sign data
    let data = Buffer.from("HelloWorld");
    let sig = user.sign(data);
    
    // to verify use the user, public or seed:
    t.true(user.verify(data, sig));

    // public keys can be used to verify signatures you cannot sign with them though.
    let pk = fromPublic(publicKey);
    t.true(pk.verify(data, sig));

    // seeds can be used to reconstitute the keypair from a string
    let sk = fromSeed(seed);
    t.true(sk.verify(data, sig));
    // and can be used to sign
    let sig2 = sk.sign(data);
    t.true(sk.verify(data, sig));

Supported Node Versions

Our support policy for Nodejs versions follows Nodejs release support. We will support and build node-nats on even-numbered Nodejs versions that are current or in LTS.

License

Unless otherwise noted, the NATS source files are distributed under the Apache Version 2.0 license found in the LICENSE file.