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

@whiteflagprotocol/crypto

v1.0.0

Published

Whiteflag JS cryptographic classes and functions

Readme

WFJSL Cryptographic Functions

Overview

The Whiteflag JavaScript Library (WFJSL) is an implementation of the Whiteflag Protocol written in TypeScript, and compiled to JavaScript, to support the development of Whiteflag-enabled applications in JavaScript.

The @whiteflagprotocol/crypto package provides cryptographic functions for other Whiteflag packages. Therefore, it should normally not be necessary to add this package as a dependency.

The WFJSL uses the Web Crypto API for the basic implementation of Whiteflag cryptographic functions, such as secret negotiation, encryption, and authentication. Putting these critical security functions in a separate package makes them better inspectable, testable and maintainable.

Most cryptography functions are asynchronous and return a Promise.

This description provides a generic overview of the WFJSL cryptography package. Please see the WFJSL TypeDoc documentation for a detailed description of all classes and functions.

Hashing

The Whiteflag cryptography package provides three hashing functions with the hash module:

| Function | Purpose | |----------|---------------------------------------------------------------------------| | hkdf | Hash-based Key Derivation Function using SHA-256 i.a.w. RFC 5869 | | hash | Basic hashing function, using SHA-256 as default | | hmac | Hash-Based Message Authentication Code function, using SHA-256 as default |

The hkdf function is used by Whiteflag to derive encryption keys and authentication tokens and bind them to the blockchain address of a specific originator. The hash and hmac functions are wrappers easy common access to the underlying algorithms through the Web Crypto API; they are used by the hkdf function, but may also be used for other functionality as required.

Encryption

The Whiteflag cryptography package provides the following functions for message encryption with the cipher module:

| Function | Purpose | |-------------|---------------------------------------------------------------------------------------| | encrypt | Encrypts a binary encoded Whiteflag message, based on the Whiteflag encryption method | | decrypt | Decrypts a binary encoded Whiteflag message, based on the Whiteflag encryption method | | deriveKey | Derives the encryption key based on the Whiteflag encryption method |

The encrypt and decrypt functions take a binary encoded Whiteflag message, along with a number of encryption parameters such as the encryption key, to perform the encryption and decryption of messages.

The deriveKey function uses the hkdf function with the input key material, information parameter, salt, and key length for the encryption method, to generate the Web Crypto API encryption key to be used with the encrypt and decrypt functions i.a.w. the Whiteflag standard.

The Whiteflag encryption methods are defined by the WfCryptoMethod enum.

Cryptographic Keys

The Whiteflag cryptography package provides the following functions for key generation with the keys module:

| Function | Purpose | |-----------------|----------------------------------------------| | createAesKey | Creates an AES encryption and decryption key | | createHmacKey | Creates an HMAC signing key |

All key generation functions create a Web Crypto API CryptoKey object, typically from a raw key generated or provided elsewhere. These keys are primarily intended to provide the correct Web Crypto API keys to other functions of the cryptography package.