20 lines
511 B
TypeScript
20 lines
511 B
TypeScript
import type { X3Config } from "../types/index.js";
|
|
import { generateJWT } from "./jwt.js";
|
|
|
|
export async function getAuthHeaders(
|
|
config: X3Config,
|
|
): Promise<Record<string, string>> {
|
|
const headers: Record<string, string> = {
|
|
"Content-Type": "application/json",
|
|
};
|
|
|
|
if (config.mode === "authenticated") {
|
|
headers["Authorization"] = `Bearer ${await generateJWT(config)}`;
|
|
headers["x-xtrem-endpoint"] = config.endpoint ?? "";
|
|
}
|
|
|
|
return headers;
|
|
}
|
|
|
|
export { generateJWT } from "./jwt.js";
|