diff --git a/.changeset/gitlab-profile-types.md b/.changeset/gitlab-profile-types.md new file mode 100644 index 0000000000..f1be83a15f --- /dev/null +++ b/.changeset/gitlab-profile-types.md @@ -0,0 +1,5 @@ +--- +"@better-auth/core": minor +--- + +GitLab profile callbacks now accept null profile details and omitted conditional fields, including compute-minute limits on Free instances. Profile mappings must handle these null or missing values. diff --git a/packages/core/src/social-providers/gitlab.test-d.ts b/packages/core/src/social-providers/gitlab.test-d.ts new file mode 100644 index 0000000000..f7bdeccf6b --- /dev/null +++ b/packages/core/src/social-providers/gitlab.test-d.ts @@ -0,0 +1,33 @@ +import { assertType, it } from "vitest"; +import type { GitlabProfile } from "./gitlab"; + +/** + * @see https://docs.gitlab.com/api/users/#retrieve-the-current-user + * @see https://github.com/gitlabhq/gitlabhq/blob/master/lib/api/entities/user_public.rb + */ +it("accepts nullable and conditional GitLab profile fields", () => { + const profileFields = { + location: null, + work_information: null, + public_email: null, + local_time: null, + last_sign_in_at: null, + confirmed_at: null, + theme_id: null, + last_activity_on: null, + current_sign_in_at: null, + shared_runners_minutes_limit: null, + extra_shared_runners_minutes_limit: null, + }; + assertType>(profileFields); + assertType< + Pick< + GitlabProfile, + | "followers" + | "following" + | "skype" + | "shared_runners_minutes_limit" + | "extra_shared_runners_minutes_limit" + > + >({}); +}); diff --git a/packages/core/src/social-providers/gitlab.ts b/packages/core/src/social-providers/gitlab.ts index 595acf9a0d..d816e4ecbc 100644 --- a/packages/core/src/social-providers/gitlab.ts +++ b/packages/core/src/social-providers/gitlab.ts @@ -16,9 +16,9 @@ export interface GitlabProfile extends Record { web_url: string; created_at: string; bio: string; - location?: string | undefined; - public_email: string; - skype: string; + location?: string | null | undefined; + public_email: string | null; + skype?: string; linkedin: string; twitter: string; website_url: string; @@ -26,17 +26,17 @@ export interface GitlabProfile extends Record { job_title: string; pronouns: string; bot: boolean; - work_information?: string | undefined; - followers: number; - following: number; - local_time: string; - last_sign_in_at: string; - confirmed_at: string; - theme_id: number; - last_activity_on: string; + work_information?: string | null | undefined; + followers?: number; + following?: number; + local_time: string | null; + last_sign_in_at: string | null; + confirmed_at: string | null; + theme_id: number | null; + last_activity_on: string | null; color_scheme_id: number; projects_limit: number; - current_sign_in_at: string; + current_sign_in_at: string | null; identities: Array<{ provider: string; extern_uid: string; @@ -47,8 +47,8 @@ export interface GitlabProfile extends Record { external: boolean; private_profile: boolean; commit_email: string; - shared_runners_minutes_limit: number; - extra_shared_runners_minutes_limit: number; + shared_runners_minutes_limit?: number | null; + extra_shared_runners_minutes_limit?: number | null; email_verified?: boolean | undefined; }