@sebastienrousseau/crypto-api
v0.0.35
Published
Shared TypeScript types for the crypto-server REST API: request and response contracts used by the server and the SDK.
Maintainers
Readme
Contents
Getting started
- Install — installation via pnpm, npm, or yarn
- Requirements — runtime floor and environment prerequisites
- Quick Start — minimal working usage sample
The Crypto Service ecosystem
- The Crypto Service ecosystem — full 18-package suite overview
Package reference
- Reference & Usage — features, configuration, and capabilities
- Examples — runnable sample code
Operational
- Development — build, lint, format, and test targets
- Security — vulnerability disclosure and cryptographic invariants
- Documentation — TypeDoc API docs and ecosystem guides
- Stability guarantees — SemVer axis and release policy
- License
Install
pnpm add @sebastienrousseau/crypto-api
# or
npm install @sebastienrousseau/crypto-api
# or
yarn add @sebastienrousseau/crypto-apiRequirements
- Node.js:
^22.0.0or>=24.0.0(active and maintenance LTS releases) - Package Manager:
pnpm >=9(recommended) ornpm >=10 - TypeScript:
>=5.0(when compiling with TypeScript)
Quick Start
Import shared types and use them to build type-safe requests and
responses across crypto-server and crypto-sdk.
import type {
AuthorizationToken,
AuthorizationInfo,
CollectionItem,
JsonDocument,
JsonRequest,
RequestHeader,
ResponseType,
} from "@sebastienrousseau/crypto-api";
// Type-safe request header
const header: RequestHeader = {
key: "Content-Type",
value: "application/json",
description: "Request content type",
};
// Build a typed JSON request
const request: JsonRequest = {
header: [header],
key: "encrypt",
value: "aes-256-gcm",
description: "Encrypt payload with AES-256-GCM",
};The Crypto Service ecosystem
Crypto Service provides a complete cryptography stack across 14 specialized packages:
| Package | Role | Description |
| :---------------------------------------------------------------------------------------------------------------------------------------- | :-------------- | :----------------------------------------------------------------------------------------------------------------------------- |
| @sebastienrousseau/crypto-api (this package) | API Schemas | Shared TypeScript types and utilities for the Crypto Service Suite, defining the canonical API surface. |
| @sebastienrousseau/crypto-benchmarks | Benchmarks | Benchmarks comparing classical and post-quantum cryptography: ops/sec, latency and throughput. |
| @sebastienrousseau/crypto-cbom | CBOM | Cryptographic Bill of Materials generator and auditor (CycloneDX 1.6, SPDX 3.0). |
| @sebastienrousseau/crypto-cli | Terminal CLI | Command-line interface: hashing, key generation, encryption, signing, HPKE, Argon2id and CBOM scans, with an interactive menu. |
| @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 | Cloud KMS | Unified KMS interface: AWS KMS and local providers implemented; GCP, Azure and Vault are stubs. |
| @sebastienrousseau/crypto-lib | Core Library | Core library: post-quantum ML-KEM, ML-DSA and SLH-DSA, plus classical, modern and OpenPGP cryptography for TypeScript. |
| @sebastienrousseau/crypto-lsp | IDE Analysis | Language server that flags weak and quantum-vulnerable cryptography in the editor, with quick fixes. |
| @sebastienrousseau/crypto-mcp | AI Agents | Model Context Protocol server exposing cryptography tools to AI assistants and agents. |
| @sebastienrousseau/crypto-middleware | Middleware | Cryptographic middleware for Express and Fastify: decrypt requests, encrypt responses, verify HMAC signatures and JWTs. |
| @sebastienrousseau/crypto-prisma | ORM Adapter | Transparent field-level encryption extension for Prisma Client, using XChaCha20-Poly1305. |
| @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 | Placeholder for a WebAssembly accelerator; no WebAssembly module ships yet. |
Overview
crypto-api provides the shared TypeScript type definitions and
utility functions used across the Crypto Service Suite. It defines
the canonical API surface -- request headers, response types,
authorization tokens, and collection items -- that crypto-server,
crypto-sdk, and other packages depend on. Utility functions convert
Postman-style JSON collections into Markdown documentation.
Features
Exported Types
All types are exported from src/@types/types.ts.
| Type | Description |
| :------------------- | :------------------------------------------------------------------------------ |
| AuthorizationToken | A single authorization token with key, type, and value fields |
| AuthorizationInfo | Full authorization payload including bearer tokens and metadata |
| CollectionItem | A Postman-style collection item -- either a folder with children or an endpoint |
| JsonDocument | Top-level document with info metadata and an array of CollectionItems |
| MethodType | A named method with optional request and response details |
| JsonRequest | An API request shape with headers, key/value pair, and description |
| RequestHeader | A single request header with key, value, and description |
| ResponseType | A response entry with HTTP code, status, and body |
Utilities
Utility functions are exported from src/utils/index.ts. They
convert Postman-style JSON collections into Markdown documentation.
| Function | Description |
| :------------------ | :-------------------------------------------------- |
| createMarkdown | Converts a full JSON document to Markdown |
| readAuthorization | Renders authorization info as a Markdown table |
| readRequest | Renders request headers as a Markdown table |
| readQueryParams | Renders query parameters as a Markdown table |
| readFormDataBody | Renders raw or form-data request bodies in Markdown |
| readResponse | Renders response codes and an example response body |
| readMethods | Renders a single API method with all its sections |
| readItems | Recursively renders a collection tree to Markdown |
| response | Writes generated Markdown to a file on disk |
Examples
All examples are self-contained TypeScript files in the examples/
directory. Run any example with:
npx ts-node examples/<name>.ts| Category | Example | Purpose | | :--------- | :-------------------------------------- | :------------------------------------- | | Types | types.ts | Using API types for type-safe requests | | Utilities | utilities.ts | Using exported utility functions | | Validation | validation.ts | Validating API payloads against types |
Development
pnpm --filter @sebastienrousseau/crypto-api run build
pnpm --filter @sebastienrousseau/crypto-api run test
pnpm --filter @sebastienrousseau/crypto-api run lint
pnpm --filter @sebastienrousseau/crypto-api run formatAll 18 packages in the Crypto Service workspace maintain a 100% coverage floor across statements, branches, functions, and lines.
Security
Report vulnerabilities privately via GitHub Security Advisories or according to SECURITY.md. Never report security issues publicly.
Cryptographic operations use the @noble/* libraries, Node.js crypto and OpenPGP.js. @noble/post-quantum has not been independently audited and does not guarantee constant-time execution, and no module in this suite is FIPS 140-3 validated. Key zeroization is limited: JavaScript strings and garbage-collected buffers cannot be reliably wiped. See SECURITY.md.
Documentation
Stability guarantees
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 18 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.
License
Dual-licensed under Apache 2.0 or MIT, at your option.
Copyright (c) 2022-2026 Sebastien Rousseau and The Crypto Service Suite contributors.
