@sebastienrousseau/crypto-server 0.0.35 → 0.0.36

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.
Files changed (104) hide show
  1. package/README.md +128 -73
  2. package/dist/@types/types.d.ts +1 -0
  3. package/dist/@types/types.d.ts.map +1 -1
  4. package/dist/config/auth-policy.d.ts +1 -0
  5. package/dist/config/auth-policy.d.ts.map +1 -1
  6. package/dist/config/auth-policy.js +10 -4
  7. package/dist/config/constants.d.ts +7 -2
  8. package/dist/config/constants.d.ts.map +1 -1
  9. package/dist/config/constants.js +15 -18
  10. package/dist/config/env.d.ts +9 -2
  11. package/dist/config/env.d.ts.map +1 -1
  12. package/dist/config/env.js +59 -36
  13. package/dist/config/settings.d.ts +3 -0
  14. package/dist/config/settings.d.ts.map +1 -0
  15. package/dist/config/settings.js +24 -0
  16. package/dist/enterprise/metering.d.ts +5 -5
  17. package/dist/enterprise/metering.d.ts.map +1 -1
  18. package/dist/enterprise/metering.js +20 -63
  19. package/dist/enterprise/types.d.ts +0 -11
  20. package/dist/enterprise/types.d.ts.map +1 -1
  21. package/dist/index.js +9 -35
  22. package/dist/lib/audit.d.ts +18 -0
  23. package/dist/lib/audit.d.ts.map +1 -0
  24. package/dist/lib/audit.js +57 -0
  25. package/dist/lib/auth.d.ts +4 -0
  26. package/dist/lib/auth.d.ts.map +1 -1
  27. package/dist/lib/auth.js +15 -1
  28. package/dist/lib/crypto-workers.d.ts +27 -0
  29. package/dist/lib/crypto-workers.d.ts.map +1 -0
  30. package/dist/lib/crypto-workers.js +46 -0
  31. package/dist/lib/http-metrics.d.ts +13 -0
  32. package/dist/lib/http-metrics.d.ts.map +1 -0
  33. package/dist/lib/http-metrics.js +45 -0
  34. package/dist/lib/key-store.d.ts +15 -1
  35. package/dist/lib/key-store.d.ts.map +1 -1
  36. package/dist/lib/key-store.js +128 -44
  37. package/dist/lib/kms-owners.d.ts +9 -0
  38. package/dist/lib/kms-owners.d.ts.map +1 -0
  39. package/dist/lib/kms-owners.js +80 -0
  40. package/dist/lib/kms-providers.d.ts +15 -0
  41. package/dist/lib/kms-providers.d.ts.map +1 -0
  42. package/dist/lib/kms-providers.js +99 -0
  43. package/dist/lib/lifecycle.d.ts +16 -0
  44. package/dist/lib/lifecycle.d.ts.map +1 -0
  45. package/dist/lib/lifecycle.js +50 -0
  46. package/dist/lib/logger.d.ts +5 -1
  47. package/dist/lib/logger.d.ts.map +1 -1
  48. package/dist/lib/logger.js +34 -15
  49. package/dist/lib/opaque-store.d.ts +13 -0
  50. package/dist/lib/opaque-store.d.ts.map +1 -1
  51. package/dist/lib/opaque-store.js +27 -2
  52. package/dist/lib/problem.d.ts +8 -0
  53. package/dist/lib/problem.d.ts.map +1 -1
  54. package/dist/lib/problem.js +25 -15
  55. package/dist/lib/readiness.d.ts +12 -0
  56. package/dist/lib/readiness.d.ts.map +1 -0
  57. package/dist/lib/readiness.js +17 -0
  58. package/dist/lib/telemetry.d.ts +1 -1
  59. package/dist/lib/telemetry.d.ts.map +1 -1
  60. package/dist/lib/telemetry.js +45 -73
  61. package/dist/routes/index.d.ts +3 -0
  62. package/dist/routes/index.d.ts.map +1 -1
  63. package/dist/routes/index.js +19 -12
  64. package/dist/routes/probes.d.ts.map +1 -1
  65. package/dist/routes/probes.js +4 -10
  66. package/dist/routes/v1/decrypt.d.ts.map +1 -1
  67. package/dist/routes/v1/decrypt.js +2 -1
  68. package/dist/routes/v1/encrypt.d.ts.map +1 -1
  69. package/dist/routes/v1/encrypt.js +2 -1
  70. package/dist/routes/v1/generate.d.ts.map +1 -1
  71. package/dist/routes/v1/generate.js +3 -2
  72. package/dist/routes/v1/index.js +2 -2
  73. package/dist/routes/v1/revoke.d.ts.map +1 -1
  74. package/dist/routes/v1/revoke.js +3 -2
  75. package/dist/routes/v1/verify.d.ts.map +1 -1
  76. package/dist/routes/v1/verify.js +27 -12
  77. package/dist/routes/v2/compliance.js +1 -1
  78. package/dist/routes/v2/hpke.d.ts.map +1 -1
  79. package/dist/routes/v2/hpke.js +8 -4
  80. package/dist/routes/v2/keys.d.ts.map +1 -1
  81. package/dist/routes/v2/keys.js +24 -2
  82. package/dist/routes/v2/kms.d.ts +8 -4
  83. package/dist/routes/v2/kms.d.ts.map +1 -1
  84. package/dist/routes/v2/kms.js +81 -82
  85. package/dist/routes/v2/opaque.d.ts.map +1 -1
  86. package/dist/routes/v2/opaque.js +26 -4
  87. package/dist/routes/v2/pq-hash-sign.d.ts.map +1 -1
  88. package/dist/routes/v2/pq-hash-sign.js +2 -4
  89. package/dist/routes/v2/pq-sign.d.ts.map +1 -1
  90. package/dist/routes/v2/pq-sign.js +2 -4
  91. package/dist/routes/v2/pq.d.ts.map +1 -1
  92. package/dist/routes/v2/pq.js +10 -9
  93. package/dist/server.d.ts +1 -1
  94. package/dist/server.d.ts.map +1 -1
  95. package/dist/server.js +40 -15
  96. package/dist/utils/keys.d.ts +1 -0
  97. package/dist/utils/keys.d.ts.map +1 -1
  98. package/dist/utils/keys.js +9 -2
  99. package/dist/utils/route-helpers.d.ts.map +1 -1
  100. package/dist/utils/route-helpers.js +5 -10
  101. package/package.json +6 -8
  102. package/dist/lib/kdf-runner.d.ts +0 -18
  103. package/dist/lib/kdf-runner.d.ts.map +0 -1
  104. package/dist/lib/kdf-runner.js +0 -27
