From fece14b142695565ddcf483db70db2ebcf62d424 Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Tue, 30 Jul 2024 21:43:16 +0200 Subject: [PATCH] Update signing in validate.ts routes --- src/routes/v1/validate.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/routes/v1/validate.ts b/src/routes/v1/validate.ts index e3d736d..aeaad94 100644 --- a/src/routes/v1/validate.ts +++ b/src/routes/v1/validate.ts @@ -1,5 +1,5 @@ import { Request, Response, Router } from "express"; -import { validateLicense, signOfflineKey } from "@controller/validation"; +import {validateLicense, signOfflineKey, signKey} from "@controller/validation"; const app: Router = Router(); @@ -14,6 +14,13 @@ app.get("/:licenseKey/sign", async (req: Request, res: Response) => { const validationKey = req.header("X-Validation-Key"); if (!validationKey) return res.status(400).json({ code: 1, message: "You need to provide a validation key" }); + res.json(await signKey(validationKey, req.params.licenseKey)); +}); + +app.get("/:licenseKey/offline", async (req: Request, res: Response) => { + const validationKey = req.header("X-Validation-Key"); + if (!validationKey) return res.status(400).json({ code: 1, message: "You need to provide a validation key" }); + const offlineKey = await signOfflineKey(validationKey, req.params.licenseKey); if (offlineKey.status !== "VALID") return res.json(offlineKey); @@ -21,7 +28,6 @@ app.get("/:licenseKey/sign", async (req: Request, res: Response) => { res.header("Content-Type", "application/octet-stream") .header("Content-Disposition", `attachment; filename=${req.params.licenseKey}.lkey`) .send(offlineKey.file); - }); export default app; \ No newline at end of file