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