Implement the official OAuth login flows natively (ported from pi-ai's reference): GitHub Copilot device-code, GPT account (ChatGPT Codex) and Google Antigravity authorization-code + PKCE via a loopback callback server. Obtained credentials are stored as JSON through the existing secret vault. Onboarding and Settings now run the real sign-in instead of pasting an access token.
14 lines
411 B
TypeScript
14 lines
411 B
TypeScript
import { createHash, randomBytes } from "node:crypto";
|
|
|
|
export interface PkcePair {
|
|
verifier: string;
|
|
challenge: string;
|
|
}
|
|
|
|
/** Generate a PKCE verifier and its S256 challenge (RFC 7636). */
|
|
export function generatePkce(): PkcePair {
|
|
const verifier = randomBytes(32).toString("base64url");
|
|
const challenge = createHash("sha256").update(verifier).digest("base64url");
|
|
return { verifier, challenge };
|
|
}
|