@sebastienrousseau/crypto-server 0.0.1 → 0.0.8

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 (136) hide show
  1. package/README.md +292 -123
  2. package/dist/@types/types.d.ts +34 -14
  3. package/dist/@types/types.d.ts.map +1 -1
  4. package/dist/@types/types.js +15 -0
  5. package/dist/config/auth-policy.d.ts +2 -0
  6. package/dist/config/auth-policy.d.ts.map +1 -0
  7. package/dist/config/auth-policy.js +18 -0
  8. package/dist/config/constants.d.ts +54 -0
  9. package/dist/config/constants.d.ts.map +1 -0
  10. package/dist/config/constants.js +101 -0
  11. package/dist/config/env.d.ts +16 -0
  12. package/dist/config/env.d.ts.map +1 -0
  13. package/dist/config/env.js +74 -0
  14. package/dist/enterprise/metering.d.ts +19 -0
  15. package/dist/enterprise/metering.d.ts.map +1 -0
  16. package/dist/enterprise/metering.js +159 -0
  17. package/dist/enterprise/types.d.ts +78 -0
  18. package/dist/enterprise/types.d.ts.map +1 -0
  19. package/dist/enterprise/types.js +3 -0
  20. package/dist/index.js +38 -74
  21. package/dist/lib/auth.d.ts +14 -0
  22. package/dist/lib/auth.d.ts.map +1 -0
  23. package/dist/lib/auth.js +120 -0
  24. package/dist/lib/logger.d.ts.map +1 -1
  25. package/dist/lib/logger.js +6 -5
  26. package/dist/lib/telemetry.d.ts +4 -0
  27. package/dist/lib/telemetry.d.ts.map +1 -0
  28. package/dist/lib/telemetry.js +92 -0
  29. package/dist/lib/version.d.ts +2 -0
  30. package/dist/lib/version.d.ts.map +1 -0
  31. package/dist/lib/version.js +7 -0
  32. package/dist/routes/index.d.ts.map +1 -1
  33. package/dist/routes/index.js +19 -4
  34. package/dist/routes/probes.d.ts +4 -0
  35. package/dist/routes/probes.d.ts.map +1 -0
  36. package/dist/routes/probes.js +52 -0
  37. package/dist/routes/v1/decrypt.d.ts +2 -2
  38. package/dist/routes/v1/decrypt.d.ts.map +1 -1
  39. package/dist/routes/v1/decrypt.js +49 -6
  40. package/dist/routes/v1/encrypt.d.ts +2 -2
  41. package/dist/routes/v1/encrypt.d.ts.map +1 -1
  42. package/dist/routes/v1/encrypt.js +48 -6
  43. package/dist/routes/v1/generate.d.ts +2 -2
  44. package/dist/routes/v1/generate.d.ts.map +1 -1
  45. package/dist/routes/v1/generate.js +85 -13
  46. package/dist/routes/v1/index.d.ts +4 -0
  47. package/dist/routes/v1/index.d.ts.map +1 -0
  48. package/dist/routes/v1/index.js +19 -0
  49. package/dist/routes/v1/revoke.d.ts +2 -2
  50. package/dist/routes/v1/revoke.d.ts.map +1 -1
  51. package/dist/routes/v1/revoke.js +57 -5
  52. package/dist/routes/v1/verify.d.ts +4 -0
  53. package/dist/routes/v1/verify.d.ts.map +1 -0
  54. package/dist/routes/v1/verify.js +60 -0
  55. package/dist/routes/v2/algorithms.d.ts +4 -0
  56. package/dist/routes/v2/algorithms.d.ts.map +1 -0
  57. package/dist/routes/v2/algorithms.js +15 -0
  58. package/dist/routes/v2/compliance.d.ts +31 -0
  59. package/dist/routes/v2/compliance.d.ts.map +1 -0
  60. package/dist/routes/v2/compliance.js +223 -0
  61. package/dist/routes/v2/encrypt.d.ts +4 -0
  62. package/dist/routes/v2/encrypt.d.ts.map +1 -0
  63. package/dist/routes/v2/encrypt.js +62 -0
  64. package/dist/routes/v2/hash.d.ts +4 -0
  65. package/dist/routes/v2/hash.d.ts.map +1 -0
  66. package/dist/routes/v2/hash.js +34 -0
  67. package/dist/routes/v2/index.d.ts +4 -0
  68. package/dist/routes/v2/index.d.ts.map +1 -0
  69. package/dist/routes/v2/index.js +44 -0
  70. package/dist/routes/v2/kdf.d.ts +4 -0
  71. package/dist/routes/v2/kdf.d.ts.map +1 -0
  72. package/dist/routes/v2/kdf.js +54 -0
  73. package/dist/routes/v2/key-wrap.d.ts +4 -0
  74. package/dist/routes/v2/key-wrap.d.ts.map +1 -0
  75. package/dist/routes/v2/key-wrap.js +97 -0
  76. package/dist/routes/v2/keys.d.ts +4 -0
  77. package/dist/routes/v2/keys.d.ts.map +1 -0
  78. package/dist/routes/v2/keys.js +88 -0
  79. package/dist/routes/v2/mac.d.ts +4 -0
  80. package/dist/routes/v2/mac.d.ts.map +1 -0
  81. package/dist/routes/v2/mac.js +102 -0
  82. package/dist/routes/v2/multi-recipient.d.ts +4 -0
  83. package/dist/routes/v2/multi-recipient.d.ts.map +1 -0
  84. package/dist/routes/v2/multi-recipient.js +88 -0
  85. package/dist/routes/v2/password-encrypt.d.ts +4 -0
  86. package/dist/routes/v2/password-encrypt.d.ts.map +1 -0
  87. package/dist/routes/v2/password-encrypt.js +92 -0
  88. package/dist/routes/v2/password.d.ts +4 -0
  89. package/dist/routes/v2/password.d.ts.map +1 -0
  90. package/dist/routes/v2/password.js +109 -0
  91. package/dist/routes/v2/pq-hash-sign.d.ts +4 -0
  92. package/dist/routes/v2/pq-hash-sign.d.ts.map +1 -0
  93. package/dist/routes/v2/pq-hash-sign.js +131 -0
  94. package/dist/routes/v2/pq-sign.d.ts +4 -0
  95. package/dist/routes/v2/pq-sign.d.ts.map +1 -0
  96. package/dist/routes/v2/pq-sign.js +117 -0
  97. package/dist/routes/v2/pq.d.ts +4 -0
  98. package/dist/routes/v2/pq.d.ts.map +1 -0
  99. package/dist/routes/v2/pq.js +149 -0
  100. package/dist/routes/v2/sealedbox.d.ts +4 -0
  101. package/dist/routes/v2/sealedbox.d.ts.map +1 -0
  102. package/dist/routes/v2/sealedbox.js +145 -0
  103. package/dist/routes/v2/secretbox.d.ts +4 -0
  104. package/dist/routes/v2/secretbox.d.ts.map +1 -0
  105. package/dist/routes/v2/secretbox.js +94 -0
  106. package/dist/routes/v2/signing.d.ts +4 -0
  107. package/dist/routes/v2/signing.d.ts.map +1 -0
  108. package/dist/routes/v2/signing.js +66 -0
  109. package/dist/routes/v2/stream.d.ts +4 -0
  110. package/dist/routes/v2/stream.d.ts.map +1 -0
  111. package/dist/routes/v2/stream.js +206 -0
  112. package/dist/server.d.ts +4 -0
  113. package/dist/server.d.ts.map +1 -0
  114. package/dist/server.js +124 -0
  115. package/dist/utils/route-helpers.d.ts +15 -0
  116. package/dist/utils/route-helpers.d.ts.map +1 -0
  117. package/dist/utils/route-helpers.js +42 -0
  118. package/dist/utils/validation.d.ts +29 -0
  119. package/dist/utils/validation.d.ts.map +1 -0
  120. package/dist/utils/validation.js +162 -0
  121. package/package.json +103 -140
  122. package/dist/@types/types.js.map +0 -1
  123. package/dist/COPYRIGHT +0 -14
  124. package/dist/Report.txt +0 -90
  125. package/dist/config/endpoints.config.d.ts +0 -7
  126. package/dist/config/endpoints.config.d.ts.map +0 -1
  127. package/dist/config/endpoints.config.js +0 -8
  128. package/dist/config/endpoints.config.js.map +0 -1
  129. package/dist/index.js.map +0 -1
  130. package/dist/lib/logger.js.map +0 -1
  131. package/dist/package.json +0 -141
  132. package/dist/routes/index.js.map +0 -1
  133. package/dist/routes/v1/decrypt.js.map +0 -1
  134. package/dist/routes/v1/encrypt.js.map +0 -1
  135. package/dist/routes/v1/generate.js.map +0 -1
  136. package/dist/routes/v1/revoke.js.map +0 -1
