@stratum-hq/control-plane 1.3.0 → 1.4.0
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maintenance.d.ts","sourceRoot":"","sources":["../../src/routes/maintenance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"maintenance.d.ts","sourceRoot":"","sources":["../../src/routes/maintenance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAQ1C,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,IACd,KAAK,eAAe,KAAG,OAAO,CAAC,IAAI,CAAC,CAoD7E"}
|
|
@@ -4,6 +4,8 @@ exports.createMaintenanceRoutes = createMaintenanceRoutes;
|
|
|
4
4
|
const audit_logs_js_1 = require("./audit-logs.js");
|
|
5
5
|
const tenant_scope_js_1 = require("../middleware/tenant-scope.js");
|
|
6
6
|
const authorize_js_1 = require("../middleware/authorize.js");
|
|
7
|
+
// The format of STRATUM_HKDF_SALT. Buffer.from(salt, "hex") silently shortens any other string.
|
|
8
|
+
const HEX_SALT = /^(?:[0-9a-fA-F]{2})+$/;
|
|
7
9
|
function createMaintenanceRoutes(stratum) {
|
|
8
10
|
return async function maintenanceRoutes(app) {
|
|
9
11
|
// Maintenance acts across all tenants: global operator keys only.
|
|
@@ -27,11 +29,29 @@ function createMaintenanceRoutes(stratum) {
|
|
|
27
29
|
reply.status(400).send({ error: { code: "VALIDATION_ERROR", message: "Both 'old_key' and 'new_key' are required" } });
|
|
28
30
|
return;
|
|
29
31
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
for (const field of ["old_salt", "new_salt"]) {
|
|
33
|
+
const salt = body[field];
|
|
34
|
+
if (salt !== undefined && (typeof salt !== "string" || !HEX_SALT.test(salt))) {
|
|
35
|
+
reply.status(400).send({
|
|
36
|
+
error: { code: "VALIDATION_ERROR", message: `'${field}' must be a non-empty, even-length hex string` },
|
|
37
|
+
});
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const oldSalt = body.old_salt;
|
|
42
|
+
const newSalt = body.new_salt;
|
|
43
|
+
// A salt that is not given is the configured salt, so two absent salts are the same salt.
|
|
44
|
+
const sameSalt = oldSalt?.toLowerCase() === newSalt?.toLowerCase();
|
|
45
|
+
if (body.old_key === body.new_key && sameSalt) {
|
|
46
|
+
reply.status(400).send({
|
|
47
|
+
error: { code: "VALIDATION_ERROR", message: "'new_key' must differ from 'old_key' unless 'new_salt' differs from 'old_salt'" },
|
|
48
|
+
});
|
|
32
49
|
return;
|
|
33
50
|
}
|
|
34
|
-
const result = await stratum.rotateEncryptionKey(body.old_key, body.new_key, (0, audit_logs_js_1.buildAuditContext)(request)
|
|
51
|
+
const result = await stratum.rotateEncryptionKey(body.old_key, body.new_key, (0, audit_logs_js_1.buildAuditContext)(request), {
|
|
52
|
+
oldSalt,
|
|
53
|
+
newSalt,
|
|
54
|
+
});
|
|
35
55
|
reply.status(200).send(result);
|
|
36
56
|
});
|
|
37
57
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maintenance.js","sourceRoot":"","sources":["../../src/routes/maintenance.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"maintenance.js","sourceRoot":"","sources":["../../src/routes/maintenance.ts"],"names":[],"mappings":";;AASA,0DAqDC;AA5DD,mDAAoD;AACpD,mEAAmE;AACnE,6DAAkE;AAElE,gGAAgG;AAChG,MAAM,QAAQ,GAAG,uBAAuB,CAAC;AAEzC,SAAgB,uBAAuB,CAAC,OAAgB;IACtD,OAAO,KAAK,UAAU,iBAAiB,CAAC,GAAo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C,IAAI,CAAC,MAAM,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stratum-hq/control-plane",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Stratum control plane REST API server",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"multi-tenancy",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@fastify/swagger": "^9.9.0",
|
|
51
51
|
"@fastify/swagger-ui": "^6.1.1",
|
|
52
52
|
"@stratum-hq/core": "^1.5.0",
|
|
53
|
-
"@stratum-hq/lib": "^1.
|
|
53
|
+
"@stratum-hq/lib": "^1.6.0",
|
|
54
54
|
"fastify": "^5.12.5",
|
|
55
55
|
"jsonwebtoken": "^9.0.0",
|
|
56
56
|
"ioredis": "^5.4.0",
|