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

@apeleghq/rfc8188

v1.0.7

Published

An implementation of RFC 8188 (encrypted content-encoding for HTTP)

Downloads

5

Readme

🔒 RFC 8188 Encrypted Content-Encoding for HTTP in TypeScript

Reliability Rating Vulnerabilities Bugs Security Rating Maintainability Rating NPM Downloads


🚀 Features

  • Implements RFC 8188 for encrypted content-encoding in HTTP.
  • Supports AES-128-GCM encryption algorithm.
  • Additionally, supports AES-256-GCM encryption algorithm (non-standard).
  • Provides functions for both encryption and decryption of data.
  • Flexible configuration options for encoding parameters.

💻 Installation

To install the package, you can use npm or yarn:

npm install @apeleghq/rfc8188

or

yarn add @apeleghq/rfc8188

📚 Usage

Decrypting Data

import { encodings, decrypt } from '@apeleghq/rfc8188';

// Maximum permissible record size when decrypting. Because the decrypted data
// are buffered until a record is full, not limiting it can result in a very
// large memory allocation (4 GiB) depending on the incoming data.
// If this parameter is not provided, no limit is used. Otherwise, incoming data
// claiming to have records larger than this value will be rejected with.
const maxRecordSize = Infinity;

// Provide a function to lookup Initial Keying Material (IKM)
const lookupIKM = async (keyId) => {
  // Your logic to lookup IKM
  return new ArrayBuffer(16);
};

// Your readable stream with ciphertext
const dataStreamToDecrypt = new ReadableStream();

// Decrypt data
const decryptedDataSteam = decrypt(
    encodings.aes128gcm,
    dataStreamToDecrypt,
    lookupIKM,
    maxRecordSize, // optional
);

// Handle decrypted data stream
// ...

Encrypting Data

import { encodings, encrypt } from '@apeleghq/rfc8188';

// Your readable stream with plaintext
const dataStreamToEncrypt = new ReadableStream();
// Some record size. It must be a value between 18 and 2**32 - 1 and is used
// for chunking.
const recordSize = 512;
// A key ID to be included in the payload header.
// It must be between 0 and 255 bytes long and is used to identify the IKM used.
const keyId = new ArrayBuffer(0);
// Initial Keying Material (IKM). Used to derive an encryption key. Note: this
// value is **not** output and it must be treated as a secret.
const IKM = new ArrayBuffer(0);
// Optional. A salt value, which will be combined with the IKM to derive an
// encyption key. If none is provided, a randomly-generated salt value will be
// used. Note that the salt must be exactly 16 bytes long.
const salt = new ArrayBuffer(16);

// Provide plaintext data and encryption parameters
const encryptedDataStream = await encrypt(
    encodings.aes128gcm,
    dataStreamToEncrypt,
    recordSize,
    keyId,
    IKM,
    salt, // optional
);

// Handle encrypted data stream
// ...

🤝 Contributing

We welcome any contributions and feedback! Please feel free to submit pull requests, bug reports or feature requests to our GitHub repository.

📜 License

This project is released under the ISC license. Check out the LICENSE file for more information.