@@ -0,0 +1,4 @@
1
+ import * as fastify from "fastify";
2
+ declare const _default: (app: fastify.FastifyInstance) => void;
3
+ export default _default;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/routes/v1/index.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;yBAUnB,KAAK,OAAO,CAAC,eAAe,KAAG,IAAI;AAAnD,wBAcE"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const uuid_1 = require("uuid");
4
+ const constants_1 = require("../../config/constants");
5
+ const id = (0, uuid_1.v4)();
6
+ exports.default = (app) => {
7
+ app.get("/", async () => {
8
+ return {
9
+ id: id,
10
+ title: "Welcome to Crypto Server",
11
+ description: "Crypto Server is a Fastify web server that exposes easy consumable REST APIs to perform low-level cryptographic operations.",
12
+ details: "It supports the following cryptographic operations:\n- Digital Signing,\n- Encryption and Decryption,\n- Key Generation,\n- Key Management,\n- Pseudorandom Number Generation,\n- Signature Verification.\n- Development of this server is hosted by GitHub at the following page. Source code is available to everyone under the standard MIT license.",
13
+ license: "MIT",
14
+ url: "https://crypto-server.com",
15
+ version: constants_1.LIB_VERSION,
16
+ };
17
+ });
18
+ };
19
+ //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import * as fastify from 'fastify';
2
- declare const _default: (app: fastify.FastifyInstance) => void;
1
+ import type { FastifyInstance } from "fastify";
2
+ declare const _default: (app: FastifyInstance) => void;
3
3
  export default _default;