package/README.md CHANGED
@@ -108,12 +108,12 @@ Crypto Service provides a complete cryptography stack across 14 specialized pack
108
108
 
109
109
  | Package | Role | Description |
110
110
  | :---------------------------------------------------------------------------------------------------------------------------------------------- | :-------------- | :----------------------------------------------------------------------------------------------------------------------------- |
111
- | [`@sebastienrousseau/crypto-api`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-api) | API Schemas | Shared TypeScript types and utilities for the Crypto Service Suite, defining the canonical API surface. |
111
+ | [`@sebastienrousseau/crypto-api`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-api) | API docs | Postman collection types and a Postman-to-Markdown converter; the server's API contract is its OpenAPI document. |
112
112
  | [`@sebastienrousseau/crypto-benchmarks`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-benchmarks) | Benchmarks | Benchmarks comparing classical and post-quantum cryptography: ops/sec, latency and throughput. |
113
113
  | [`@sebastienrousseau/crypto-cbom`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-cbom) | CBOM | Cryptographic Bill of Materials generator and auditor (CycloneDX 1.6, SPDX 3.0). |
114
114
  | [`@sebastienrousseau/crypto-cli`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-cli) | Terminal CLI | Command-line interface: hashing, key generation, encryption, signing, HPKE, Argon2id and CBOM scans, with an interactive menu. |
115
115
  | [`@sebastienrousseau/crypto-edge`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-edge) | Edge Runtime | Edge-runtime cryptographic operations using the Web Crypto API, optimized for Cloudflare Workers, Vercel Edge, and Deno. |
116
- | [`@sebastienrousseau/crypto-kms`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-kms) | Cloud KMS | Unified KMS interface: AWS KMS and local providers implemented; GCP, Azure and Vault are stubs. |
116
+ | [`@sebastienrousseau/crypto-kms`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-kms) | Cloud KMS | Unified KMS interface: AWS KMS, Google Cloud KMS, Vault Transit and local providers; Azure is a stub. |
117
117
  | [`@sebastienrousseau/crypto-lib`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-lib) | Core Library | Core library: post-quantum ML-KEM, ML-DSA and SLH-DSA, plus classical, modern and OpenPGP cryptography for TypeScript. |
118
118
  | [`@sebastienrousseau/crypto-lsp`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-lsp) | IDE Analysis | Language server that flags weak and quantum-vulnerable cryptography in the editor, with quick fixes. |
119
119
  | [`@sebastienrousseau/crypto-mcp`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-mcp) | AI Agents | Model Context Protocol server exposing cryptography tools to AI assistants and agents. |
@@ -163,47 +163,48 @@ All v2 endpoints accept and return `application/json`. Authenticated
163
163
  requests must include an `x-api-key` header (or
164
164
  `Authorization: Bearer <jwt>`).
165
165
 
