@sebastienrousseau/crypto-server 0.0.2 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +292 -123
- package/dist/@types/types.d.ts +34 -14
- package/dist/@types/types.d.ts.map +1 -1
- package/dist/@types/types.js +15 -0
- package/dist/config/auth-policy.d.ts +2 -0
- package/dist/config/auth-policy.d.ts.map +1 -0
- package/dist/config/auth-policy.js +18 -0
- package/dist/config/constants.d.ts +54 -0
- package/dist/config/constants.d.ts.map +1 -0
- package/dist/config/constants.js +101 -0
- package/dist/config/env.d.ts +16 -0
- package/dist/config/env.d.ts.map +1 -0
- package/dist/config/env.js +74 -0
- package/dist/enterprise/metering.d.ts +19 -0
- package/dist/enterprise/metering.d.ts.map +1 -0
- package/dist/enterprise/metering.js +159 -0
- package/dist/enterprise/types.d.ts +78 -0
- package/dist/enterprise/types.d.ts.map +1 -0
- package/dist/enterprise/types.js +3 -0
- package/dist/index.js +38 -74
- package/dist/lib/auth.d.ts +14 -0
- package/dist/lib/auth.d.ts.map +1 -0
- package/dist/lib/auth.js +120 -0
- package/dist/lib/logger.d.ts.map +1 -1
- package/dist/lib/logger.js +6 -5
- package/dist/lib/telemetry.d.ts +4 -0
- package/dist/lib/telemetry.d.ts.map +1 -0
- package/dist/lib/telemetry.js +92 -0
- package/dist/lib/version.d.ts +2 -0
- package/dist/lib/version.d.ts.map +1 -0
- package/dist/lib/version.js +7 -0
- package/dist/routes/index.d.ts.map +1 -1
- package/dist/routes/index.js +19 -4
- package/dist/routes/probes.d.ts +4 -0
- package/dist/routes/probes.d.ts.map +1 -0
- package/dist/routes/probes.js +52 -0
- package/dist/routes/v1/decrypt.d.ts +2 -2
- package/dist/routes/v1/decrypt.d.ts.map +1 -1
- package/dist/routes/v1/decrypt.js +49 -6
- package/dist/routes/v1/encrypt.d.ts +2 -2
- package/dist/routes/v1/encrypt.d.ts.map +1 -1
- package/dist/routes/v1/encrypt.js +48 -6
- package/dist/routes/v1/generate.d.ts +2 -2
- package/dist/routes/v1/generate.d.ts.map +1 -1
- package/dist/routes/v1/generate.js +85 -13
- package/dist/routes/v1/index.d.ts +4 -0
- package/dist/routes/v1/index.d.ts.map +1 -0
- package/dist/routes/v1/index.js +19 -0
- package/dist/routes/v1/revoke.d.ts +2 -2
- package/dist/routes/v1/revoke.d.ts.map +1 -1
- package/dist/routes/v1/revoke.js +57 -5
- package/dist/routes/v1/verify.d.ts +4 -0
- package/dist/routes/v1/verify.d.ts.map +1 -0
- package/dist/routes/v1/verify.js +60 -0
- package/dist/routes/v2/algorithms.d.ts +4 -0
- package/dist/routes/v2/algorithms.d.ts.map +1 -0
- package/dist/routes/v2/algorithms.js +15 -0
- package/dist/routes/v2/compliance.d.ts +31 -0
- package/dist/routes/v2/compliance.d.ts.map +1 -0
- package/dist/routes/v2/compliance.js +223 -0
- package/dist/routes/v2/encrypt.d.ts +4 -0
- package/dist/routes/v2/encrypt.d.ts.map +1 -0
- package/dist/routes/v2/encrypt.js +62 -0
- package/dist/routes/v2/hash.d.ts +4 -0
- package/dist/routes/v2/hash.d.ts.map +1 -0
- package/dist/routes/v2/hash.js +34 -0
- package/dist/routes/v2/index.d.ts +4 -0
- package/dist/routes/v2/index.d.ts.map +1 -0
- package/dist/routes/v2/index.js +44 -0
- package/dist/routes/v2/kdf.d.ts +4 -0
- package/dist/routes/v2/kdf.d.ts.map +1 -0
- package/dist/routes/v2/kdf.js +54 -0
- package/dist/routes/v2/key-wrap.d.ts +4 -0
- package/dist/routes/v2/key-wrap.d.ts.map +1 -0
- package/dist/routes/v2/key-wrap.js +97 -0
- package/dist/routes/v2/keys.d.ts +4 -0
- package/dist/routes/v2/keys.d.ts.map +1 -0
- package/dist/routes/v2/keys.js +88 -0
- package/dist/routes/v2/mac.d.ts +4 -0
- package/dist/routes/v2/mac.d.ts.map +1 -0
- package/dist/routes/v2/mac.js +102 -0
- package/dist/routes/v2/multi-recipient.d.ts +4 -0
- package/dist/routes/v2/multi-recipient.d.ts.map +1 -0
- package/dist/routes/v2/multi-recipient.js +88 -0
- package/dist/routes/v2/password-encrypt.d.ts +4 -0
- package/dist/routes/v2/password-encrypt.d.ts.map +1 -0
- package/dist/routes/v2/password-encrypt.js +92 -0
- package/dist/routes/v2/password.d.ts +4 -0
- package/dist/routes/v2/password.d.ts.map +1 -0
- package/dist/routes/v2/password.js +109 -0
- package/dist/routes/v2/pq-hash-sign.d.ts +4 -0
- package/dist/routes/v2/pq-hash-sign.d.ts.map +1 -0
- package/dist/routes/v2/pq-hash-sign.js +131 -0
- package/dist/routes/v2/pq-sign.d.ts +4 -0
- package/dist/routes/v2/pq-sign.d.ts.map +1 -0
- package/dist/routes/v2/pq-sign.js +117 -0
- package/dist/routes/v2/pq.d.ts +4 -0
- package/dist/routes/v2/pq.d.ts.map +1 -0
- package/dist/routes/v2/pq.js +149 -0
- package/dist/routes/v2/sealedbox.d.ts +4 -0
- package/dist/routes/v2/sealedbox.d.ts.map +1 -0
- package/dist/routes/v2/sealedbox.js +145 -0
- package/dist/routes/v2/secretbox.d.ts +4 -0
- package/dist/routes/v2/secretbox.d.ts.map +1 -0
- package/dist/routes/v2/secretbox.js +94 -0
- package/dist/routes/v2/signing.d.ts +4 -0
- package/dist/routes/v2/signing.d.ts.map +1 -0
- package/dist/routes/v2/signing.js +66 -0
- package/dist/routes/v2/stream.d.ts +4 -0
- package/dist/routes/v2/stream.d.ts.map +1 -0
- package/dist/routes/v2/stream.js +206 -0
- package/dist/server.d.ts +4 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +124 -0
- package/dist/utils/route-helpers.d.ts +15 -0
- package/dist/utils/route-helpers.d.ts.map +1 -0
- package/dist/utils/route-helpers.js +42 -0
- package/dist/utils/validation.d.ts +29 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +162 -0
- package/package.json +103 -140
- package/dist/@types/types.js.map +0 -1
- package/dist/COPYRIGHT +0 -14
- package/dist/Report.txt +0 -90
- package/dist/config/endpoints.config.d.ts +0 -7
- package/dist/config/endpoints.config.d.ts.map +0 -1
- package/dist/config/endpoints.config.js +0 -8
- package/dist/config/endpoints.config.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/logger.js.map +0 -1
- package/dist/package.json +0 -141
- package/dist/routes/index.js.map +0 -1
- package/dist/routes/v1/decrypt.js.map +0 -1
- package/dist/routes/v1/encrypt.js.map +0 -1
- package/dist/routes/v1/generate.js.map +0 -1
- package/dist/routes/v1/revoke.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,170 +1,339 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- SPDX-License-Identifier: Apache-2.0 OR MIT -->
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="https://raw.githubusercontent.com/sebastienrousseau/crypto-service/main/assets/crypto-server-logo.svg" alt="crypto-server logo" width="360" />
|
|
5
|
+
</p>
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
<h1 align="center">@sebastienrousseau/crypto-server</h1>
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
<p align="center">
|
|
10
|
+
A hardened Fastify REST API for cryptographic operations, with rate limiting, OpenAPI schemas, and post-quantum endpoints.
|
|
11
|
+
</p>
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
<p align="center">
|
|
14
|
+
<a href="https://github.com/sebastienrousseau/crypto-service/actions"><img src="https://img.shields.io/github/actions/workflow/status/sebastienrousseau/crypto-service/ci.yml?branch=main&style=for-the-badge&logo=github" alt="Build" /></a>
|
|
15
|
+
<a href="https://coveralls.io/github/sebastienrousseau/crypto-service?branch=main"><img src="https://img.shields.io/coveralls/github/sebastienrousseau/crypto-service?branch=main&style=for-the-badge" alt="Coverage" /></a>
|
|
16
|
+
<a href="https://www.npmjs.com/package/@sebastienrousseau/crypto-server"><img src="https://img.shields.io/npm/v/@sebastienrousseau/crypto-server.svg?style=for-the-badge&color=f14041&logo=npm" alt="Registry" /></a>
|
|
17
|
+
<a href="https://sebastienrousseau.github.io/crypto-service/"><img src="https://img.shields.io/badge/docs-TypeDoc-blue.svg?style=for-the-badge&labelColor=555555&logo=typescript" alt="Docs" /></a>
|
|
18
|
+
<a href="https://scorecard.dev/viewer/?uri=github.com/sebastienrousseau/crypto-service" title="ossf-scorecard"><img src="https://img.shields.io/badge/OpenSSF-Scorecard-blue?style=for-the-badge&logo=openssf" alt="OpenSSF Scorecard" /></a>
|
|
19
|
+
<a href="https://github.com/sebastienrousseau/crypto-service/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0%20OR%20MIT-blue.svg?style=for-the-badge" alt="License: Apache-2.0 OR MIT" /></a>
|
|
20
|
+
<a href="https://github.com/sebastienrousseau/crypto-service/blob/main/docs/POLICIES.md"><img src="https://img.shields.io/badge/Node.js-%3E%3D22-93450a.svg?style=for-the-badge&logo=node.js" alt="Node.js 22 or newer" /></a>
|
|
21
|
+
</p>
|
|
14
22
|
|
|
15
|
-
|
|
16
|
-
- Encryption and Decryption,
|
|
17
|
-
- Key Generation,
|
|
18
|
-
- Key Management,
|
|
19
|
-
- Pseudorandom Number Generation,
|
|
20
|
-
- Signature Verification.
|
|
23
|
+
---
|
|
21
24
|
|
|
22
|
-
|
|
23
|
-
Source code is available to everyone under the standard [MIT license][8].
|
|
25
|
+
## Contents
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
**Getting started**
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
- [Install](#install) — installation via pnpm, npm, or yarn
|
|
30
|
+
- [Requirements](#requirements) — runtime floor and environment prerequisites
|
|
31
|
+
- [Quick Start](#quick-start) — minimal working usage sample
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
[`yarn`][9] or [`pnpm`][10] package managers to use Crypto Server with Node.js
|
|
33
|
-
or the Command Line Interface:
|
|
33
|
+
**The Crypto Service ecosystem**
|
|
34
34
|
|
|
35
|
-
-
|
|
36
|
-
- `yarn add @sebastienrousseau/crypto-server`
|
|
37
|
-
- `pnpm add @sebastienrousseau/crypto-server`
|
|
35
|
+
- [The Crypto Service ecosystem](#the-crypto-service-ecosystem) — full 14-package suite overview
|
|
38
36
|
|
|
39
|
-
|
|
37
|
+
**Package reference**
|
|
40
38
|
|
|
41
|
-
|
|
39
|
+
- [Reference & Usage](#overview) — features, configuration, and capabilities
|
|
40
|
+
- [Examples](#examples) — runnable sample code
|
|
42
41
|
|
|
43
|
-
|
|
44
|
-
- Enter one of the following commands to start the Crypto Server:
|
|
42
|
+
**Operational**
|
|
45
43
|
|
|
46
|
-
|
|
44
|
+
- [Development](#development) — build, lint, format, and test targets
|
|
45
|
+
- [Security](#security) — vulnerability disclosure and cryptographic invariants
|
|
46
|
+
- [Documentation](#documentation) — TypeDoc API docs and ecosystem guides
|
|
47
|
+
- [Stability guarantees](#stability-guarantees) — SemVer axis and release policy
|
|
48
|
+
- [License](#license)
|
|
47
49
|
|
|
48
|
-
|
|
50
|
+
---
|
|
49
51
|
|
|
50
|
-
|
|
52
|
+
## Install
|
|
51
53
|
|
|
52
|
-
|
|
54
|
+
```bash
|
|
55
|
+
pnpm add @sebastienrousseau/crypto-server
|
|
56
|
+
# or
|
|
57
|
+
npm install @sebastienrousseau/crypto-server
|
|
58
|
+
# or
|
|
59
|
+
yarn add @sebastienrousseau/crypto-server
|
|
60
|
+
```
|
|
53
61
|
|
|
54
|
-
|
|
62
|
+
<p align="right"><a href="#contents">Back to Top</a></p>
|
|
55
63
|
|
|
56
|
-
|
|
64
|
+
---
|
|
57
65
|
|
|
58
|
-
|
|
59
|
-
environment details:
|
|
66
|
+
## Requirements
|
|
60
67
|
|
|
61
|
-
-
|
|
62
|
-
-
|
|
63
|
-
-
|
|
64
|
-
- IP: 127.0.0.1.
|
|
68
|
+
- **Node.js**: `^22.0.0` or `>=24.0.0` (active and maintenance LTS releases)
|
|
69
|
+
- **Package Manager**: `pnpm >=9` (recommended) or `npm >=10`
|
|
70
|
+
- **TypeScript**: `>=5.0` (when compiling with TypeScript)
|
|
65
71
|
|
|
66
|
-
|
|
67
|
-
[http://localhost:3000/](http://localhost:3000/)
|
|
72
|
+
<p align="right"><a href="#contents">Back to Top</a></p>
|
|
68
73
|
|
|
69
|
-
|
|
74
|
+
---
|
|
70
75
|
|
|
71
|
-
|
|
72
|
-
solutions to perform low-level cryptographic operations, key storage operations,
|
|
73
|
-
protect static data, and securely share secrets.
|
|
76
|
+
## Quick Start
|
|
74
77
|
|
|
75
|
-
|
|
76
|
-
operation in the host environment, subsequently the response is transferred back
|
|
77
|
-
to the requesting application. All operations that are performed andd coming
|
|
78
|
-
through the Crypto Server are monitored so statistics can be made and acted upon
|
|
78
|
+
Start the server:
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
```bash
|
|
81
|
+
npx crypto-server
|
|
82
|
+
# or, from a clone of this repo:
|
|
83
|
+
pnpm --filter @sebastienrousseau/crypto-server start
|
|
84
|
+
```
|
|
82
85
|
|
|
83
|
-
|
|
84
|
-
protocol version to be enforced for your API Gateway custom domain. Crypto
|
|
85
|
-
Server recommends either a TLS version 1.3 or TLS version 1.3 security policy.
|
|
86
|
+
Hash some data:
|
|
86
87
|
|
|
87
|
-
|
|
88
|
+
```bash
|
|
89
|
+
curl -s -X POST http://localhost:3000/v2/hash \
|
|
90
|
+
-H "Content-Type: application/json" \
|
|
91
|
+
-H "x-api-key: your-secret-api-key" \
|
|
92
|
+
-d '{"algorithm":"sha256","data":"Hello, world!"}' | jq
|
|
93
|
+
```
|
|
88
94
|
|
|
89
|
-
|
|
95
|
+
```json
|
|
96
|
+
{
|
|
97
|
+
"data": "315f5bdb76d078c43b8ac0064e4a0164612b1fce77c869345bfc94c75894edd3"
|
|
98
|
+
}
|
|
99
|
+
```
|
|
90
100
|
|
|
91
|
-
|
|
101
|
+
<p align="right"><a href="#contents">Back to Top</a></p>
|
|
92
102
|
|
|
93
|
-
|
|
94
|
-
|---|---|---|
|
|
95
|
-
|type|rsa|The primary key algorithm type: ECC (default) or RSA. |
|
|
96
|
-
|bits|2048|Number of bits for RSA keys (defaults to 4096 bits). |
|
|
97
|
-
|name|Jane Doe|First name and Last name |
|
|
98
|
-
|email|jane@doe.com|Email address |
|
|
99
|
-
|passphrase|123456789abcdef|The passphrase used to encrypt the private key. |
|
|
100
|
-
|curve|null|Elliptic curve for ECC keys. See Appendix for more detail... |
|
|
101
|
-
|expiration|0|Number of seconds from the key creation time. |
|
|
102
|
-
|format|armored|Format of the output keys e.g. 'armored' | 'object' | 'binary'.|
|
|
103
|
+
---
|
|
103
104
|
|
|
104
|
-
|
|
105
|
-
curl --location --request GET 'http://localhost:3000/v1/generate' \
|
|
106
|
-
--header 'type: rsa' \
|
|
107
|
-
--header 'bits: 2048' \
|
|
108
|
-
--header 'name: Jane Doe' \
|
|
109
|
-
--header 'email: jane@doe.com' \
|
|
110
|
-
--header 'passphrase: 123456789abcdef' \
|
|
111
|
-
--header 'curve: null' \
|
|
112
|
-
--header 'expiration: 0' \
|
|
113
|
-
--header 'format: armored'
|
|
114
|
-
```
|
|
105
|
+
## The Crypto Service ecosystem
|
|
115
106
|
|
|
116
|
-
|
|
107
|
+
Crypto Service provides a complete cryptography stack across 14 specialized packages:
|
|
117
108
|
|
|
118
|
-
|
|
109
|
+
| Package | Role | Description |
|
|
110
|
+
| :-------------------------------------------------------------------------- | :-------------- | :------------------------------------------------------------------------------------------------------------------------------------- |
|
|
111
|
+
| [`@sebastienrousseau/crypto-api`](../crypto-api) | API Schemas | Shared TypeScript types and utilities for the Crypto Service Suite, defining the canonical API surface. |
|
|
112
|
+
| [`@sebastienrousseau/crypto-cli`](../crypto-cli) | Terminal CLI | An interactive command-line interface for cryptographic operations, supporting both legacy OpenPGP and modern post-quantum algorithms. |
|
|
113
|
+
| [`@sebastienrousseau/crypto-edge`](../crypto-edge) | Edge Runtime | Edge-runtime cryptographic operations using the Web Crypto API, optimized for Cloudflare Workers, Vercel Edge, and Deno. |
|
|
114
|
+
| [`@sebastienrousseau/crypto-kms`](../crypto-kms) | Cloud KMS | Unified Key Management Service interface for AWS KMS, GCP Cloud KMS, Azure Key Vault, and HashiCorp Vault. |
|
|
115
|
+
| [`@sebastienrousseau/crypto-lib`](../crypto-lib) | Core Library | A modern cryptographic library for TypeScript, with post-quantum support, zero unsafe dependencies, and 100% test coverage. |
|
|
116
|
+
| [`@sebastienrousseau/crypto-middleware`](../crypto-middleware) | Middleware | Framework-agnostic cryptographic middleware for Express, Fastify, and Koa applications. |
|
|
117
|
+
| [`@sebastienrousseau/crypto-prisma`](../crypto-prisma) | ORM Adapter | Transparent field-level encryption extension for Prisma Client, using XChaCha20-Poly1305. |
|
|
118
|
+
| [`@sebastienrousseau/crypto-react`](../crypto-react) | React Hooks | React hooks and context provider for client-side cryptographic operations with zero boilerplate. |
|
|
119
|
+
| [`@sebastienrousseau/crypto-sdk`](../crypto-sdk) | Client SDK | A zero-dependency, typed HTTP client for the Crypto Service REST API, with full post-quantum support. |
|
|
120
|
+
| **[`@sebastienrousseau/crypto-server`](../crypto-server)** _(this package)_ | **HTTP API** | **A hardened Fastify REST API for cryptographic operations, with rate limiting, OpenAPI schemas, and post-quantum endpoints.** |
|
|
121
|
+
| [`@sebastienrousseau/crypto-testing`](../crypto-testing) | Test Support | Deterministic keys, fast mocks, and test fixtures for crypto-lib |
|
|
122
|
+
| [`@sebastienrousseau/crypto-typeorm`](../crypto-typeorm) | ORM Adapter | TypeORM column-level encryption with a single decorator, powered by crypto-lib. |
|
|
123
|
+
| [`@sebastienrousseau/crypto-vue`](../crypto-vue) | Vue Composables | Vue 3 composables for client-side cryptography |
|
|
124
|
+
| [`@sebastienrousseau/crypto-wasm`](../crypto-wasm) | Acceleration | WebAssembly performance accelerator for crypto-lib |
|
|
119
125
|
|
|
120
|
-
|
|
121
|
-
|---|---|---|
|
|
122
|
-
|passphrase|123456789abcdef|Passphrase to encrypt the message.|
|
|
123
|
-
|message|Hello Crypto Service!|Message to be encrypted.|
|
|
124
|
-
|publicKey|{{publicKey}}|A public key.|
|
|
125
|
-
|privateKey|{{privateKey}}|A private key.|
|
|
126
|
+
<p align="right"><a href="#contents">Back to Top</a></p>
|
|
126
127
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Overview
|
|
131
|
+
|
|
132
|
+
Crypto Server is built on **Fastify 4.x** with a layered middleware
|
|
133
|
+
stack:
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
Request
|
|
137
|
+
-> @fastify/helmet (security headers)
|
|
138
|
+
-> @fastify/cors
|
|
139
|
+
-> @fastify/rate-limit
|
|
140
|
+
-> @fastify/compress
|
|
141
|
+
-> Authentication (x-api-key / JWT Bearer)
|
|
142
|
+
-> Route handler
|
|
143
|
+
-> Response
|
|
133
144
|
```
|
|
134
145
|
|
|
135
|
-
|
|
146
|
+
### Route versioning
|
|
147
|
+
|
|
148
|
+
| Prefix | Status | Notes |
|
|
149
|
+
| :---------------------------- | :------------- | :---------------------------------------------------------------------------- |
|
|
150
|
+
| `/v1/*` | **Deprecated** | Legacy PGP-based endpoints. Emit `Deprecation`, `Sunset`, and `Link` headers. |
|
|
151
|
+
| `/v2/*` | **Current** | Modern endpoints using `@noble/*` primitives and post-quantum algorithms. |
|
|
152
|
+
| `/live`, `/ready`, `/metrics` | Stable | Infrastructure probes (no auth required). |
|
|
153
|
+
|
|
154
|
+
<p align="right"><a href="#contents">Back to Top</a></p>
|
|
155
|
+
|
|
156
|
+
## API Routes
|
|
157
|
+
|
|
158
|
+
All v2 endpoints accept and return `application/json`. Authenticated
|
|
159
|
+
requests must include an `x-api-key` header (or
|
|
160
|
+
`Authorization: Bearer <jwt>`).
|
|
161
|
+
|
|
162
|
+
| Method | Path | Description |
|
|
163
|
+
| :----- | :---------------------------- | :----------------------------------------------------------- |
|
|
164
|
+
| `POST` | `/v2/hash` | Compute a cryptographic hash (SHA-2, SHA-3, BLAKE2b, BLAKE3) |
|
|
165
|
+
| `POST` | `/v2/encrypt` | AEAD encryption with XChaCha20-Poly1305 |
|
|
166
|
+
| `POST` | `/v2/decrypt` | AEAD decryption with XChaCha20-Poly1305 |
|
|
167
|
+
| `POST` | `/v2/sign` | Create a digital signature |
|
|
168
|
+
| `POST` | `/v2/verify` | Verify a digital signature |
|
|
169
|
+
| `POST` | `/v2/kdf` | Derive a key (scrypt, HKDF-SHA256, PBKDF2-SHA256) |
|
|
170
|
+
| `POST` | `/v2/hmac` | Compute an HMAC |
|
|
171
|
+
| `POST` | `/v2/hmac/verify` | Verify an HMAC in constant time |
|
|
172
|
+
| `POST` | `/v2/password/hash` | Hash a password with Argon2id |
|
|
173
|
+
| `POST` | `/v2/password/verify` | Verify a password against an Argon2id hash |
|
|
174
|
+
| `POST` | `/v2/password/encrypt` | Encrypt with password (Argon2id + XChaCha20-Poly1305) |
|
|
175
|
+
| `POST` | `/v2/password/decrypt` | Decrypt with password |
|
|
176
|
+
| `POST` | `/v2/keys/generate` | Generate a key pair for any supported algorithm |
|
|
177
|
+
| `POST` | `/v2/keys/wrap` | Wrap a key with AES-KW or AES-KWP |
|
|
178
|
+
| `POST` | `/v2/keys/unwrap` | Unwrap a key |
|
|
179
|
+
| `POST` | `/v2/secretbox/seal` | Encrypt with XChaCha20-Poly1305 (secretbox) |
|
|
180
|
+
| `POST` | `/v2/secretbox/open` | Decrypt a secretbox ciphertext |
|
|
181
|
+
| `POST` | `/v2/sealedbox/seal` | Anonymous public-key encryption (X25519) |
|
|
182
|
+
| `POST` | `/v2/sealedbox/open` | Decrypt an anonymous sealed box |
|
|
183
|
+
| `POST` | `/v2/sealedbox/seal-pq` | Post-quantum sealed box (X25519 + ML-KEM-768) |
|
|
184
|
+
| `POST` | `/v2/sealedbox/open-pq` | Decrypt a post-quantum sealed box |
|
|
185
|
+
| `POST` | `/v2/multi-recipient/encrypt` | Encrypt for multiple recipients |
|
|
186
|
+
| `POST` | `/v2/pq/keygen` | Generate an ML-KEM-768 key pair (FIPS 203) |
|
|
187
|
+
| `POST` | `/v2/pq/encapsulate` | Encapsulate a shared secret with ML-KEM-768 |
|
|
188
|
+
| `POST` | `/v2/pq/decapsulate` | Decapsulate and recover the shared secret |
|
|
189
|
+
| `POST` | `/v2/pq/hybrid/keygen` | Generate a hybrid X25519 + ML-KEM-768 key pair |
|
|
190
|
+
| `POST` | `/v2/pq/hybrid/encapsulate` | Hybrid encapsulation |
|
|
191
|
+
| `POST` | `/v2/pq/hybrid/decapsulate` | Hybrid decapsulation |
|
|
192
|
+
| `POST` | `/v2/pq/dsa/keygen` | Generate an ML-DSA key pair (FIPS 204) |
|
|
193
|
+
| `POST` | `/v2/pq/dsa/sign` | Sign with ML-DSA |
|
|
194
|
+
| `POST` | `/v2/pq/dsa/verify` | Verify an ML-DSA signature |
|
|
195
|
+
| `POST` | `/v2/pq/slh-dsa/keygen` | Generate an SLH-DSA key pair (FIPS 205) |
|
|
196
|
+
| `POST` | `/v2/pq/slh-dsa/sign` | Sign with SLH-DSA |
|
|
197
|
+
| `POST` | `/v2/pq/slh-dsa/verify` | Verify an SLH-DSA signature |
|
|
198
|
+
| `GET` | `/v2/algorithms` | List all supported algorithms |
|
|
199
|
+
| `GET` | `/live` | Liveness probe (Kubernetes) |
|
|
200
|
+
| `GET` | `/ready` | Readiness probe (Kubernetes) |
|
|
201
|
+
| `GET` | `/metrics` | Prometheus-compatible metrics |
|
|
202
|
+
|
|
203
|
+
<p align="right"><a href="#contents">Back to Top</a></p>
|
|
204
|
+
|
|
205
|
+
## Authentication
|
|
206
|
+
|
|
207
|
+
The server supports two authentication modes:
|
|
208
|
+
|
|
209
|
+
1. **API Key** -- set `CRYPTO_API_KEY` and pass it as the `x-api-key`
|
|
210
|
+
header.
|
|
211
|
+
2. **JWT Bearer** -- set `JWT_SECRET` and pass
|
|
212
|
+
`Authorization: Bearer <token>`.
|
|
213
|
+
|
|
214
|
+
If neither variable is set, all requests are allowed (development
|
|
215
|
+
mode).
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
# API key
|
|
219
|
+
curl -H "x-api-key: your-secret-api-key" ...
|
|
220
|
+
|
|
221
|
+
# JWT Bearer
|
|
222
|
+
curl -H "Authorization: Bearer eyJhbGciOi..." ...
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
<p align="right"><a href="#contents">Back to Top</a></p>
|
|
226
|
+
|
|
227
|
+
## Configuration
|
|
228
|
+
|
|
229
|
+
| Variable | Default | Description |
|
|
230
|
+
| :-------------------- | :------------ | :------------------------------------------------- |
|
|
231
|
+
| `PORT` | `3000` | TCP port to listen on |
|
|
232
|
+
| `HOST` | `localhost` | Bind address |
|
|
233
|
+
| `PROTOCOL` | `http` | `http` or `https` |
|
|
234
|
+
| `NODE_ENV` | `development` | `development`, `production`, or `test` |
|
|
235
|
+
| `LOG_LEVEL` | `info` | `error`, `warn`, `info`, or `debug` |
|
|
236
|
+
| `CRYPTO_API_KEY` | -- | Static API key for `x-api-key` authentication |
|
|
237
|
+
| `JWT_SECRET` | -- | HMAC secret for HS256 JWT validation |
|
|
238
|
+
| `CORS_ORIGIN` | -- | Comma-separated allowed origins (empty = disabled) |
|
|
239
|
+
| `TRUSTED_PROXY_CIDRS` | -- | Comma-separated trusted proxy CIDRs |
|
|
240
|
+
| `CRYPTO_KEY_DIR` | -- | Directory for key storage |
|
|
241
|
+
| `CRYPTO_KEY_OUT_DIR` | -- | Directory for key output |
|
|
242
|
+
| `SHUTDOWN_TIMEOUT_MS` | `30000` | Graceful shutdown timeout in milliseconds |
|
|
136
243
|
|
|
137
|
-
|
|
244
|
+
<p align="right"><a href="#contents">Back to Top</a></p>
|
|
138
245
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
246
|
+
## Examples
|
|
247
|
+
|
|
248
|
+
All examples are self-contained TypeScript files in the `examples/`
|
|
249
|
+
directory. Each uses `fetch` to call the server. Run any example
|
|
250
|
+
with:
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
# Start the server in one terminal:
|
|
254
|
+
pnpm --filter @sebastienrousseau/crypto-server start
|
|
255
|
+
|
|
256
|
+
# Run an example in another:
|
|
257
|
+
npx ts-node examples/<name>.ts
|
|
258
|
+
```
|
|
143
259
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
260
|
+
| Category | Example | Purpose |
|
|
261
|
+
| :-------------- | :---------------------------------------------- | :--------------------------------------- |
|
|
262
|
+
| Algorithms | [algorithms.ts](examples/algorithms.ts) | List supported algorithms |
|
|
263
|
+
| Encryption | [encrypt.ts](examples/encrypt.ts) | Encrypt and decrypt via v2 endpoints |
|
|
264
|
+
| Hashing | [hash.ts](examples/hash.ts) | Hash data via POST /v2/hash |
|
|
265
|
+
| HMAC | [hmac.ts](examples/hmac.ts) | HMAC compute and verify |
|
|
266
|
+
| KDF | [kdf.ts](examples/kdf.ts) | Key derivation |
|
|
267
|
+
| Key Generation | [keygen.ts](examples/keygen.ts) | Generate keys via POST /v2/keys/generate |
|
|
268
|
+
| Key Wrap | [keywrap.ts](examples/keywrap.ts) | AES key wrapping and unwrapping |
|
|
269
|
+
| Passwords | [password.ts](examples/password.ts) | Password hash and verify |
|
|
270
|
+
| PW Encrypt | [pwencrypt.ts](examples/pwencrypt.ts) | Password-based encryption and decryption |
|
|
271
|
+
| PQ KEM | [pqkem.ts](examples/pqkem.ts) | Post-quantum KEM operations |
|
|
272
|
+
| PQ Sign | [pqsign.ts](examples/pqsign.ts) | Post-quantum ML-DSA signing |
|
|
273
|
+
| PQ Hash Sign | [pqhashsign.ts](examples/pqhashsign.ts) | Post-quantum SLH-DSA signing |
|
|
274
|
+
| Probes | [probes.ts](examples/probes.ts) | Health and readiness checks |
|
|
275
|
+
| Multi-Recipient | [multirecipient.ts](examples/multirecipient.ts) | Multi-recipient encryption |
|
|
276
|
+
| Sealed Box | [sealedbox.ts](examples/sealedbox.ts) | Sealed box operations |
|
|
277
|
+
| Secretbox | [secretbox.ts](examples/secretbox.ts) | Secretbox seal and open |
|
|
278
|
+
| Signing | [sign.ts](examples/sign.ts) | Sign and verify via v2 endpoints |
|
|
279
|
+
|
|
280
|
+
<p align="right"><a href="#contents">Back to Top</a></p>
|
|
281
|
+
|
|
282
|
+
<p align="right"><a href="#contents">Back to Top</a></p>
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## Development
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
pnpm --filter @sebastienrousseau/crypto-server run build
|
|
290
|
+
pnpm --filter @sebastienrousseau/crypto-server run test
|
|
291
|
+
pnpm --filter @sebastienrousseau/crypto-server run lint
|
|
292
|
+
pnpm --filter @sebastienrousseau/crypto-server run format
|
|
148
293
|
```
|
|
149
294
|
|
|
150
|
-
|
|
295
|
+
All 18 packages in the Crypto Service workspace maintain a **100% coverage floor** across statements, branches, functions, and lines.
|
|
296
|
+
|
|
297
|
+
<p align="right"><a href="#contents">Back to Top</a></p>
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
## Security
|
|
302
|
+
|
|
303
|
+
Report vulnerabilities privately via [GitHub Security Advisories](https://github.com/sebastienrousseau/crypto-service/security/advisories) or according to [`SECURITY.md`](../../SECURITY.md). Never report security issues publicly.
|
|
304
|
+
|
|
305
|
+
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`](../../SECURITY.md).
|
|
306
|
+
|
|
307
|
+
<p align="right"><a href="#contents">Back to Top</a></p>
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
## Documentation
|
|
312
|
+
|
|
313
|
+
- [Full Suite Documentation](https://sebastienrousseau.github.io/crypto-service/)
|
|
314
|
+
- [API Reference (TypeDoc)](https://sebastienrousseau.github.io/crypto-service/)
|
|
315
|
+
- [Developer Guide](../../DEVELOPMENT.md)
|
|
316
|
+
- [Security Policy](../../SECURITY.md)
|
|
317
|
+
- [Architecture & Design](../../ARCHITECTURE.md)
|
|
318
|
+
|
|
319
|
+
<p align="right"><a href="#contents">Back to Top</a></p>
|
|
320
|
+
|
|
321
|
+
---
|
|
322
|
+
|
|
323
|
+
## Stability guarantees
|
|
324
|
+
|
|
325
|
+
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.
|
|
326
|
+
|
|
327
|
+
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](../../docs/POLICIES.md).
|
|
328
|
+
|
|
329
|
+
<p align="right"><a href="#contents">Back to Top</a></p>
|
|
330
|
+
|
|
331
|
+
---
|
|
151
332
|
|
|
152
|
-
|
|
153
|
-
[Contributing Guidelines][1] for further details on the process for submitting
|
|
154
|
-
pull requests to us.
|
|
333
|
+
## License
|
|
155
334
|
|
|
156
|
-
|
|
335
|
+
Dual-licensed under [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0) or [MIT](https://opensource.org/licenses/MIT), at your option.
|
|
157
336
|
|
|
158
|
-
|
|
159
|
-
brainpoolP256r1,brainpoolP384r1, or brainpoolP512r1.*
|
|
337
|
+
Copyright (c) 2022-2026 Sebastien Rousseau and The Crypto Service Suite contributors.
|
|
160
338
|
|
|
161
|
-
|
|
162
|
-
[2]: https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-lib
|
|
163
|
-
[3]: https://www.fastify.io
|
|
164
|
-
[4]: https://nodejs.org/en/
|
|
165
|
-
[5]: https://www.npmjs.com/
|
|
166
|
-
[6]: https://github.com
|
|
167
|
-
[7]: https://github.com/sebastienrousseau/crypto-server
|
|
168
|
-
[8]: https://github.com/sebastienrousseau/crypto-server/blob/main/LICENSE
|
|
169
|
-
[9]: https://yarnpkg.com/getting-started
|
|
170
|
-
[10]: https://pnpm.io/motivation
|
|
339
|
+
<p align="right"><a href="#contents">Back to Top</a></p>
|
package/dist/@types/types.d.ts
CHANGED
|
@@ -1,21 +1,41 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export declare
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
export declare const KEY_TYPES: readonly ["ecc", "rsa"];
|
|
2
|
+
export type KeyType = (typeof KEY_TYPES)[number];
|
|
3
|
+
export declare const CURVE_TYPES: readonly ["curve25519", "ed25519", "p256", "p384", "p521", "secp256k1", "brainpoolP256r1", "brainpoolP384r1", "brainpoolP512r1"];
|
|
4
|
+
export type CurveType = (typeof CURVE_TYPES)[number];
|
|
5
|
+
export declare const FORMAT_TYPES: readonly ["armored", "binary", "object"];
|
|
6
|
+
export type FormatType = (typeof FORMAT_TYPES)[number];
|
|
7
|
+
export declare const REVOCATION_FLAGS: readonly [0, 1, 2, 3];
|
|
8
|
+
export type RevocationFlag = (typeof REVOCATION_FLAGS)[number];
|
|
9
|
+
export interface IBodyGenerate {
|
|
8
10
|
name: string;
|
|
9
11
|
email: string;
|
|
12
|
+
type: KeyType;
|
|
13
|
+
passphrase: string;
|
|
14
|
+
rsaBits?: number;
|
|
15
|
+
curve: CurveType;
|
|
16
|
+
keyExpirationTime?: number;
|
|
17
|
+
format: FormatType;
|
|
18
|
+
}
|
|
19
|
+
export interface IBodyEncrypt {
|
|
20
|
+
passphrase: string;
|
|
21
|
+
message: string;
|
|
22
|
+
publicKey: string;
|
|
23
|
+
privateKey?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface IBodyDecrypt {
|
|
10
26
|
passphrase: string;
|
|
11
|
-
curve: string;
|
|
12
|
-
expiration: string;
|
|
13
|
-
format: string;
|
|
14
27
|
message: string;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
28
|
+
publicKey: string;
|
|
29
|
+
privateKey: string;
|
|
30
|
+
}
|
|
31
|
+
export interface IBodyRevoke {
|
|
18
32
|
passphrase: string;
|
|
33
|
+
flag: number;
|
|
34
|
+
reason: string;
|
|
35
|
+
}
|
|
36
|
+
export interface IBodyVerify {
|
|
37
|
+
date: string;
|
|
19
38
|
message: string;
|
|
20
|
-
|
|
39
|
+
verificationKeys: string;
|
|
40
|
+
}
|
|
21
41
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/@types/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/@types/types.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,SAAS,yBAA0B,CAAC;AAEjD,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAKjD,eAAO,MAAM,WAAW,kIAUd,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAKrD,eAAO,MAAM,YAAY,0CAA2C,CAAC;AAErE,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAKvD,eAAO,MAAM,gBAAgB,uBAAwB,CAAC;AAEtD,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAiB/D,MAAM,WAAW,aAAa;IAE5B,IAAI,EAAE,MAAM,CAAC;IAEb,KAAK,EAAE,MAAM,CAAC;IAEd,IAAI,EAAE,OAAO,CAAC;IAEd,UAAU,EAAE,MAAM,CAAC;IAEnB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,KAAK,EAAE,SAAS,CAAC;IAEjB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,MAAM,EAAE,UAAU,CAAC;CACpB;AAcD,MAAM,WAAW,YAAY;IAE3B,UAAU,EAAE,MAAM,CAAC;IAEnB,OAAO,EAAE,MAAM,CAAC;IAEhB,SAAS,EAAE,MAAM,CAAC;IAElB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAeD,MAAM,WAAW,YAAY;IAE3B,UAAU,EAAE,MAAM,CAAC;IAEnB,OAAO,EAAE,MAAM,CAAC;IAEhB,SAAS,EAAE,MAAM,CAAC;IAElB,UAAU,EAAE,MAAM,CAAC;CACpB;AAcD,MAAM,WAAW,WAAW;IAE1B,UAAU,EAAE,MAAM,CAAC;IAEnB,IAAI,EAAE,MAAM,CAAC;IAEb,MAAM,EAAE,MAAM,CAAC;CAChB;AAcD,MAAM,WAAW,WAAW;IAE1B,IAAI,EAAE,MAAM,CAAC;IAEb,OAAO,EAAE,MAAM,CAAC;IAEhB,gBAAgB,EAAE,MAAM,CAAC;CAC1B"}
|
package/dist/@types/types.js
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.REVOCATION_FLAGS = exports.FORMAT_TYPES = exports.CURVE_TYPES = exports.KEY_TYPES = void 0;
|
|
4
|
+
exports.KEY_TYPES = ["ecc", "rsa"];
|
|
5
|
+
exports.CURVE_TYPES = [
|
|
6
|
+
"curve25519",
|
|
7
|
+
"ed25519",
|
|
8
|
+
"p256",
|
|
9
|
+
"p384",
|
|
10
|
+
"p521",
|
|
11
|
+
"secp256k1",
|
|
12
|
+
"brainpoolP256r1",
|
|
13
|
+
"brainpoolP384r1",
|
|
14
|
+
"brainpoolP512r1",
|
|
15
|
+
];
|
|
16
|
+
exports.FORMAT_TYPES = ["armored", "binary", "object"];
|
|
17
|
+
exports.REVOCATION_FLAGS = [0, 1, 2, 3];
|
|
3
18
|
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-policy.d.ts","sourceRoot":"","sources":["../../src/config/auth-policy.ts"],"names":[],"mappings":"AAsBA,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,GAAG,IAAI,CAcrE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.authConfigError = authConfigError;
|
|
4
|
+
const MIN_JWT_SECRET_BYTES = 32;
|
|
5
|
+
function authConfigError(env) {
|
|
6
|
+
const jwtSecret = env["JWT_SECRET"];
|
|
7
|
+
if (jwtSecret && Buffer.byteLength(jwtSecret) < MIN_JWT_SECRET_BYTES) {
|
|
8
|
+
return `JWT_SECRET must be at least ${MIN_JWT_SECRET_BYTES} bytes`;
|
|
9
|
+
}
|
|
10
|
+
const hasCredential = Boolean(env["CRYPTO_API_KEY"] || jwtSecret);
|
|
11
|
+
if (env["NODE_ENV"] === "production" &&
|
|
12
|
+
!hasCredential &&
|
|
13
|
+
env["ALLOW_ANONYMOUS"] !== "1") {
|
|
14
|
+
return "Production requires CRYPTO_API_KEY or JWT_SECRET (or ALLOW_ANONYMOUS=1 behind an authenticating gateway)";
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=auth-policy.js.map
|