fix(github): complete account profile fields

This commit is contained in:
Taesu
2026-10-17 05:51:18 +09:00
parent 3e7f026c7e
commit c4ac364c1f
3 changed files with 21 additions and 3 deletions
+1 -1
View File
@@ -2,4 +2,4 @@
"@better-auth/core": minor
---
GitHub `getUserInfo` callbacks can now return public or private API profiles without type assertions. Existing profile mappings may need updates for numeric IDs and counters, nullable attributes, and omitted fields.
GitHub profile mappings now accept the documented numeric, nullable, private-account, and enterprise fields. Handle nullable fields and omitted scope-dependent fields in custom mappings.
@@ -1,4 +1,4 @@
import { assertType, describe, expect, it } from "vitest";
import { assertType, describe, expect, expectTypeOf, it } from "vitest";
import type { GithubProfile } from "./github";
import { github } from "./github";
@@ -86,3 +86,17 @@ describe("github profile", () => {
expect(result?.data).toBe(profile);
});
});
/** @see https://docs.github.com/en/rest/users/users#get-the-authenticated-user */
it("types additional GitHub account fields", () => {
expectTypeOf<GithubProfile["user_view_type"]>().toEqualTypeOf<
string | undefined
>();
expectTypeOf<GithubProfile["notification_email"]>().toEqualTypeOf<
string | null | undefined
>();
expectTypeOf<GithubProfile["business_plus"]>().toEqualTypeOf<
boolean | undefined
>();
expectTypeOf<GithubProfile["ldap_dn"]>().toEqualTypeOf<string | undefined>();
});
+5 -1
View File
@@ -47,6 +47,10 @@ export interface GithubProfile {
disk_usage?: number;
collaborators?: number;
two_factor_authentication?: boolean;
user_view_type?: string;
notification_email?: string | null;
business_plus?: boolean;
ldap_dn?: string;
plan?: {
name: string;
space: number;
@@ -153,7 +157,7 @@ export const github = (options: GithubOptions) => {
email: string;
primary: boolean;
verified: boolean;
visibility: "public" | "private";
visibility: "public" | "private" | null;
}[]
>("https://api.github.com/user/emails", {
headers: {