feat: everything
This commit is contained in:
19
src/auth/index.ts
Normal file
19
src/auth/index.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
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";
|
||||
Reference in New Issue
Block a user