166
- | Method | Path | Description |
167
- | :----- | :---------------------------- | :------------------------------------------------------------------- |
168
- | `POST` | `/v2/hash` | Compute a cryptographic hash (SHA-2, SHA-3, BLAKE2b, BLAKE3) |
169
- | `POST` | `/v2/encrypt` | AEAD encryption with XChaCha20-Poly1305 |
170
- | `POST` | `/v2/decrypt` | AEAD decryption with XChaCha20-Poly1305 |
171
- | `POST` | `/v2/sign` | Sign with a server-held Ed25519 key (`keyId`) |
172
- | `POST` | `/v2/verify` | Verify a digital signature |
173
- | `POST` | `/v2/kdf` | Derive a key (scrypt N=2^17 r=8, HKDF-SHA256, PBKDF2-SHA256 >= 600k) |
174
- | `POST` | `/v2/hmac` | Compute an HMAC |
175
- | `POST` | `/v2/hmac/verify` | Verify an HMAC in constant time |
176
- | `POST` | `/v2/password/hash` | Hash a password with Argon2id (m >= 19 MiB, t >= 2) |
177
- | `POST` | `/v2/password/verify` | Verify a password against an Argon2id hash |
178
- | `POST` | `/v2/password/encrypt` | Encrypt with password (Argon2id + XChaCha20-Poly1305) |
179
- | `POST` | `/v2/password/decrypt` | Decrypt with password |
180
- | `POST` | `/v2/keys/generate` | Generate a server-held key pair; returns `keyId` + public key |
181
- | `POST` | `/v2/keys/export` | Export a private key (`crypto:keys:export` scope only) |
182
- | `POST` | `/v2/keys/wrap` | Wrap a key with AES-KW or AES-KWP |
183
- | `POST` | `/v2/keys/unwrap` | Unwrap a key |
184
- | `POST` | `/v2/secretbox/seal` | Encrypt with XChaCha20-Poly1305 (secretbox) |
185
- | `POST` | `/v2/secretbox/open` | Decrypt a secretbox ciphertext |
186
- | `POST` | `/v2/sealedbox/seal` | Anonymous public-key encryption (X25519) |
187
- | `POST` | `/v2/sealedbox/open` | Decrypt a sealed box with a server-held X25519 key (`keyId`) |
188
- | `POST` | `/v2/sealedbox/seal-pq` | Post-quantum sealed box (X25519 + ML-KEM-768) |
189
- | `POST` | `/v2/sealedbox/open-pq` | Decrypt a PQ sealed box with a server-held hybrid key |
190
- | `POST` | `/v2/multi-recipient/encrypt` | Encrypt for multiple recipients |
191
- | `POST` | `/v2/pq/keygen` | Generate an ML-KEM-768 key pair (FIPS 203) |
192
- | `POST` | `/v2/pq/encapsulate` | Encapsulate a shared secret with ML-KEM-768 |
193
- | `POST` | `/v2/pq/decapsulate` | Decapsulate with a server-held ML-KEM-768 key (`keyId`) |
194
- | `POST` | `/v2/pq/hybrid/keygen` | Generate a hybrid X25519 + ML-KEM-768 key pair |
195
- | `POST` | `/v2/pq/hybrid/encapsulate` | Hybrid encapsulation |
196
- | `POST` | `/v2/pq/hybrid/decapsulate` | Hybrid decapsulation with a server-held key (`keyId`) |
197
- | `POST` | `/v2/pq/dsa/keygen` | Generate an ML-DSA key pair (FIPS 204) |
198
- | `POST` | `/v2/pq/dsa/sign` | Sign with a server-held ML-DSA key (`keyId`) |
199
- | `POST` | `/v2/pq/dsa/verify` | Verify an ML-DSA signature |
200
- | `POST` | `/v2/pq/slh-dsa/keygen` | Generate an SLH-DSA key pair (FIPS 205) |
201
- | `POST` | `/v2/pq/slh-dsa/sign` | Sign with a server-held SLH-DSA key (`keyId`) |
202
- | `POST` | `/v2/pq/slh-dsa/verify` | Verify an SLH-DSA signature |
203
- | `GET` | `/v2/algorithms` | List all supported algorithms |
204
- | `GET` | `/live` | Liveness probe (Kubernetes) |
205
- | `GET` | `/ready` | Readiness probe (Kubernetes) |
206
- | `GET` | `/metrics` | Prometheus-compatible metrics |
166
+ | Method | Path | Description |
167
+ | :----- | :---------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------- |
168
+ | `POST` | `/v2/hash` | Compute a cryptographic hash (SHA-2, SHA-3, BLAKE2b, BLAKE3) |
169
+ | `POST` | `/v2/encrypt` | AEAD encryption with XChaCha20-Poly1305 |
170
+ | `POST` | `/v2/decrypt` | AEAD decryption with XChaCha20-Poly1305 |
171
+ | `POST` | `/v2/sign` | Sign with a server-held Ed25519 key (`keyId`) |
172
+ | `POST` | `/v2/verify` | Verify a digital signature |
173
+ | `POST` | `/v2/kdf` | Derive a key (scrypt N=2^17 r=8, HKDF-SHA256, PBKDF2-SHA256 >= 600k) |
174
+ | `POST` | `/v2/hmac` | Compute an HMAC |
175
+ | `POST` | `/v2/hmac/verify` | Verify an HMAC in constant time |
176
+ | `POST` | `/v2/password/hash` | Hash a password with Argon2id (m >= 19 MiB, t >= 2) |
177
+ | `POST` | `/v2/password/verify` | Verify a password against an Argon2id hash |
178
+ | `POST` | `/v2/password/encrypt` | Encrypt with password (Argon2id + XChaCha20-Poly1305) |
179
+ | `POST` | `/v2/password/decrypt` | Decrypt with password |
180
+ | `POST` | `/v2/keys/generate` | Generate a server-held key pair; returns `keyId` + public key |
181
+ | `POST` | `/v2/keys/export` | Export a private key (`crypto:keys:export` scope only) |
182
+ | `POST` | `/v2/keys/delete` | Delete one of the caller's keys, freeing quota |
183
+ | `POST` | `/v2/keys/wrap` | Wrap a key with AES-KW or AES-KWP |
184
+ | `POST` | `/v2/keys/unwrap` | Unwrap a key |
185
+ | `POST` | `/v2/secretbox/seal` | Encrypt with XChaCha20-Poly1305 (secretbox) |
186
+ | `POST` | `/v2/secretbox/open` | Decrypt a secretbox ciphertext |
187
+ | `POST` | `/v2/sealedbox/seal` | Anonymous public-key encryption (X25519) |
188
+ | `POST` | `/v2/sealedbox/open` | Decrypt a sealed box with a server-held X25519 key (`keyId`) |
189
+ | `POST` | `/v2/sealedbox/seal-pq` | Post-quantum sealed box (X25519 + ML-KEM-768) |
190
+ | `POST` | `/v2/sealedbox/open-pq` | Decrypt a PQ sealed box with a server-held hybrid key |
191
+ | `POST` | `/v2/multi-recipient/encrypt` | Encrypt for multiple recipients |
192
+ | `POST` | `/v2/pq/keygen` | Generate an ML-KEM-768 key pair (FIPS 203) |
193
+ | `POST` | `/v2/pq/encapsulate` | Encapsulate a shared secret with ML-KEM-768 |
194
+ | `POST` | `/v2/pq/decapsulate` | Decapsulate with a server-held ML-KEM-768 key (`keyId`) |
195
+ | `POST` | `/v2/pq/hybrid/keygen` | Generate a hybrid X25519 + ML-KEM-768 key pair |
196
+ | `POST` | `/v2/pq/hybrid/encapsulate` | Hybrid encapsulation |
197
+ | `POST` | `/v2/pq/hybrid/decapsulate` | Hybrid decapsulation with a server-held key (`keyId`) |
198
+ | `POST` | `/v2/pq/dsa/keygen` | Generate an ML-DSA key pair (FIPS 204) |
199
+ | `POST` | `/v2/pq/dsa/sign` | Sign with a server-held ML-DSA key (`keyId`) |
200
+ | `POST` | `/v2/pq/dsa/verify` | Verify an ML-DSA signature |
201
+ | `POST` | `/v2/pq/slh-dsa/keygen` | Generate an SLH-DSA key pair (FIPS 205) |
202
+ | `POST` | `/v2/pq/slh-dsa/sign` | Sign with a server-held SLH-DSA key (`keyId`) |
203
+ | `POST` | `/v2/pq/slh-dsa/verify` | Verify an SLH-DSA signature |
204
+ | `GET` | `/v2/algorithms` | List all supported algorithms |
205
+ | `GET` | `/live` | Liveness probe (Kubernetes) |
206
+ | `GET` | `/ready` | Readiness probe: `503` while the server drains for shutdown or cannot write to `CRYPTO_KEY_OUT_DIR` |
207
+ | `GET` | `/metrics` | Prometheus metrics: process memory and uptime, and `http_requests_total` and `http_request_duration_seconds` by method, route and status |
207
208
 
