@sebastienrousseau/crypto-server 0.0.2 → 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.
- 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
|
@@ -0,0 +1,54 @@
|
|
|
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 kdfSchema = {
|
|
6
|
+
tags: ["Key Derivation"],
|
|
7
|
+
summary: "Derive a key from a password",
|
|
8
|
+
description: "Key derivation using scrypt, HKDF-SHA256, or PBKDF2-SHA256.",
|
|
9
|
+
body: {
|
|
10
|
+
type: "object",
|
|
11
|
+
required: ["algorithm", "password"],
|
|
12
|
+
additionalProperties: false,
|
|
13
|
+
properties: {
|
|
14
|
+
algorithm: { type: "string", enum: [...modern_1.KDF_ALGORITHMS] },
|
|
15
|
+
password: { type: "string", minLength: 1, maxLength: 1024 },
|
|
16
|
+
salt: { type: "string", maxLength: 128 },
|
|
17
|
+
keyLength: { type: "number", minimum: 16, maximum: 64 },
|
|
18
|
+
params: {
|
|
19
|
+
type: "object",
|
|
20
|
+
additionalProperties: false,
|
|
21
|
+
properties: {
|
|
22
|
+
N: { type: "integer", minimum: 2, maximum: 131072 },
|
|
23
|
+
r: { type: "integer", minimum: 1, maximum: 8 },
|
|
24
|
+
p: { type: "integer", minimum: 1, maximum: 4 },
|
|
25
|
+
iterations: { type: "integer", minimum: 1, maximum: 1000000 },
|
|
26
|
+
info: { type: "string", maxLength: 1024 },
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
exports.default = (app) => {
|
|
33
|
+
app.post("/v2/kdf", { schema: kdfSchema }, async (request, reply) => {
|
|
34
|
+
try {
|
|
35
|
+
const body = request.body;
|
|
36
|
+
const result = (0, modern_1.kdfDerive)({
|
|
37
|
+
algorithm: body.algorithm,
|
|
38
|
+
password: body.password,
|
|
39
|
+
...(body.salt ? { salt: body.salt } : {}),
|
|
40
|
+
...(body.keyLength ? { keyLength: body.keyLength } : {}),
|
|
41
|
+
...(body.params
|
|
42
|
+
? {
|
|
43
|
+
params: body.params,
|
|
44
|
+
}
|
|
45
|
+
: {}),
|
|
46
|
+
});
|
|
47
|
+
return reply.send({ data: result });
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
return (0, route_helpers_1.classifyCryptoError)(error, request, reply, "Key derivation");
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=kdf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key-wrap.d.ts","sourceRoot":"","sources":["../../../src/routes/v2/key-wrap.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;yBAI/B,KAAK,eAAe,KAAG,IAAI;AAA3C,wBA8EE"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const route_helpers_1 = require("../../utils/route-helpers");
|
|
37
|
+
exports.default = (app) => {
|
|
38
|
+
app.post("/v2/keys/wrap", {
|
|
39
|
+
schema: {
|
|
40
|
+
tags: ["Key Wrapping"],
|
|
41
|
+
summary: "Wrap a key using AES-KW or AES-KWP (RFC 3394/5649)",
|
|
42
|
+
body: {
|
|
43
|
+
type: "object",
|
|
44
|
+
required: ["kek", "keyToWrap"],
|
|
45
|
+
additionalProperties: false,
|
|
46
|
+
properties: {
|
|
47
|
+
kek: { type: "string", minLength: 1 },
|
|
48
|
+
keyToWrap: { type: "string", minLength: 1 },
|
|
49
|
+
algorithm: { type: "string", enum: ["aes-kw", "aes-kwp"] },
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
}, async (request, reply) => {
|
|
54
|
+
try {
|
|
55
|
+
const { aesKwWrap, aesKwpWrap } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib/dist/high-level/key-wrap")));
|
|
56
|
+
const { kek, keyToWrap, algorithm } = request.body;
|
|
57
|
+
const result = algorithm === "aes-kwp"
|
|
58
|
+
? aesKwpWrap(kek, keyToWrap)
|
|
59
|
+
: aesKwWrap(kek, keyToWrap);
|
|
60
|
+
return reply.send({ data: result });
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
return (0, route_helpers_1.classifyCryptoError)(error, request, reply, "Key wrapping");
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
app.post("/v2/keys/unwrap", {
|
|
67
|
+
schema: {
|
|
68
|
+
tags: ["Key Wrapping"],
|
|
69
|
+
summary: "Unwrap a key using AES-KW or AES-KWP (RFC 3394/5649)",
|
|
70
|
+
body: {
|
|
71
|
+
type: "object",
|
|
72
|
+
required: ["kek", "wrappedKey"],
|
|
73
|
+
additionalProperties: false,
|
|
74
|
+
properties: {
|
|
75
|
+
kek: { type: "string", minLength: 1 },
|
|
76
|
+
wrappedKey: { type: "string", minLength: 1 },
|
|
77
|
+
algorithm: { type: "string", enum: ["aes-kw", "aes-kwp"] },
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
}, async (request, reply) => {
|
|
82
|
+
try {
|
|
83
|
+
const { aesKwUnwrap, aesKwpUnwrap } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib/dist/high-level/key-wrap")));
|
|
84
|
+
const { kek, wrappedKey, algorithm } = request.body;
|
|
85
|
+
const result = algorithm === "aes-kwp"
|
|
86
|
+
? aesKwpUnwrap(kek, wrappedKey)
|
|
87
|
+
: aesKwUnwrap(kek, wrappedKey);
|
|
88
|
+
return reply.send({
|
|
89
|
+
data: Buffer.from(result).toString("hex"),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
return (0, route_helpers_1.classifyCryptoError)(error, request, reply, "Key unwrapping");
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=key-wrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../../src/routes/v2/keys.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;yBAI/B,KAAK,eAAe,KAAG,IAAI;AAA3C,wBA0DE"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const route_helpers_1 = require("../../utils/route-helpers");
|
|
37
|
+
exports.default = (app) => {
|
|
38
|
+
app.post("/v2/keys/generate", {
|
|
39
|
+
schema: {
|
|
40
|
+
tags: ["Key Management"],
|
|
41
|
+
summary: "Generate a key pair for any supported algorithm",
|
|
42
|
+
body: {
|
|
43
|
+
type: "object",
|
|
44
|
+
additionalProperties: false,
|
|
45
|
+
properties: {
|
|
46
|
+
algorithm: {
|
|
47
|
+
default: "ed25519",
|
|
48
|
+
type: "string",
|
|
49
|
+
enum: [
|
|
50
|
+
"ed25519",
|
|
51
|
+
"x25519",
|
|
52
|
+
"ed448",
|
|
53
|
+
"x448",
|
|
54
|
+
"p256",
|
|
55
|
+
"p384",
|
|
56
|
+
"ml-kem-512",
|
|
57
|
+
"ml-kem-768",
|
|
58
|
+
"ml-kem-1024",
|
|
59
|
+
"ml-dsa-44",
|
|
60
|
+
"ml-dsa-65",
|
|
61
|
+
"ml-dsa-87",
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
metadata: {
|
|
65
|
+
type: "object",
|
|
66
|
+
additionalProperties: false,
|
|
67
|
+
properties: {
|
|
68
|
+
kid: { type: "string" },
|
|
69
|
+
use: { type: "string", enum: ["sig", "enc"] },
|
|
70
|
+
exp: { type: "string" },
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
}, async (request, reply) => {
|
|
77
|
+
try {
|
|
78
|
+
const { generateKeyPair } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib/dist/keys/keygen")));
|
|
79
|
+
const { algorithm, metadata } = request.body;
|
|
80
|
+
const result = generateKeyPair(algorithm, metadata);
|
|
81
|
+
return reply.send({ data: result });
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
return (0, route_helpers_1.classifyCryptoError)(error, request, reply, "Key generation");
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
//# sourceMappingURL=keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mac.d.ts","sourceRoot":"","sources":["../../../src/routes/v2/mac.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;yBAQ/B,KAAK,eAAe,KAAG,IAAI;AAA3C,wBAiFE"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const route_helpers_1 = require("../../utils/route-helpers");
|
|
37
|
+
const HMAC_ALGORITHMS = ["sha256", "sha384", "sha512", "sha3-256", "sha3-512"];
|
|
38
|
+
exports.default = (app) => {
|
|
39
|
+
app.post("/v2/hmac", {
|
|
40
|
+
schema: {
|
|
41
|
+
tags: ["MAC"],
|
|
42
|
+
summary: "Compute an HMAC",
|
|
43
|
+
body: {
|
|
44
|
+
type: "object",
|
|
45
|
+
required: ["algorithm", "key", "data"],
|
|
46
|
+
additionalProperties: false,
|
|
47
|
+
properties: {
|
|
48
|
+
algorithm: { type: "string", enum: HMAC_ALGORITHMS },
|
|
49
|
+
key: { type: "string", minLength: 1 },
|
|
50
|
+
data: { type: "string", minLength: 1 },
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
}, async (request, reply) => {
|
|
55
|
+
try {
|
|
56
|
+
const { computeHmac } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib/dist/modern/mac")));
|
|
57
|
+
const body = request.body;
|
|
58
|
+
const result = computeHmac({
|
|
59
|
+
algorithm: body.algorithm,
|
|
60
|
+
key: body.key,
|
|
61
|
+
data: body.data,
|
|
62
|
+
});
|
|
63
|
+
return reply.send({ data: result });
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
return (0, route_helpers_1.classifyCryptoError)(error, request, reply, "HMAC computation");
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
app.post("/v2/hmac/verify", {
|
|
70
|
+
schema: {
|
|
71
|
+
tags: ["MAC"],
|
|
72
|
+
summary: "Verify an HMAC",
|
|
73
|
+
body: {
|
|
74
|
+
type: "object",
|
|
75
|
+
required: ["algorithm", "key", "data", "mac"],
|
|
76
|
+
additionalProperties: false,
|
|
77
|
+
properties: {
|
|
78
|
+
algorithm: { type: "string", enum: HMAC_ALGORITHMS },
|
|
79
|
+
key: { type: "string", minLength: 1 },
|
|
80
|
+
data: { type: "string", minLength: 1 },
|
|
81
|
+
mac: { type: "string", minLength: 1 },
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
}, async (request, reply) => {
|
|
86
|
+
try {
|
|
87
|
+
const { verifyHmac } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib/dist/modern/mac")));
|
|
88
|
+
const body = request.body;
|
|
89
|
+
const result = verifyHmac({
|
|
90
|
+
algorithm: body.algorithm,
|
|
91
|
+
key: body.key,
|
|
92
|
+
data: body.data,
|
|
93
|
+
mac: body.mac,
|
|
94
|
+
});
|
|
95
|
+
return reply.send({ data: result });
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
return (0, route_helpers_1.classifyCryptoError)(error, request, reply, "HMAC verification");
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=mac.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multi-recipient.d.ts","sourceRoot":"","sources":["../../../src/routes/v2/multi-recipient.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;yBAI/B,KAAK,eAAe,KAAG,IAAI;AAA3C,wBAgEE"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const route_helpers_1 = require("../../utils/route-helpers");
|
|
37
|
+
exports.default = (app) => {
|
|
38
|
+
app.post("/v2/multi-recipient/encrypt", {
|
|
39
|
+
schema: {
|
|
40
|
+
tags: ["Multi-Recipient"],
|
|
41
|
+
summary: "Encrypt for multiple recipients (hybrid key wrapping)",
|
|
42
|
+
body: {
|
|
43
|
+
type: "object",
|
|
44
|
+
required: ["plaintext", "recipients"],
|
|
45
|
+
additionalProperties: false,
|
|
46
|
+
properties: {
|
|
47
|
+
plaintext: { type: "string", minLength: 1 },
|
|
48
|
+
recipients: {
|
|
49
|
+
type: "array",
|
|
50
|
+
minItems: 1,
|
|
51
|
+
items: {
|
|
52
|
+
type: "object",
|
|
53
|
+
required: ["type", "publicKey"],
|
|
54
|
+
properties: {
|
|
55
|
+
type: {
|
|
56
|
+
type: "string",
|
|
57
|
+
enum: ["classical", "pq"],
|
|
58
|
+
},
|
|
59
|
+
publicKey: { type: "string", minLength: 1 },
|
|
60
|
+
mlKemPublicKey: { type: "string" },
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
}, async (request, reply) => {
|
|
68
|
+
try {
|
|
69
|
+
const { multiEncrypt } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib/dist/high-level/multi-recipient")));
|
|
70
|
+
const { plaintext, recipients } = request.body;
|
|
71
|
+
const libRecipients = recipients.map((r) => {
|
|
72
|
+
if (r.type === "classical") {
|
|
73
|
+
return { type: "x25519", publicKey: r.publicKey };
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
type: "x25519-ml-kem-768",
|
|
77
|
+
x25519PublicKey: r.publicKey,
|
|
78
|
+
mlKemPublicKey: r.mlKemPublicKey,
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
return reply.send({ data: multiEncrypt(libRecipients, plaintext) });
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
return (0, route_helpers_1.classifyCryptoError)(error, request, reply, "Encryption");
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
//# sourceMappingURL=multi-recipient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password-encrypt.d.ts","sourceRoot":"","sources":["../../../src/routes/v2/password-encrypt.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;yBAI/B,KAAK,eAAe,KAAG,IAAI;AAA3C,wBAsEE"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const route_helpers_1 = require("../../utils/route-helpers");
|
|
37
|
+
exports.default = (app) => {
|
|
38
|
+
app.post("/v2/password/encrypt", {
|
|
39
|
+
schema: {
|
|
40
|
+
tags: ["Password Encryption"],
|
|
41
|
+
summary: "Encrypt with password (Argon2id + XChaCha20-Poly1305)",
|
|
42
|
+
body: {
|
|
43
|
+
type: "object",
|
|
44
|
+
required: ["password", "plaintext"],
|
|
45
|
+
additionalProperties: false,
|
|
46
|
+
properties: {
|
|
47
|
+
password: { type: "string", minLength: 1 },
|
|
48
|
+
plaintext: { type: "string", minLength: 1 },
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
}, async (request, reply) => {
|
|
53
|
+
try {
|
|
54
|
+
const { passwordEncrypt } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib/dist/high-level/password-encrypt")));
|
|
55
|
+
const { password, plaintext } = request.body;
|
|
56
|
+
return reply.send({
|
|
57
|
+
data: passwordEncrypt({ password, plaintext }),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
return (0, route_helpers_1.classifyCryptoError)(error, request, reply, "Encryption");
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
app.post("/v2/password/decrypt", {
|
|
65
|
+
schema: {
|
|
66
|
+
tags: ["Password Encryption"],
|
|
67
|
+
summary: "Decrypt with password (Argon2id + XChaCha20-Poly1305)",
|
|
68
|
+
body: {
|
|
69
|
+
type: "object",
|
|
70
|
+
required: ["password", "ciphertext"],
|
|
71
|
+
additionalProperties: false,
|
|
72
|
+
properties: {
|
|
73
|
+
password: { type: "string", minLength: 1 },
|
|
74
|
+
ciphertext: { type: "string", minLength: 1 },
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
}, async (request, reply) => {
|
|
79
|
+
try {
|
|
80
|
+
const { passwordDecrypt } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib/dist/high-level/password-encrypt")));
|
|
81
|
+
const { password, ciphertext } = request.body;
|
|
82
|
+
const plaintext = passwordDecrypt(password, ciphertext);
|
|
83
|
+
return reply.send({
|
|
84
|
+
data: Buffer.from(plaintext).toString("utf8"),
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
return (0, route_helpers_1.classifyCryptoError)(error, request, reply, "Decryption");
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
//# sourceMappingURL=password-encrypt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password.d.ts","sourceRoot":"","sources":["../../../src/routes/v2/password.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;yBAI/B,KAAK,eAAe,KAAG,IAAI;AAA3C,wBAiGE"}
|