Unified Key Management Service interface for AWS KMS, GCP Cloud KMS, Azure Key Vault, and HashiCorp Vault.
Getting started
The Crypto Service ecosystem
Package reference
Operational
pnpm add @sebastienrousseau/crypto-kms
# or
npm install @sebastienrousseau/crypto-kms
# or
yarn add @sebastienrousseau/crypto-kms
^22.0.0 or >=24.0.0 (active and maintenance LTS releases)pnpm >=9 (recommended) or npm >=10>=5.0 (when compiling with TypeScript)import { LocalKmsProvider } from "@sebastienrousseau/crypto-kms";
const kms = new LocalKmsProvider();
const key = await kms.createKey("aes-256-gcm", "encrypt");
const encrypted = await kms.encrypt(
key.keyId,
new TextEncoder().encode("secret"),
);
const decrypted = await kms.decrypt(key.keyId, encrypted.ciphertext);
console.log(new TextDecoder().decode(decrypted.plaintext)); // "secret"
Crypto Service provides a complete cryptography stack across 14 specialized packages:
| Package | Role | Description |
|---|---|---|
@sebastienrousseau/crypto-api |
API Schemas | Shared TypeScript types and utilities for the Crypto Service Suite, defining the canonical API surface. |
@sebastienrousseau/crypto-cli |
Terminal CLI | An interactive command-line interface for cryptographic operations, supporting both legacy OpenPGP and modern post-quantum algorithms. |
@sebastienrousseau/crypto-edge |
Edge Runtime | Edge-runtime cryptographic operations using the Web Crypto API, optimized for Cloudflare Workers, Vercel Edge, and Deno. |
@sebastienrousseau/crypto-kms (this package) |
Cloud KMS | Unified Key Management Service interface for AWS KMS, GCP Cloud KMS, Azure Key Vault, and HashiCorp Vault. |
@sebastienrousseau/crypto-lib |
Core Library | A modern cryptographic library for TypeScript, with post-quantum support, zero unsafe dependencies, and 100% test coverage. |
@sebastienrousseau/crypto-middleware |
Middleware | Framework-agnostic cryptographic middleware for Express, Fastify, and Koa applications. |
@sebastienrousseau/crypto-prisma |
ORM Adapter | Transparent field-level encryption extension for Prisma Client, powered by AES-256-GCM. |
@sebastienrousseau/crypto-react |
React Hooks | React hooks and context provider for client-side cryptographic operations with zero boilerplate. |
@sebastienrousseau/crypto-sdk |
Client SDK | A zero-dependency, typed HTTP client for the Crypto Service REST API, with full post-quantum support. |
@sebastienrousseau/crypto-server |
HTTP API | A hardened Fastify REST API for cryptographic operations, with rate limiting, OpenAPI schemas, and post-quantum endpoints. |
@sebastienrousseau/crypto-testing |
Test Support | Deterministic keys, fast mocks, and test fixtures for crypto-lib |
@sebastienrousseau/crypto-typeorm |
ORM Adapter | TypeORM column-level encryption with a single decorator, powered by crypto-lib. |
@sebastienrousseau/crypto-vue |
Vue Composables | Vue 3 composables for client-side cryptography |
@sebastienrousseau/crypto-wasm |
Acceleration | WebAssembly performance accelerator for crypto-lib |
crypto-kms provides a unified KmsProvider interface over multiple
key management backends -- AWS KMS, Google Cloud KMS, Azure Key
Vault, HashiCorp Vault, and an in-memory local provider. All
providers expose the same methods for key creation, encryption,
decryption, signing, verification, rotation, and data-key
generation, making it trivial to swap backends without changing
application code.
| Provider | Class | Backend | Peer Dependency |
|---|---|---|---|
| AWS | AwsKmsProvider |
AWS Key Management Service | @aws-sdk/client-kms |
| GCP | GcpKmsProvider |
Google Cloud KMS | @google-cloud/kms |
| Azure | AzureKmsProvider |
Azure Key Vault | @azure/keyvault-keys |
| Vault | VaultKmsProvider |
HashiCorp Vault Transit | None (uses fetch) |
| Local | LocalKmsProvider |
In-memory (crypto-lib) | None |
Every provider exposes the KmsProvider interface:
| Method | Description |
|---|---|
listKeys(filters?) |
List all managed keys, with optional filters |
getKey(keyId) |
Retrieve metadata for a specific key |
createKey(algorithm, usage, metadata?) |
Create a new managed key |
enableKey(keyId) |
Enable a disabled key |
disableKey(keyId) |
Disable a key (soft delete) |
scheduleKeyDeletion(keyId, days?) |
Schedule a key for deletion |
encrypt(keyId, plaintext, context?) |
Encrypt plaintext with a managed key |
decrypt(keyId, ciphertext, context?) |
Decrypt ciphertext with a managed key |
sign(keyId, data, algorithm?) |
Sign data with a managed signing key |
verify(keyId, data, signature, algorithm?) |
Verify a signature |
rotateKey(keyId) |
Rotate key material (new version) |
generateDataKey(keyId, keySpec?) |
Generate a wrapped data encryption key |
| Provider | Credentials |
|---|---|
| AWS | Pass credentials in AwsKmsOptions, or rely on the default AWS credential chain |
| GCP | Uses Application Default Credentials (ADC). Set GOOGLE_APPLICATION_CREDENTIALS |
| Azure | Uses @azure/identity DefaultAzureCredential |
| Vault | Pass token in VaultKmsOptions |
| Local | No authentication required |
All examples are self-contained TypeScript files in the examples/
directory. Run any example with:
npx ts-node examples/<name>.ts
| Category | Example | Purpose |
|---|---|---|
| Local | local.ts | Create keys, encrypt/decrypt with the in-memory provider |
| AWS | aws.ts | AWS KMS setup and usage pattern |
| Envelope | envelope.ts | Envelope encryption with generateDataKey |
| Rotation | rotation.ts | Key rotation workflow |
| Multi | multi.ts | Provider-agnostic code across multiple backends |
pnpm --filter @sebastienrousseau/crypto-kms run build
pnpm --filter @sebastienrousseau/crypto-kms run test
pnpm --filter @sebastienrousseau/crypto-kms run lint
pnpm --filter @sebastienrousseau/crypto-kms run format
All 14 packages in the Crypto Service workspace maintain a 100% coverage floor across statements, branches, functions, and lines.
Report vulnerabilities privately via GitHub Security Advisories or according to SECURITY.md. Never report security issues publicly.
All cryptographic operations leverage audited primitives, enforce constant-time execution where applicable, and zero sensitive key material upon disposal.
Versions advance strictly one step at a time on the 0.0.x line (v0.0.1 → v0.0.2 → v0.0.3 ... → v0.0.999 → v0.1.0). Work for every release iteration begins on a dedicated feat/v<version> branch.
All 14 packages in the workspace move in lockstep. Public API signatures, cipher output formats, and serialization schemas are strictly versioned. Breaking changes to serialized formats or algorithm defaults are considered major breaking changes. Minimum toolchain upgrades (e.g. Node.js LTS floor) are governed by POLICIES.md.
Dual-licensed under Apache 2.0 or MIT, at your option.
Copyright (c) 2022-2026 Sebastien Rousseau and The Crypto Service Suite contributors.