208
209
  <p align="right"><a href="#contents">Back to Top</a></p>
209
210
 
@@ -255,10 +256,14 @@ decapsulation routes take that `keyId`. A key belongs to the principal
255
256
  (token `sub`) that generated it; for anyone else it does not exist
256
257
  (`404`).
257
258
 
258
- Keys live in memory (at most 10,000 without persistence). Set
259
- `CRYPTO_KEY_OUT_DIR` to also write each key to `<keyId>.json` there
260
- (mode `0600`, never overwritten) so keys survive a restart; those files
261
- hold the private key unencrypted, so protect the directory.
259
+ Keys live in memory (at most 10,000 without persistence, and 1,000 per
260
+ principal by default). Set `CRYPTO_KEY_OUT_DIR` to also write each key
261
+ to `<keyId>.json` there (mode `0600`, never overwritten) so keys survive
262
+ a restart. With `CRYPTO_KEY_STORAGE_KEY` the private parts are encrypted
263
+ and the whole record authenticated; without it they are written in
264
+ plaintext, which a production server refuses unless
265
+ `CRYPTO_KEY_ALLOW_PLAINTEXT=1`. `POST /v2/keys/delete` removes one of
266
+ the caller's keys.
262
267
 
263
268
  `POST /v2/keys/export` returns a key's private parts. It needs the
264
269
  `crypto:keys:export` scope, granted explicitly in a JWT: `crypto:admin`
@@ -294,7 +299,9 @@ curl -H "x-api-key: your-secret-api-key" ...
294
299
  curl -H "Authorization: Bearer eyJhbGciOi..." ...
