MCPcopy Create free account
hub / github.com/pollinations/pollinations / mintAppJwt

Function mintAppJwt

shared/github/app-auth.ts:135–149  ·  view source on GitHub ↗

Mint a short-lived App JWT (valid ~9 min, iat backdated for clock skew).

(creds: GithubAppCredentials)

Source from the content-addressed store, hash-verified

133
134/** Mint a short-lived App JWT (valid ~9 min, iat backdated for clock skew). */
135async function mintAppJwt(creds: GithubAppCredentials): Promise<string> {
136 const key = await importSigningKey(creds.privateKey);
137 const nowSec = Math.floor(Date.now() / 1000);
138 const header = { alg: "RS256", typ: "JWT" };
139 const payload = { iat: nowSec - 60, exp: nowSec + 540, iss: creds.appId };
140 const signingInput = `${b64urlFromString(JSON.stringify(header))}.${b64urlFromString(
141 JSON.stringify(payload),
142 )}`;
143 const sig = await crypto.subtle.sign(
144 "RSASSA-PKCS1-v1_5",
145 key,
146 new TextEncoder().encode(signingInput),
147 );
148 return `${signingInput}.${b64urlFromBytes(new Uint8Array(sig))}`;
149}
150
151async function appJsonGet<T>(path: string, jwt: string): Promise<T> {
152 const res = await fetch(`${GITHUB_API}${path}`, {

Callers 1

getInstallationTokenFunction · 0.85

Calls 4

importSigningKeyFunction · 0.85
b64urlFromStringFunction · 0.85
b64urlFromBytesFunction · 0.85
stringifyMethod · 0.80

Tested by

no test coverage detected