mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-10-02 08:33:16 +00:00
17 lines
360 B
TypeScript
17 lines
360 B
TypeScript
|
|
import * as jwt from "jsonwebtoken";
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Generates a JWT for GitHub App authentication
|
||
|
|
*/
|
||
|
|
export function generateJWT(appId: string, privateKey: string): string {
|
||
|
|
const now = Math.floor(Date.now() / 1000);
|
||
|
|
|
||
|
|
const payload = {
|
||
|
|
iat: now,
|
||
|
|
exp: now + 10 * 60,
|
||
|
|
iss: appId,
|
||
|
|
};
|
||
|
|
|
||
|
|
return jwt.sign(payload, privateKey, { algorithm: "RS256" });
|
||
|
|
}
|