295
300
  ```
296
301
 
297
- A JWT must be HS256 and carry `exp` and `iat`; it is refused once it
302
+ A JWT must be HS256 and carry `sub`, `exp` and `iat`. Its `sub` must be
303
+ a non-empty string other than `api-key` and `anonymous` (the built-in
304
+ principals), because server-held keys belong to the subject. It is refused once it
298
305
  is older than `JWT_MAX_AGE` seconds (default 3600) or if it declares a
299
306
  longer lifetime (`exp - iat`). When `JWT_ISSUER` / `JWT_AUDIENCE` are
300
307
  set, its `iss` must equal the issuer and its `aud` must contain the
@@ -311,6 +318,22 @@ JWT principals carry their scopes in a `scopes` array claim; API-key
311
318
  and anonymous principals hold `crypto:admin`, which satisfies every
312
319
  scope except `crypto:keys:export`.
313
320
 
321
+ Anonymous access (`ALLOW_ANONYMOUS=1`) is single-tenant: every caller is
322
+ the same principal, holds `crypto:admin`, and can use every key the
323
+ server holds. Use it only for local development.
324
+
325
+ ### KMS keys
326
+
327
+ The `/v2/kms/*` routes use only the providers in `KMS_PROVIDERS`
328
+ (default `local`); a request for any other provider is refused with
329
+ `400` before a provider is contacted. A key created with
330
+ `/v2/kms/create-key` belongs to the principal that created it: other
331
+ principals get `404` for it, as for a key that does not exist. A key
332
+ the API did not create (for example one made in the cloud console) has
333
+ no owner and can be used by `crypto:admin` only. With
334
+ `CRYPTO_KEY_OUT_DIR` set, owners are kept in `kms-owners.json` there
335
+ (mode `0600`), so they survive a restart.
336
+
314
337
  | Scope | Routes |
315
338
  | :------------------- | :------------------------------------------------------------------------------------------------------------------- |
316
339
  | `crypto:encrypt` | `/v1/encrypt`, `/v2/encrypt`, secretbox/sealedbox seal, password and multi-recipient encrypt, PQ encapsulate |
@@ -328,33 +351,65 @@ authentication but no scope.
328
351
 
329
352
  <p align="right"><a href="#contents">Back to Top</a></p>
330
353
 
354
+ ### Audit log
355
+
356
+ Every request that creates, exports, deletes or uses a server-held key,
357
+ calls a KMS route, or registers an OPAQUE credential writes one log line
358
+ with `msg: "audit"` after the response, refused requests included:
359
+
360
+ ```json
361
+ {
362
+ "reqId": "…",
363
+ "msg": "audit",
364
+ "audit": {
365
+ "action": "POST /v2/keys/export",
366
+ "principal": "alice",
367
+ "status": 404,
368
+ "outcome": "failure",
369
+ "keyId": "k_…"
370
+ }
371
+ }
372
+ ```
373
+
374
+ It names the key or KMS provider, never key material. Audit lines are
375
+ written at `info`, so a `LOG_LEVEL` above `info` drops them.
376
+
377
+ <p align="right"><a href="#contents">Back to Top</a></p>
378
+
331
379
  ## Configuration
332
380
 
333
- | Variable | Default | Description |
334
- | :----------------------------------------------------------------------- | :----------------------------------- | :------------------------------------------------------------------------------------------------------------ |
335
- | `PORT` | `3000` | TCP port to listen on |
336
- | `HOST` | `localhost` | Bind address |
337
- | `PROTOCOL` | `http` | `http` or `https` |
338
- | `NODE_ENV` | `development` | `development`, `production`, or `test` |
339
- | `LOG_LEVEL` | `info` | `error`, `warn`, `info`, or `debug` |
340
- | `CRYPTO_API_KEY` | -- | Static API key for `x-api-key` authentication |
341
- | `JWT_SECRET` | -- | HMAC secret for HS256 JWT validation |
342
- | `JWT_MAX_AGE` | `3600` | Maximum JWT lifetime in seconds |
343
- | `JWT_ISSUER` | -- | Required JWT `iss` (required in production) |
344
- | `JWT_AUDIENCE` | -- | Required JWT `aud` (required in production) |
345
- | `CORS_ORIGIN` | -- | Comma-separated allowed origins (empty = disabled) |
346
- | `TRUSTED_PROXY_CIDRS` | -- | Comma-separated trusted proxy CIDRs |
347
- | `CRYPTO_KEY_DIR` | -- | Directory for key storage |
348
- | `CRYPTO_KEY_OUT_DIR` | -- | Where generated keys are persisted (see Key custody) |
349
- | `SHUTDOWN_TIMEOUT_MS` | `30000` | Graceful shutdown timeout in milliseconds |
350
- | `ALLOW_ANONYMOUS` | -- | `1` allows unauthenticated requests |
351
- | `RATE_LIMIT_MAX` | `10` | Requests per client per minute (probes are exempt) |
352
- | `CRYPTO_KEY_STORAGE_KEY` | -- | Encrypts persisted private keys at rest (AES-256-GCM): 64 hex characters, or a passphrase hashed with SHA-256 |
353
- | `OTEL_EXPORTER_OTLP_ENDPOINT` | -- | OpenTelemetry OTLP collector endpoint (export disabled when unset) |
354
- | `AWS_REGION` | `us-east-1` | Region for the AWS KMS provider |
355
- | `GCP_PROJECT_ID`, `GCP_LOCATION_ID`, `GCP_KEY_RING_ID`, `GCP_AUTH_TOKEN` | placeholders | GCP KMS provider settings (the provider is a stub) |
356
- | `VAULT_ADDR`, `VAULT_TOKEN` | `http://localhost:8200`, placeholder | Vault KMS provider settings (the provider is a stub) |
357
- | `AZURE_VAULT_URL` | placeholder | Azure Key Vault provider setting (the provider is a stub) |
381
+ The server checks every setting at startup and refuses to start, listing each problem, when one is invalid. Numeric settings take digits only: `PORT=3000abc` or `RATE_LIMIT_MAX=0` is an error, not a fallback to the default.
382
+
383
+ | Variable | Default | Description |
384
+ | :----------------------------------------------------------------------- | :------------ | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
385
+ | `PORT` | `3000` | TCP port to listen on |
386
+ | `HOST` | `localhost` | Bind address |
387
+ | `PROTOCOL` | `http` | `http` or `https` |
388
+ | `NODE_ENV` | `development` | `development`, `production`, or `test` |
389
+ | `LOG_LEVEL` | `info` | `error`, `warn`, `info`, or `debug`, for every log line (one JSON logger, pino). Credentials and key fields are redacted; request lines carry `reqId`, taken from a well-formed `x-request-id` header (at most 128 of `A-Za-z0-9._-`) or generated, and echoed in the response |
390
+ | `CRYPTO_API_KEY` | -- | Static API key for `x-api-key` authentication |
391
+ | `JWT_SECRET` | -- | HMAC secret for HS256 JWT validation |
392
+ | `JWT_MAX_AGE` | `3600` | Maximum JWT lifetime in seconds |
393
+ | `JWT_ISSUER` | -- | Required JWT `iss` (required in production) |
394
+ | `JWT_AUDIENCE` | -- | Required JWT `aud` (required in production) |
395
+ | `CORS_ORIGIN` | -- | Comma-separated allowed origins (empty = disabled) |
396
+ | `TRUSTED_PROXY_CIDRS` | -- | Comma-separated trusted proxy CIDRs |
397
+ | `CRYPTO_KEY_DIR` | -- | Directory for key storage |
398
+ | `CRYPTO_KEY_OUT_DIR` | -- | Where generated keys are persisted (see Key custody) |
399
+ | `SHUTDOWN_TIMEOUT_MS` | `30000` | Graceful shutdown timeout in milliseconds |
400
+ | `ALLOW_ANONYMOUS` | -- | `1` allows unauthenticated requests |
401
+ | `RATE_LIMIT_MAX` | `10` | Requests per client per minute (probes are exempt) |
402
+ | `CRYPTO_KEY_STORAGE_KEY` | -- | Encrypts the private parts of persisted keys (AES-256-GCM, authenticated with the whole record): exactly 64 hex characters; a passphrase is refused. Required in production when `CRYPTO_KEY_OUT_DIR` is set |
403
+ | `CRYPTO_KEY_ALLOW_PLAINTEXT` | -- | `1` accepts plaintext key files: writing them in production, or reading old ones after `CRYPTO_KEY_STORAGE_KEY` was set |
404
+ | `KEY_STORE_MAX_PER_PRINCIPAL` | `1000` | Keys one principal may hold; more answer `429` until it deletes some |
405
+ | `OTEL_EXPORTER_OTLP_ENDPOINT` | -- | OpenTelemetry OTLP collector endpoint; without it (or with `OTEL_SDK_DISABLED=true`) OpenTelemetry does not start, in any environment |
406
+ | `OTEL_SDK_DISABLED` | -- | `true` keeps OpenTelemetry off even with an endpoint set |
407
+ | `DOCS_ENABLED` | `1` | `0` removes the API documentation (`/docs` and the OpenAPI document at `/docs/json`) |
408
+ | `V1_ENABLED` | `1` | `0` removes the deprecated v1 routes before their sunset (1 January 2027); see [MIGRATION.md](../../MIGRATION.md) |
409
+ | `KMS_PROVIDERS` | `local` | Comma-separated KMS providers requests may use: `local`, `aws`, `gcp`, `vault`. Any other provider is refused with `400`; an enabled provider with a missing setting, an unknown name or `azure` (a stub) stops the server from starting |
410
+ | `AWS_REGION` | -- | Required when `aws` is enabled; credentials come from the AWS default credential chain |
411
+ | `GCP_PROJECT_ID`, `GCP_LOCATION_ID`, `GCP_KEY_RING_ID`, `GCP_AUTH_TOKEN` | -- | Required when `gcp` is enabled; the OAuth2 access token is not refreshed by the server |
412
+ | `VAULT_ADDR`, `VAULT_TOKEN` | -- | Required when `vault` is enabled (Transit engine mounted at `transit`) |
358
413
 
359
414
  <p align="right"><a href="#contents">Back to Top</a></p>
360
415
 
@@ -36,5 +36,6 @@ export interface IBodyVerify {
36
36
  date: string;
37
37
  message: string;
38
38
  verificationKeys: string;
39
+ signature?: string;
39
40
  }
40
41
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
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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,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,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAiBD,MAAM,WAAW,YAAY;IAE3B,UAAU,EAAE,MAAM,CAAC;IAEnB,OAAO,EAAE,MAAM,CAAC;IAEhB,SAAS,EAAE,MAAM,CAAC;CACnB;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;IAEzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
@@ -8,6 +8,7 @@ export declare function jwtConfigError(env: NodeJS.ProcessEnv): string | null;
8
8
  export declare function jwtPolicy(env: NodeJS.ProcessEnv): JwtPolicy;
9
9
  export declare function authConfigError(env: NodeJS.ProcessEnv): string | null;
10
10
  export declare const AUTHENTICATED = "authenticated";
11
+ export declare const PUBLIC = "public";
11
12
  export declare const ROUTE_SCOPES: Readonly<Record<string, string>>;
12
13
  export declare function isPublicRoute(url: string): boolean;
13
14
  export declare function routeRequirement(method: string, url: string): string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"auth-policy.d.ts","sourceRoot":"","sources":["../../src/config/auth-policy.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,2BAA2B,OAAO,CAAC;AAGhD,MAAM,WAAW,SAAS;IAMxB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAE/B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAEpC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC;AAQD,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,GAAG,IAAI,CAUpE;AAMD,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,SAAS,CAO3D;AAUD,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,GAAG,IAAI,CAgBrE;AAOD,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAY7C,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAiFxD,CAAC;AAOH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAIlD;AAMD,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,GACV,MAAM,GAAG,SAAS,CAGpB;AAGD,MAAM,WAAW,eAAe;IAE9B,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAE1B,GAAG,EAAE,MAAM,CAAC;CACb;AAMD,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,GAAG,MAAM,EAAE,CAY3E;AAOD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,GAAG,IAAI,CAO5E"}
1
+ {"version":3,"file":"auth-policy.d.ts","sourceRoot":"","sources":["../../src/config/auth-policy.ts"],"names":[],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DS = void 0;
3
+ exports.ROUTE_SCOPES = exports.PUBLIC = exports.AUTHENTICATED = exports.DEFAULT_JWT_MAX_AGE_SECONDS = void 0;
4
4
  exports.jwtConfigError = jwtConfigError;
5
5
  exports.jwtPolicy = jwtPolicy;
6
6
  exports.authConfigError = authConfigError;
@@ -47,6 +47,7 @@ function authConfigError(env) {
47
47
  return null;
48
48
  }
49
49
  exports.AUTHENTICATED = "authenticated";
50
+ exports.PUBLIC = "public";
50
51
  exports.ROUTE_SCOPES = Object.freeze({
51
52
  "GET /": exports.AUTHENTICATED,
52
53
  "GET /v2/algorithms": exports.AUTHENTICATED,
@@ -93,6 +94,7 @@ exports.ROUTE_SCOPES = Object.freeze({
93
94
  "POST /v2/password/hash": "crypto:kdf",
94
95
  "POST /v2/password/verify": "crypto:kdf",
95
96
  "POST /v2/keys/generate": "crypto:keys",
97
+ "POST /v2/keys/delete": "crypto:keys",
96
98
  "POST /v2/keys/export": "crypto:keys:export",
97
99
  "POST /v2/keys/wrap": "crypto:keys",
98
100
  "POST /v2/keys/unwrap": "crypto:keys",
@@ -102,8 +104,8 @@ exports.ROUTE_SCOPES = Object.freeze({
102
104
  "POST /v2/pq/slh-dsa/keygen": "crypto:keys",
103
105
  "POST /v2/opaque/register/init": exports.AUTHENTICATED,
104
106
  "POST /v2/opaque/register/finish": exports.AUTHENTICATED,
105
- "POST /v2/opaque/login/init": exports.AUTHENTICATED,
106
- "POST /v2/opaque/login/finish": exports.AUTHENTICATED,
107
+ "POST /v2/opaque/login/init": exports.PUBLIC,
108
+ "POST /v2/opaque/login/finish": exports.PUBLIC,
107
109
  "POST /v2/hpke/keygen": "crypto:keys",
108
110
  "POST /v2/hpke/seal": "crypto:encrypt",
109
111
  "POST /v2/hpke/open": "crypto:decrypt",
@@ -114,8 +116,12 @@ exports.ROUTE_SCOPES = Object.freeze({
114
116
  "POST /v2/kms/encrypt": "crypto:encrypt",
115
117
  "POST /v2/kms/decrypt": "crypto:decrypt",
116
118
  });
119
+ const PUBLIC_PATHS = new Set(Object.entries(exports.ROUTE_SCOPES)
120
+ .filter(([, requirement]) => requirement === exports.PUBLIC)
121
+ .map(([route]) => route.slice(route.indexOf(" ") + 1)));
117
122
  function isPublicRoute(url) {
118
- return ((0, constants_1.isProbePath)(url) || url.startsWith("/docs") || url.startsWith("/v2/opaque"));
123
+ const path = url.split("?")[0];
124
+ return ((0, constants_1.isProbePath)(path) || path.startsWith("/docs") || PUBLIC_PATHS.has(path));
119
125
  }
120
126
  function routeRequirement(method, url) {
121
127
  const verb = method === "HEAD" ? "GET" : method;
@@ -6,7 +6,12 @@ export declare const LIB_VERSION: string;
6
6
  export declare const HOST: string;
7
7
  export declare const PORT: string | number;
8
8
  export declare const PROTOCOL: string;
9
- export declare const consoleOutput: string[];
9
+ export declare const serverDetails: Readonly<{
10
+ protocol: string;
11
+ host: string;
12
+ port: string | 3000;
13
+ version: string;
14
+ }>;
10
15
  export declare const fastifyOptions: FastifyServerOptions;
11
16
  export declare const compressOptions: FastifyCompressOptions;
12
17
  export declare const helmetOptions: FastifyHelmetOptions;
@@ -46,7 +51,7 @@ export declare const rateLimitOptions: {
46
51
  expiresIn: number;
47
52
  };
48
53
  };
49
- export declare const resolveRateLimitMax: () => number;
54
+ export declare const resolveRateLimitMax: (env?: NodeJS.ProcessEnv) => number;
50
55
  export declare const healthCheckOptions: {
51
56
  healthcheckUrl: string;
52
57
  exposeUptime: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/config/constants.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAQ5D,eAAO,MAAM,WAAW,QAA+B,CAAC;AAMxD,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AAM,WAAW,QAA+B,CAAC;AAMxD,eAAO,MAAM,IAAI,QAAqC,CAAC;AAMvD,eAAO,MAAM,IAAI,iBAA8B,CAAC;AAMhD,eAAO,MAAM,QAAQ,QAAoC,CAAC;AAqB1D,eAAO,MAAM,aAAa;;;;;EAKxB,CAAC;AAMH,eAAO,MAAM,cAAc,EAAE,oBAiB5B,CAAC;AAOF,eAAO,MAAM,eAAe,EAAE,sBAM7B,CAAC;AAOF,eAAO,MAAM,aAAa,EAAE,oBAG3B,CAAC;AAOF,eAAO,MAAM,WAAW,EAAE,kBAazB,CAAC;AAOF,eAAO,MAAM,WAAW,EAAE,WAAW,CAAC,MAAM,CAK1C,CAAC;AAKH,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,KAAG,OACN,CAAC;AAMrC,eAAO,MAAM,gBAAgB;;;;qBAgBV;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,KAAG,OAAO;;;;;;;;8BAiBnC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE;YAAE,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;SAAE,CAAA;KAAE,WAChD;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE;;;;;;;;CAoB3E,CAAC;AASF,eAAO,MAAM,mBAAmB,GAC9B,MAAK,MAAM,CAAC,UAAwB,KACnC,MAAwE,CAAC;AAM5E,eAAO,MAAM,kBAAkB;;;CAK9B,CAAC"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.healthCheckOptions = exports.resolveRateLimitMax = exports.rateLimitOptions = exports.isProbePath = exports.PROBE_PATHS = exports.corsOptions = exports.helmetOptions = exports.compressOptions = exports.fastifyOptions = exports.consoleOutput = exports.PROTOCOL = exports.PORT = exports.HOST = exports.LIB_VERSION = void 0;
3
+ exports.healthCheckOptions = exports.resolveRateLimitMax = exports.rateLimitOptions = exports.isProbePath = exports.PROBE_PATHS = exports.corsOptions = exports.helmetOptions = exports.compressOptions = exports.fastifyOptions = exports.serverDetails = exports.PROTOCOL = exports.PORT = exports.HOST = exports.LIB_VERSION = void 0;
4
+ const settings_1 = require("./settings");
4
5
  const pack = require("../../package.json");
5
6
  exports.LIB_VERSION = JSON.stringify(pack.version);
6
7
  exports.HOST = process.env["HOST"] ?? "localhost";
@@ -15,24 +16,25 @@ const parseTrustProxy = () => {
15
16
  .map((entry) => entry.trim())
16
17
  .filter((entry) => entry.length > 0);
17
18
  };
18
- exports.consoleOutput = [
19
- `\n → protocol: ${exports.PROTOCOL}`,
20
- `\n → hostname: ${exports.HOST}`,
21
- `\n → port: ${exports.PORT}`,
22
- `\n → version: ${exports.LIB_VERSION}`,
23
- "\n",
24
- ];
19
+ exports.serverDetails = Object.freeze({
20
+ protocol: exports.PROTOCOL,
21
+ host: exports.HOST,
22
+ port: exports.PORT,
23
+ version: pack.version,
24
+ });
25
25
  exports.fastifyOptions = {
26
26
  bodyLimit: 256 * 1024,
27
- caseSensitive: true,
28
27
  connectionTimeout: 30_000,
29
- ignoreTrailingSlash: false,
30
28
  keepAliveTimeout: 5000,
31
- logger: true,
32
- maxParamLength: 100,
29
+ requestIdHeader: false,
33
30
  onConstructorPoisoning: "error",
34
31
  onProtoPoisoning: "error",
35
32
  return503OnClosing: true,
33
+ routerOptions: {
34
+ caseSensitive: true,
35
+ ignoreTrailingSlash: false,
36
+ maxParamLength: 100,
37
+ },
36
38
  trustProxy: parseTrustProxy(),
37
39
  };
38
40
  exports.compressOptions = {
@@ -92,12 +94,7 @@ exports.rateLimitOptions = {
92
94
  };
93
95
  },
94
96
  };
95
- const resolveRateLimitMax = () => {
96
- const parsed = Number(process.env["RATE_LIMIT_MAX"]);
97
- return Number.isSafeInteger(parsed) && parsed > 0
98
- ? parsed
99
- : exports.rateLimitOptions.max;
100
- };
97
+ const resolveRateLimitMax = (env = process.env) => (0, settings_1.integerSetting)(env, "RATE_LIMIT_MAX", exports.rateLimitOptions.max, 1);
101
98
  exports.resolveRateLimitMax = resolveRateLimitMax;
102
99
  exports.healthCheckOptions = {
103
100
  healthcheckUrl: "/health",
@@ -1,3 +1,6 @@
1
+ export declare class ConfigError extends Error {
2
+ name: string;
3
+ }
1
4
  export interface Config {
2
5
  readonly host: string;
3
6
  readonly port: number;
@@ -10,7 +13,11 @@ export interface Config {
10
13
  readonly keyDir: string | undefined;
11
14
  readonly keyOutDir: string | undefined;
12
15
  readonly shutdownTimeoutMs: number;
16
+ readonly rateLimitMax: number;
17
+ readonly docsEnabled: boolean;
18
+ readonly v1Enabled: boolean;
13
19
  }
14
- export declare function loadConfig(): Config;
15
- export declare const config: Config;
20
+ export declare function docsEnabled(env?: NodeJS.ProcessEnv): boolean;
21
+ export declare function v1Enabled(env?: NodeJS.ProcessEnv): boolean;
22
+ export declare function loadConfig(env?: NodeJS.ProcessEnv): Config;
16
23
  //# sourceMappingURL=env.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/config/env.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,MAAM;IAErB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IAEpC,QAAQ,CAAC,OAAO,EAAE,aAAa,GAAG,YAAY,GAAG,MAAM,CAAC;IAExD,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IAEvD,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAEpC,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IAEvC,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,G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