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

@skvostik/skva

v1.0.0

Published

TypeScript library for the SKVA encrypted backup archive format

Downloads

15

Readme

@skvostik/skva

TypeScript library for the .skva format: a stream-based encrypted backup archive.

Features

  • Strict SKVA v1 header parsing and validation.
  • Stream-based encryption and decryption with chunked payload processing.
  • Multi-recipient support with password-based recipient selection.
  • Password-based recipient recovery is deterministic from the stored KDF parameters and password, while recipient generation uses a fresh random salt per call.
  • Typed errors for parsing, validation, and cryptographic failures.

Public API

The supported public contract is exposed from the package entrypoint. Each function below is meant for a specific integration path, and the brief descriptions should make it easier to choose the right one.

skvaEncryptStream

Encrypts a plaintext stream and writes the SKVA payload to an output stream. Use this when you want to process large inputs without buffering them in memory.

skvaEncryptStream(
  input: ReadableStream<Uint8Array>,
  output: WritableStream<Uint8Array>,
  options: SkvaEncryptOptions,
): Promise<{ json_header: SkvaJsonHeader; binary_header: SkvaBinaryHeader }>

skvaDecryptStream

Decrypts a SKVA stream and writes the recovered plaintext to an output stream. This is the stream-based counterpart to byte decryption.

skvaDecryptStream(
  input: ReadableStream<Uint8Array>,
  output: WritableStream<Uint8Array>,
  options: SkvaDecryptOptions,
): Promise<{ json_header: SkvaJsonHeader; binary_header: SkvaBinaryHeader }>

skvaEncryptBytes

Encrypts an in-memory plaintext buffer and returns the encoded SKVA bytes plus the parsed headers. This is the simplest option for small to medium payloads.

skvaEncryptBytes(
  plaintext: Uint8Array,
  options: SkvaEncryptOptions,
): Promise<{ bytes: Uint8Array; json_header: SkvaJsonHeader; binary_header: SkvaBinaryHeader }>

skvaDecryptBytes

Decrypts an in-memory SKVA byte buffer and returns the recovered plaintext plus the parsed headers.

skvaDecryptBytes(
  skva_bytes: Uint8Array,
  options: SkvaDecryptOptions,
): Promise<{ bytes: Uint8Array; json_header: SkvaJsonHeader; binary_header: SkvaBinaryHeader }>

skvaReadHeaderStream

Parses the SKVA binary header and JSON metadata from a stream without decrypting the payload. Use this when you only need recipient or metadata information.

skvaReadHeaderStream(
  stream: ReadableStream<Uint8Array>,
): Promise<{ json_header: SkvaJsonHeader; binary_header: SkvaBinaryHeader }>

skvaReadHeaderBytes

Parses the SKVA header from in-memory bytes without decrypting the payload.

skvaReadHeaderBytes(
  skva_bytes: Uint8Array,
): Promise<{ json_header: SkvaJsonHeader; binary_header: SkvaBinaryHeader }>

skvaGenerateRecipient

Creates a recipient descriptor from a password and an optional recipient ID. The returned value can be passed directly into encryption options. Each call generates a fresh random KDF salt, so generated recipient material is intentionally different across calls.

skvaGenerateRecipient(
  password: string,
  recipient_id?: string,
  kdf_options?: Partial<Omit<SkvaKdfHeader, "algorithm" | "salt_b64">>,
): Promise<SkvaRecipient>

skvaFindRecipient

Tries to determine which recipient entry can be unlocked with the provided password and returns its recipient ID, or null if none match.

skvaFindRecipient(
  recipients: SkvaRecipientFekWrapper[],
  password: string,
): Promise<string | null>

The most commonly used exported types are SkvaKdfHeader, SkvaRecipient, SkvaJsonHeader, SkvaBinaryHeader, SkvaEncryptOptions, SkvaDecryptOptions, and SkvaError.

Core options

Encryption accepts one or more recipients and writes the wrapped FEK information into the header:

interface SkvaEncryptOptions {
  recipients: SkvaRecipient[];
  meta?: Record<string, unknown>;
  plaintext_chunk_bytes?: number;
  header_extension_bytes?: Uint8Array;
  on_progress?: (processedBytes: number) => void;
}

Decryption tries recipients in order until one password match succeeds, or only the selected recipient when recipient_id is provided:

interface SkvaDecryptOptions {
  password: string;
  recipient_id?: string;
  on_progress?: (processedBytes: number) => void;
}

Key types

SkvaKdfHeader

Argon2id parameters used to derive the KEM seed and recover the FEK for a recipient:

interface SkvaKdfHeader {
  algorithm: "argon2id";
  salt_b64: string;
  time_cost: number;
  memory_cost_kib: number;
  parallelism: number;
  derived_key_bytes: number;
}

SkvaRecipient

A recipient descriptor that can be used during encryption:

interface SkvaRecipient {
  recipient_id?: string;
  public_key: Uint8Array;
  kdf: SkvaKdfHeader;
}

SkvaJsonHeader

The decoded JSON header stored in the SKVA wire format:

interface SkvaJsonHeader {
  format: "skva";
  version: 1;
  recovery_note?: unknown;
  recipients: SkvaRecipientFekWrapper[];
  payload: SkvaPayloadHeader;
  meta?: Record<string, unknown>;
}

SkvaBinaryHeader

The binary prefix and length information parsed from the SKVA stream:

interface SkvaBinaryHeader {
  magic: "SKVA";
  version: number;
  header_length: number;
  header_bytes: Uint8Array;
  header_extension_length: number;
  header_extension_bytes: Uint8Array;
}

SkvaError

Typed errors are surfaced through SkvaError and the code field:

class SkvaError extends Error {
  readonly code: SkvaErrorCode;
}

Quick example

import {
  skvaGenerateRecipient,
  skvaEncryptBytes,
  skvaDecryptBytes,
} from "@skvostik/skva";

const password = "correct horse battery staple";
const recipient = await skvaGenerateRecipient(password, "primary");

const plaintext = new TextEncoder().encode("hello SKVA");
const encrypted = await skvaEncryptBytes(plaintext, {
  recipients: [recipient],
  plaintext_chunk_bytes: 64 * 1024,
});

const decrypted = await skvaDecryptBytes(encrypted.bytes, {
  password,
  recipient_id: "primary",
});

console.log(decrypted.bytes);

Stream example

import { createReadStream, createWriteStream } from "node:fs";
import { Readable, Writable } from "node:stream";
import {
  skvaGenerateRecipient,
  skvaEncryptStream,
  skvaDecryptStream,
} from "@skvostik/skva";

const password = "correct horse battery staple";
const recipient = await skvaGenerateRecipient(password, "primary");

const input = Readable.toWeb(createReadStream("./input.bin")) as ReadableStream<Uint8Array>;
const output = Writable.toWeb(createWriteStream("./output.skva")) as WritableStream<Uint8Array>;

await skvaEncryptStream(input, output, {
  recipients: [recipient],
  plaintext_chunk_bytes: 256 * 1024,
});

Header-only parse

Use this when you only need metadata or recipient information without decrypting the payload:

import { skvaReadHeaderBytes } from "@skvostik/skva";

const { json_header } = await skvaReadHeaderBytes(skva_bytes);
console.log(json_header.recipients.length);
console.log(json_header.payload.plaintext_chunk_bytes);