export type ValidAuthProvider = "Discord" | "GitHub"; // Can't send the providers across the wire, do this instead export type AuthProviderState = { name: ValidAuthProvider; } & ({ connected: false } | { connected: true; id: string; username: string }); export abstract class AuthProvider { protected readonly accessToken: string; constructor(accessToken: string) { this.accessToken = accessToken; } abstract isPermitted(): Promise; abstract getId(): Promise; // this difference only really matters for discordd // display name: // - discord: username // - github: username // username: // - discord: username#discriminator // - github: username abstract getDisplayName(): Promise; abstract getUsername(): Promise; // these two aren't null for github abstract getAvatar(): Promise; abstract getEmail(): Promise; static get redirectUri(): string { throw new Error("Not implemented"); } }