Make project defaults reusable
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
import {createHmac} from "node:crypto";
|
||||
import {readFileSync} from "node:fs";
|
||||
|
||||
const baseUrl = "https://f-n8.ru";
|
||||
const [keyId, secret] = readFileSync("/root/ghost-admin-api-key", "utf8").trim().split(":");
|
||||
const baseUrl = (process.env.GHOST_URL || "").replace(/\/$/, "");
|
||||
const keyFile = process.env.GHOST_ADMIN_KEY_FILE || "";
|
||||
if (!baseUrl || !keyFile) {
|
||||
throw new Error("GHOST_URL and GHOST_ADMIN_KEY_FILE are required");
|
||||
}
|
||||
const [keyId, secret] = readFileSync(keyFile, "utf8").trim().split(":");
|
||||
const encode = (value) => Buffer.from(JSON.stringify(value)).toString("base64url");
|
||||
const now = Math.floor(Date.now() / 1000);
|
||||
const unsigned = `${encode({alg: "HS256", typ: "JWT", kid: keyId})}.${encode({iat: now, exp: now + 300, aud: "/admin/"})}`;
|
||||
|
||||
Reference in New Issue
Block a user