4
4
  //# sourceMappingURL=revoke.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"revoke.d.ts","sourceRoot":"","sources":["../../../src/routes/v1/revoke.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;8BAId,QAAQ,eAAe;AAA5C,wBASE"}
1
+ {"version":3,"file":"revoke.d.ts","sourceRoot":"","sources":["../../../src/routes/v1/revoke.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;yBA8C/B,KAAK,eAAe,KAAG,IAAI;AAA3C,wBAgCE"}
@@ -4,12 +4,64 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const revoke_1 = __importDefault(require("@sebastienrousseau/crypto-lib/dist/lib/revoke"));
7
+ const types_1 = require("../../@types/types");
8
+ const validation_1 = require("../../utils/validation");
9
+ const route_helpers_1 = require("../../utils/route-helpers");
10
+ const revokeSchema = {
11
+ tags: ["Key Management"],
12
+ summary: "Revoke a key pair",
13
+ description: "Revokes the shipped key pair with a reason code (0=unspecified, 1=superseded, 2=compromised, 3=retired). Returns the revoked public key only.",
14
+ response: {
15
+ 200: {
16
+ type: "object",
17
+ additionalProperties: false,
18
+ properties: {
19
+ data: {
20
+ type: "object",
21
+ additionalProperties: false,
22
+ properties: { publicKey: { type: "string" } },
23
+ },
24
+ },
25
+ },
26
+ 400: {
27
+ type: "object",
28
+ properties: { error: { type: "string" }, details: { type: "array" } },
29
+ },
30
+ 401: { type: "object", properties: { error: { type: "string" } } },
31
+ },
32
+ body: {
33
+ type: "object",
34
+ required: ["passphrase", "flag", "reason"],
35
+ additionalProperties: false,
36
+ properties: {
37
+ passphrase: { type: "string", minLength: 1, maxLength: 1024 },
38
+ flag: { type: "number", enum: [...types_1.REVOCATION_FLAGS] },
39
+ reason: { type: "string", minLength: 1, maxLength: 2048 },
40
+ },
41
+ },
42
+ };
7
43
  exports.default = (app) => {
8
- app.get("/v1/revoke", async (request, reply) => {
9
- const encryptedData = await (0, revoke_1.default)({
10
- passphrase: request.headers["passphrase"],
11
- });
12
- reply.send({ data: encryptedData });
44
+ app.post("/v1/revoke", { schema: revokeSchema }, async (request, reply) => {
45
+ try {
46
+ const body = request.body;
47
+ const v = (0, route_helpers_1.collectValidation)({
48
+ passphrase: (0, validation_1.validateRequiredString)(body.passphrase, "passphrase"),
49
+ flag: (0, validation_1.validateRequiredNumber)(body.flag, "flag", { min: 0, max: 3 }),
50
+ reason: (0, validation_1.validateRequiredString)(body.reason, "reason"),
51
+ }, reply);
52
+ if (!v)
53
+ return;
54
+ const revocationData = await (0, revoke_1.default)({
55
+ passphrase: v.passphrase,
56
+ flag: v.flag,
57
+ reason: v.reason,
58
+ });
59
+ return reply.send({ data: { publicKey: revocationData.publicKey } });
60
+ }
61
+ catch (error) {
62
+ request.log.error(error, "Revocation operation failed");
63
+ return reply.status(500).send({ error: "Revocation failed" });
64
+ }
13
65
  });
14
66
  };
15
67
  //# sourceMappingURL=revoke.js.map
@@ -0,0 +1,4 @@
1
+ import type { FastifyInstance } from "fastify";
2
+ declare const _default: (app: FastifyInstance) => void;
3
+ export default _default;
4
+ //# sourceMappingURL=verify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../src/routes/v1/verify.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;yBAyC/B,KAAK,eAAe,KAAG,IAAI;AAA3C,wBAiCE"}
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const verify_1 = __importDefault(require("@sebastienrousseau/crypto-lib/dist/lib/verify"));
7
+ const validation_1 = require("../../utils/validation");
8
+ const route_helpers_1 = require("../../utils/route-helpers");
9
+ const verifySchema = {
10
+ tags: ["Signing"],
11
+ summary: "Verify a signed message",
12
+ description: "Verifies a cleartext-signed PGP message against the supplied verification keys.",
13
+ response: {
14
+ 200: {
15
+ type: "object",
16
+ additionalProperties: true,
17
+ properties: { data: {} },
18
+ },
19
+ 400: {
20
+ type: "object",
21
+ properties: { error: { type: "string" }, details: { type: "array" } },
22
+ },
23
+ 401: { type: "object", properties: { error: { type: "string" } } },
24
+ },
25
+ body: {
26
+ type: "object",
27
+ required: ["date", "message", "verificationKeys"],
28
+ additionalProperties: false,
29
+ properties: {
30
+ date: { type: "string", minLength: 1, maxLength: 64 },
31
+ message: { type: "string", minLength: 1, maxLength: 1024 * 1024 },
32
+ verificationKeys: { type: "string", minLength: 1, maxLength: 64 * 1024 },
33
+ },
34
+ },
35
+ };
36
+ exports.default = (app) => {
37
+ app.post("/v1/verify", { schema: verifySchema }, async (request, reply) => {
38
+ try {
39
+ const body = request.body;
40
+ const v = (0, route_helpers_1.collectValidation)({
41
+ date: (0, validation_1.validateDateString)(body.date, "date"),
42
+ message: (0, validation_1.validateRequiredString)(body.message, "message"),
43
+ verificationKeys: (0, validation_1.validateBase64)(body.verificationKeys, "verificationKeys"),
44
+ }, reply);
45
+ if (!v)
46
+ return;
47
+ const verifyData = await (0, verify_1.default)({
48
+ date: v.date,
49
+ message: v.message,
50
+ verificationKeys: v.verificationKeys,
51
+ });
52
+ return reply.send({ data: verifyData });
53
+ }
54
+ catch (error) {
55
+ request.log.error(error, "Verification operation failed");
56
+ return reply.status(500).send({ error: "Verification failed" });
57
+ }
58
+ });
59
+ };
60
+ //# sourceMappingURL=verify.js.map
@@ -0,0 +1,4 @@
1
+ import type { FastifyInstance } from "fastify";
2
+ declare const _default: (app: FastifyInstance) => void;
3
+ export default _default;
4
+ //# sourceMappingURL=algorithms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"algorithms.d.ts","sourceRoot":"","sources":["../../../src/routes/v2/algorithms.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;yBAI/B,KAAK,eAAe,KAAG,IAAI;AAA3C,wBAeE"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const modern_1 = require("@sebastienrousseau/crypto-lib/dist/modern");
4
+ exports.default = (app) => {
5
+ app.get("/v2/algorithms", {
6
+ schema: {
7
+ tags: ["Algorithms"],
8
+ summary: "List supported algorithms",
9
+ description: "Returns all cryptographic algorithms supported by the v2 API.",
10
+ },
11
+ }, async () => {
12
+ return { data: modern_1.SUPPORTED_ALGORITHMS };
13
+ });
14
+ };
15
+ //# sourceMappingURL=algorithms.js.map
@@ -0,0 +1,31 @@
1
+ import type { FastifyInstance } from "fastify";
2
+ import type { CbomPayload } from "../../enterprise/types";
3
+ export declare function readPackageVersion(dir: string): string;
4
+ export interface InventoryRecord {
5
+ readonly package: string;
6
+ readonly version: string;
7
+ readonly status: "implemented" | "partial" | "placeholder";
8
+ readonly fipsCompliance: string;
9
+ }
10
+ export interface DoraSelfAssessment {
11
+ readonly standard: "DORA (EU 2022/2554)";
12
+ readonly article: "Article 9 & Article 13";
13
+ readonly status: string;
14
+ readonly disclaimer: string;
15
+ readonly quantumResistanceRatio: number;
16
+ readonly activePrimitivesCount: number;
17
+ readonly postQuantumPrimitivesCount: number;
18
+ readonly algorithmDeprecationSchedule: ReadonlyArray<{
19
+ readonly algorithm: string;
20
+ readonly category: "symmetric" | "asymmetric";
21
+ readonly sunsetDate: string;
22
+ readonly recommendedMigration: string;
23
+ }>;
24
+ readonly cryptographicInventory: ReadonlyArray<InventoryRecord>;
25
+ readonly timestamp: string;
26
+ }
27
+ export declare function buildDoraSelfAssessment(now?: Date): DoraSelfAssessment;
28
+ export declare function buildCbom(now?: Date): CbomPayload;
29
+ declare const _default: (app: FastifyInstance) => void;
30
+ export default _default;
31
+ //# sourceMappingURL=compliance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compliance.d.ts","sourceRoot":"","sources":["../../../src/routes/v2/compliance.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAe1D,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAQtD;AAGD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,aAAa,GAAG,SAAS,GAAG,aAAa,CAAC;IAE3D,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAGD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,QAAQ,EAAE,qBAAqB,CAAC;IACzC,QAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAC;IAC3C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAC;IACxC,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;IACvC,QAAQ,CAAC,0BAA0B,EAAE,MAAM,CAAC;IAC5C,QAAQ,CAAC,4BAA4B,EAAE,aAAa,CAAC;QACnD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,QAAQ,EAAE,WAAW,GAAG,YAAY,CAAC;QAC9C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;QAC5B,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;KACvC,CAAC,CAAC;IACH,QAAQ,CAAC,sBAAsB,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IAChE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AA4FD,wBAAgB,uBAAuB,CACrC,GAAG,GAAE,IAAiB,GACrB,kBAAkB,CAmBpB;AA8CD,wBAAgB,SAAS,CAAC,GAAG,GAAE,IAAiB,GAAG,WAAW,CA0B7D;yBAGe,KAAK,eAAe,KAAG,IAAI;AAA3C,wBAyDE"}
@@ -0,0 +1,223 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.readPackageVersion = readPackageVersion;
7
+ exports.buildDoraSelfAssessment = buildDoraSelfAssessment;
8
+ exports.buildCbom = buildCbom;
9
+ const node_crypto_1 = require("node:crypto");
10
+ const node_fs_1 = require("node:fs");
11
+ const node_path_1 = __importDefault(require("node:path"));
12
+ const modern_1 = require("@sebastienrousseau/crypto-lib/dist/modern");
13
+ const PACKAGES_ROOT = node_path_1.default.resolve(__dirname, "..", "..", "..", "..");
14
+ function readPackageVersion(dir) {
15
+ try {
16
+ const file = node_path_1.default.join(PACKAGES_ROOT, dir, "package.json");
17
+ return JSON.parse((0, node_fs_1.readFileSync)(file, "utf8"))
18
+ .version;
19
+ }
20
+ catch {
21
+ return "unknown";
22
+ }
23
+ }
24
+ const DISCLAIMER = "Self-reported inventory generated by crypto-server. It is not a DORA " +
25
+ "compliance assessment, audit or certification. Counts are algorithm " +
26
+ "identifiers listed by crypto-lib's SUPPORTED_ALGORITHMS, not a measure " +
27
+ "of any deployment. Sunset dates are project recommendations, not " +
28
+ "regulatory deadlines. No module in this suite is FIPS 140-3 validated.";
29
+ const POST_QUANTUM_ID = /ml-kem|ml-dsa|slh-dsa|fn-dsa/;
30
+ const ALGORITHM_IDS = new Set(Object.values(modern_1.SUPPORTED_ALGORITHMS).flat());
31
+ const POST_QUANTUM_COUNT = [...ALGORITHM_IDS].filter((id) => POST_QUANTUM_ID.test(id)).length;
32
+ const DEPRECATION_SCHEDULE = [
33
+ {
34
+ algorithm: "RSA-2048",
35
+ category: "asymmetric",
36
+ sunsetDate: "2026-12-31T23:59:59Z",
37
+ recommendedMigration: "FIPS 203 ML-KEM-768 / FIPS 204 ML-DSA-65",
38
+ },
39
+ {
40
+ algorithm: "ECDSA (secp256r1 / P-256)",
41
+ category: "asymmetric",
42
+ sunsetDate: "2027-12-31T23:59:59Z",
43
+ recommendedMigration: "FIPS 204 ML-DSA-44 / Ed25519-ML-DSA Hybrid",
44
+ },
45
+ {
46
+ algorithm: "Classical X25519 ECDH",
47
+ category: "asymmetric",
48
+ sunsetDate: "2030-01-01T00:00:00Z",
49
+ recommendedMigration: "Hybrid X25519 + ML-KEM-768 (X25519MLKEM768 per RFC 10024 for TLS 1.3)",
50
+ },
51
+ {
52
+ algorithm: "Triple-DES (3DES) & RC4",
53
+ category: "symmetric",
54
+ sunsetDate: "Immediate (Deprecated)",
55
+ recommendedMigration: "AES-256-GCM / ChaCha20-Poly1305",
56
+ },
57
+ ];
58
+ const INVENTORY = [
59
+ {
60
+ package: "@sebastienrousseau/crypto-lib",
61
+ status: "implemented",
62
+ fipsCompliance: "Implements FIPS 203/204/205 algorithms (ML-KEM, ML-DSA, SLH-DSA) and Falcon (FN-DSA) via @noble/post-quantum; not a validated cryptographic module",
63
+ },
64
+ {
65
+ package: "@sebastienrousseau/crypto-wasm",
66
+ status: "placeholder",
67
+ fipsCompliance: "Contains no WebAssembly code; all operations run in JavaScript",
68
+ },
69
+ {
70
+ package: "@sebastienrousseau/crypto-kms",
71
+ status: "partial",
72
+ fipsCompliance: "AWS KMS and in-memory local providers; GCP, Azure and Vault providers are stubs; PKCS#11 provider is a software simulation; not FIPS 140 validated",
73
+ },
74
+ {
75
+ package: "@sebastienrousseau/crypto-edge",
76
+ status: "implemented",
77
+ fipsCompliance: "Web Crypto API adapter with TextEncoder/TextDecoder and base64 fallbacks; not a validated cryptographic module",
78
+ },
79
+ {
80
+ package: "@sebastienrousseau/crypto-cbom",
81
+ status: "implemented",
82
+ fipsCompliance: "Generates CycloneDX 1.6 and SPDX 3.0 CBOM documents",
83
+ },
84
+ {
85
+ package: "@sebastienrousseau/crypto-mcp",
86
+ status: "implemented",
87
+ fipsCompliance: "Model Context Protocol server exposing crypto operations",
88
+ },
89
+ {
90
+ package: "@sebastienrousseau/crypto-lsp",
91
+ status: "implemented",
92
+ fipsCompliance: "Language server flagging quantum-vulnerable algorithm names with pattern rules",
93
+ },
94
+ ];
95
+ function buildDoraSelfAssessment(now = new Date()) {
96
+ return {
97
+ standard: "DORA (EU 2022/2554)",
98
+ article: "Article 9 & Article 13",
99
+ status: "Self-assessment (not a compliance verdict)",
100
+ disclaimer: DISCLAIMER,
101
+ quantumResistanceRatio: Math.round((POST_QUANTUM_COUNT / ALGORITHM_IDS.size) * 100) / 100,
102
+ activePrimitivesCount: ALGORITHM_IDS.size,
103
+ postQuantumPrimitivesCount: POST_QUANTUM_COUNT,
104
+ algorithmDeprecationSchedule: DEPRECATION_SCHEDULE,
105
+ cryptographicInventory: INVENTORY.map((record) => ({
106
+ ...record,
107
+ version: readPackageVersion(record.package.replace("@sebastienrousseau/", "")),
108
+ })),
109
+ timestamp: now.toISOString(),
110
+ };
111
+ }
112
+ const CBOM_COMPONENTS = [
113
+ {
114
+ type: "cryptographic-asset",
115
+ name: "ML-KEM-768",
116
+ version: "FIPS-203",
117
+ properties: [
118
+ { name: "algorithm-family", value: "Module-Lattice KEM" },
119
+ { name: "quantum-security-category", value: "3" },
120
+ { name: "implementation", value: "@noble/post-quantum" },
121
+ ],
122
+ },
123
+ {
124
+ type: "cryptographic-asset",
125
+ name: "ML-DSA-65",
126
+ version: "FIPS-204",
127
+ properties: [
128
+ { name: "algorithm-family", value: "Module-Lattice Signatures" },
129
+ { name: "quantum-security-category", value: "3" },
130
+ { name: "implementation", value: "@noble/post-quantum" },
131
+ ],
132
+ },
133
+ {
134
+ type: "cryptographic-asset",
135
+ name: "SLH-DSA-128s",
136
+ version: "FIPS-205",
137
+ properties: [
138
+ { name: "algorithm-family", value: "Stateless Hash-Based Signatures" },
139
+ { name: "quantum-security-category", value: "1" },
140
+ { name: "implementation", value: "@noble/post-quantum" },
141
+ ],
142
+ },
143
+ {
144
+ type: "cryptographic-asset",
145
+ name: "Composite-Hybrid-X25519-ML-KEM-768",
146
+ version: "RFC-10024",
147
+ properties: [
148
+ { name: "algorithm-family", value: "Dual Encapsulation Hybrid KEM" },
149
+ { name: "defense-in-depth", value: "classical-plus-post-quantum" },
150
+ { name: "implementation", value: "@noble/curves + @noble/post-quantum" },
151
+ ],
152
+ },
153
+ ];
154
+ function buildCbom(now = new Date()) {
155
+ const serverVersion = readPackageVersion("crypto-server");
156
+ return {
157
+ bomFormat: "CycloneDX",
158
+ specVersion: "1.6",
159
+ serialNumber: `urn:uuid:${(0, node_crypto_1.randomUUID)()}`,
160
+ version: 1,
161
+ metadata: {
162
+ timestamp: now.toISOString(),
163
+ tools: [
164
+ {
165
+ vendor: "Sebastien Rousseau",
166
+ name: "@sebastienrousseau/crypto-server",
167
+ version: serverVersion,
168
+ },
169
+ ],
170
+ component: {
171
+ type: "framework",
172
+ name: "@sebastienrousseau/crypto-server",
173
+ version: serverVersion,
174
+ description: "Fastify REST API exposing crypto-lib operations, including post-quantum algorithms",
175
+ },
176
+ },
177
+ components: CBOM_COMPONENTS,
178
+ };
179
+ }
180
+ exports.default = (app) => {
181
+ app.get("/v2/compliance/dora", {
182
+ schema: {
183
+ tags: ["Compliance"],
184
+ summary: "DORA cryptographic inventory (self-assessment)",
185
+ description: "Returns a self-reported cryptographic inventory, post-quantum algorithm counts and recommended sunset dates. It is not a compliance assessment or verdict under Regulation (EU) 2022/2554.",
186
+ response: {
187
+ 200: {
188
+ type: "object",
189
+ properties: {
190
+ data: {
191
+ type: "object",
192
+ properties: {
193
+ standard: { type: "string" },
194
+ article: { type: "string" },
195
+ status: { type: "string" },
196
+ disclaimer: { type: "string" },
197
+ quantumResistanceRatio: { type: "number" },
198
+ activePrimitivesCount: { type: "number" },
199
+ postQuantumPrimitivesCount: { type: "number" },
200
+ algorithmDeprecationSchedule: { type: "array" },
201
+ cryptographicInventory: { type: "array" },
202
+ timestamp: { type: "string" },
203
+ },
204
+ },
205
+ },
206
+ },
207
+ },
208
+ },
209
+ }, async () => {
210
+ return { data: buildDoraSelfAssessment() };
211
+ });
212
+ app.get("/v2/compliance/cbom", {
213
+ schema: {
214
+ tags: ["Compliance"],
215
+ summary: "Cryptographic Bill of Materials (CBOM) in CycloneDX 1.6 format",
216
+ description: "Emits a machine-readable CycloneDX 1.6 CBOM listing the post-quantum algorithms this service implements. It is informational input for CRA and DORA work and does not by itself establish compliance.",
217
+ },
218
+ }, async (_request, reply) => {
219
+ reply.header("Content-Type", "application/vnd.cyclonedx+json; charset=utf-8");
220
+ return buildCbom();
221
+ });
222
+ };
223
+ //# sourceMappingURL=compliance.js.map
@@ -0,0 +1,4 @@
1
+ import type { FastifyInstance } from "fastify";
2
+ declare const _default: (app: FastifyInstance) => void;
3
+ export default _default;
4
+ //# sourceMappingURL=encrypt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encrypt.d.ts","sourceRoot":"","sources":["../../../src/routes/v2/encrypt.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;yBA+C/B,KAAK,eAAe,KAAG,IAAI;AAA3C,wBA4BE"}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const modern_1 = require("@sebastienrousseau/crypto-lib/dist/modern");
4
+ const route_helpers_1 = require("../../utils/route-helpers");
5
+ const encryptSchema = {
6
+ tags: ["Modern Encryption"],
7
+ summary: "Encrypt with XChaCha20-Poly1305",
8
+ description: "AEAD encryption using XChaCha20-Poly1305. Returns base64(nonce || ciphertext || tag).",
9
+ body: {
10
+ type: "object",
11
+ required: ["key", "plaintext"],
12
+ additionalProperties: false,
13
+ properties: {
14
+ key: {
15
+ type: "string",
16
+ minLength: 64,
17
+ maxLength: 64,
18
+ description: "256-bit key as hex (64 chars)",
19
+ },
20
+ plaintext: { type: "string", minLength: 1, maxLength: 10 * 1024 * 1024 },
21
+ },
22
+ },
23
+ };
24
+ const decryptSchema = {
25
+ tags: ["Modern Encryption"],
26
+ summary: "Decrypt with XChaCha20-Poly1305",
27
+ description: "AEAD decryption. Expects base64 blob from the encrypt endpoint.",
28
+ body: {
29
+ type: "object",
30
+ required: ["key", "ciphertext"],
31
+ additionalProperties: false,
32
+ properties: {
33
+ key: { type: "string", minLength: 64, maxLength: 64 },
34
+ ciphertext: { type: "string", minLength: 1 },
35
+ },
36
+ },
37
+ };
38
+ exports.default = (app) => {
39
+ app.post("/v2/encrypt", { schema: encryptSchema }, async (request, reply) => {
40
+ try {
41
+ const { key, plaintext } = request.body;
42
+ const result = (0, modern_1.aeadEncrypt)({ key, plaintext });
43
+ return reply.send({ data: result });
44
+ }
45
+ catch (error) {
46
+ return (0, route_helpers_1.classifyCryptoError)(error, request, reply, "Encryption");
47
+ }
48
+ });
49
+ app.post("/v2/decrypt", { schema: decryptSchema }, async (request, reply) => {
50
+ try {
51
+ const { key, ciphertext } = request.body;
52
+ const plaintext = (0, modern_1.aeadDecrypt)({ key, ciphertext });
53
+ return reply.send({
54
+ data: { plaintext: Buffer.from(plaintext).toString("utf8") },
55
+ });
56
+ }
57
+ catch (error) {
58
+ return (0, route_helpers_1.classifyCryptoError)(error, request, reply, "Decryption");
59
+ }
60
+ });
61
+ };
62
+ //# sourceMappingURL=encrypt.js.map
@@ -0,0 +1,4 @@
1
+ import type { FastifyInstance } from "fastify";
2
+ declare const _default: (app: FastifyInstance) => void;
3
+ export default _default;
4
+ //# sourceMappingURL=hash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../../src/routes/v2/hash.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;yBAwB/B,KAAK,eAAe,KAAG,IAAI;AAA3C,wBAiBE"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const modern_1 = require("@sebastienrousseau/crypto-lib/dist/modern");
4
+ const route_helpers_1 = require("../../utils/route-helpers");
5
+ const hashSchema = {
6
+ tags: ["Hashing"],
7
+ summary: "Compute a cryptographic hash",
8
+ description: "Compute a hash digest using SHA-2, SHA-3, BLAKE2b, or BLAKE3.",
9
+ body: {
10
+ type: "object",
11
+ required: ["algorithm", "data"],
12
+ additionalProperties: false,
13
+ properties: {
14
+ algorithm: { type: "string", enum: [...modern_1.HASH_ALGORITHMS] },
15
+ data: { type: "string", minLength: 1, maxLength: 10 * 1024 * 1024 },
16
+ },
17
+ },
18
+ };
19
+ exports.default = (app) => {
20
+ app.post("/v2/hash", { schema: hashSchema }, async (request, reply) => {
21
+ try {
22
+ const { algorithm, data } = request.body;
23
+ const result = (0, modern_1.hash)({
24
+ algorithm: algorithm,
25
+ data,
26
+ });
27
+ return reply.send({ data: result });
28
+ }
29
+ catch (error) {
30
+ return (0, route_helpers_1.classifyCryptoError)(error, request, reply, "Hash computation");
31
+ }
32
+ });
33
+ };
34
+ //# sourceMappingURL=hash.js.map
@@ -0,0 +1,4 @@
1
+ import type { FastifyInstance } from "fastify";
2
+ declare const _default: (app: FastifyInstance) => void;
3
+ export default _default;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/routes/v2/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;yBAqB/B,KAAK,eAAe,KAAG,IAAI;AAA3C,wBAmBE"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const algorithms_1 = __importDefault(require("./algorithms"));
7
+ const encrypt_1 = __importDefault(require("./encrypt"));
8
+ const hash_1 = __importDefault(require("./hash"));
9
+ const kdf_1 = __importDefault(require("./kdf"));
10
+ const mac_1 = __importDefault(require("./mac"));
11
+ const password_1 = __importDefault(require("./password"));
12
+ const pq_1 = __importDefault(require("./pq"));
13
+ const pq_sign_1 = __importDefault(require("./pq-sign"));
14
+ const pq_hash_sign_1 = __importDefault(require("./pq-hash-sign"));
15
+ const signing_1 = __importDefault(require("./signing"));
16
+ const secretbox_1 = __importDefault(require("./secretbox"));
17
+ const sealedbox_1 = __importDefault(require("./sealedbox"));
18
+ const password_encrypt_1 = __importDefault(require("./password-encrypt"));
19
+ const key_wrap_1 = __importDefault(require("./key-wrap"));
20
+ const keys_1 = __importDefault(require("./keys"));
21
+ const multi_recipient_1 = __importDefault(require("./multi-recipient"));
22
+ const compliance_1 = __importDefault(require("./compliance"));
23
+ const stream_1 = __importDefault(require("./stream"));
24
+ exports.default = (app) => {
25
+ (0, algorithms_1.default)(app);
26
+ (0, compliance_1.default)(app);
27
+ (0, stream_1.default)(app);
28
+ (0, encrypt_1.default)(app);
29
+ (0, hash_1.default)(app);
30
+ (0, kdf_1.default)(app);
31
+ (0, mac_1.default)(app);
32
+ (0, password_1.default)(app);
33
+ (0, pq_1.default)(app);
34
+ (0, pq_sign_1.default)(app);
35
+ (0, pq_hash_sign_1.default)(app);
36
+ (0, signing_1.default)(app);
37
+ (0, secretbox_1.default)(app);
38
+ (0, sealedbox_1.default)(app);
39
+ (0, password_encrypt_1.default)(app);
40
+ (0, key_wrap_1.default)(app);
41
+ (0, keys_1.default)(app);
42
+ (0, multi_recipient_1.default)(app);
43
+ };
44
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,4 @@
1
+ import type { FastifyInstance } from "fastify";
2
+ declare const _default: (app: FastifyInstance) => void;
3
+ export default _default;
4
+ //# sourceMappingURL=kdf.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kdf.d.ts","sourceRoot":"","sources":["../../../src/routes/v2/kdf.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;yBAuC/B,KAAK,eAAe,KAAG,IAAI;AAA3C,wBAgCE"}