open-swe/packages/shared/src/jwt.ts

17 lines
360 B
TypeScript
Raw Normal View History

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" });
}