From c4ac364c1f061a2b85cf79a2d4db720d2b91e4b5 Mon Sep 17 00:00:00 2001 From: Taesu Date: Sat, 17 Oct 2026 05:51:18 +0900 Subject: [PATCH] fix(github): complete account profile fields --- .changeset/github-profile-types.md | 2 +- .../core/src/social-providers/github.test.ts | 16 +++++++++++++++- packages/core/src/social-providers/github.ts | 6 +++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/.changeset/github-profile-types.md b/.changeset/github-profile-types.md index 420bff1efa..fed07f8c92 100644 --- a/.changeset/github-profile-types.md +++ b/.changeset/github-profile-types.md @@ -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. diff --git a/packages/core/src/social-providers/github.test.ts b/packages/core/src/social-providers/github.test.ts index 0e9471847a..040fdda1e1 100644 --- a/packages/core/src/social-providers/github.test.ts +++ b/packages/core/src/social-providers/github.test.ts @@ -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().toEqualTypeOf< + string | undefined + >(); + expectTypeOf().toEqualTypeOf< + string | null | undefined + >(); + expectTypeOf().toEqualTypeOf< + boolean | undefined + >(); + expectTypeOf().toEqualTypeOf(); +}); diff --git a/packages/core/src/social-providers/github.ts b/packages/core/src/social-providers/github.ts index 62634a2cdd..a146e8d992 100644 --- a/packages/core/src/social-providers/github.ts +++ b/packages/core/src/social-providers/github.ts @@ -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: {