mirror of
https://github.com/gnmyt/LicenseAPI.git
synced 2026-01-09 01:31:47 +00:00
Update signing in validate.ts routes
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
import { Request, Response, Router } from "express";
|
import { Request, Response, Router } from "express";
|
||||||
import { validateLicense, signOfflineKey } from "@controller/validation";
|
import {validateLicense, signOfflineKey, signKey} from "@controller/validation";
|
||||||
|
|
||||||
const app: Router = Router();
|
const app: Router = Router();
|
||||||
|
|
||||||
@ -14,6 +14,13 @@ app.get("/:licenseKey/sign", async (req: Request, res: Response) => {
|
|||||||
const validationKey = req.header("X-Validation-Key");
|
const validationKey = req.header("X-Validation-Key");
|
||||||
if (!validationKey) return res.status(400).json({ code: 1, message: "You need to provide a 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);
|
const offlineKey = await signOfflineKey(validationKey, req.params.licenseKey);
|
||||||
|
|
||||||
if (offlineKey.status !== "VALID") return res.json(offlineKey);
|
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")
|
res.header("Content-Type", "application/octet-stream")
|
||||||
.header("Content-Disposition", `attachment; filename=${req.params.licenseKey}.lkey`)
|
.header("Content-Disposition", `attachment; filename=${req.params.licenseKey}.lkey`)
|
||||||
.send(offlineKey.file);
|
.send(offlineKey.file);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default app;
|
export default app;
|
||||||
Reference in New Issue
Block a user