feat: adapt pullfrog for gitea + ollama
This commit is contained in:
+4
-13
@@ -44,18 +44,9 @@ export type GitAuthServer = {
|
||||
[Symbol.asyncDispose]: () => Promise<void>;
|
||||
};
|
||||
|
||||
function revokeGitHubToken(token: string): void {
|
||||
fetch("https://api.github.com/installation/token", {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
Accept: "application/vnd.github+json",
|
||||
"User-Agent": "pullfrog",
|
||||
},
|
||||
}).then(
|
||||
(r) => log.info(`token revocation response: ${r.status}`),
|
||||
() => log.warning("token revocation request failed")
|
||||
);
|
||||
function revokeToken(_token: string): void {
|
||||
// For Gitea personal access tokens / bot tokens, revocation is not needed.
|
||||
log.debug("token revocation skipped (Gitea tokens don't require explicit revocation)");
|
||||
}
|
||||
|
||||
export async function startGitAuthServer(tmpdir: string): Promise<GitAuthServer> {
|
||||
@@ -91,7 +82,7 @@ export async function startGitAuthServer(tmpdir: string): Promise<GitAuthServer>
|
||||
// request for a revoked code — the $git() window has closed, so this
|
||||
// is an agent replaying the code. revoke the token as a precaution.
|
||||
log.info("askpass code used after revoke — revoking token");
|
||||
revokeGitHubToken(entry.token);
|
||||
revokeToken(entry.token);
|
||||
if (entry.timeout) clearTimeout(entry.timeout);
|
||||
codes.delete(code);
|
||||
res.writeHead(409, { "Content-Type": "text/plain" });
|
||||
|
||||
Reference in New Issue
Block a user