TS4023: Exported variable 'auth' has or is using name 'OIDCConfig' from external module "/Users/diegoescobedo/repos/web-app/node_modules/.pnpm/better-auth@1.2.6-beta.2_typescript@5.4.5/node_modules/better-auth/dist/plugins/sso/index" but cannot be named. #955

Closed
opened 2026-03-13 08:11:55 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @diego-escobedo on GitHub (Mar 31, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Simply create a betterAuth instance with the SSO plugin enabled.

import { betterAuth } from "better-auth"
import { sso } from "better-auth/plugins/sso";
 
const auth = betterAuth({
    plugins: [ 
        sso() 
    ] 
})

Current vs. Expected behavior

I would expect the types to work, but instead I get this error that the OIDCConfig cannot be named.

What version of Better Auth are you using?

1.2.6-beta.2

Provide environment information

- OS: MacOS Sequoia 15.3.2
- Typescript: 5.4.5
- Browser: Chrome 134.0.6998.118

Which area(s) are affected? (Select all that apply)

Backend, Client

Auth config (if applicable)

export const auth = betterAuth({
  baseURL: getBaseUrl(),
  secret: serverEnv.BETTER_AUTH_SECRET,
  database: drizzleAdapter(db, {
    provider: "pg",
  }),
  socialProviders: {
    google: {
      clientId: serverEnv.GOOGLE_OAUTH_CLIENT_ID,
      clientSecret: serverEnv.GOOGLE_OAUTH_CLIENT_SECRET,
    },
  },
  basePath: "/api/auth",
  user: {
    fields: {
      emailVerified: "email_verified",
      createdAt: "created_at",
      updatedAt: "updated_at",
      banReason: "ban_reason",
      banExpires: "ban_expires",
    },
  },
  session: {
    modelName: "session",
    fields: {
      expiresAt: "expires_at",
      createdAt: "created_at",
      updatedAt: "updated_at",
      ipAddress: "ip_address",
      userAgent: "user_agent",
      userId: "user_id",
      impersonatedBy: "impersonated_by",
      activeOrganizationId: "active_organization_id",
    },
    expiresIn: 60 * 60 * 24 * 7, // 7 days
    updateAge: 60 * 60 * 24, // 1 day (every 1 day the session expiration is updated)
    cookieCache: {
      enabled: true,
      maxAge: 5 * 60, // Cache duration in seconds
    },
  },
  account: {
    accountLinking: {
      enabled: true,
      trustedProviders: ["google"],
    },
    modelName: "account",
    fields: {
      accountId: "account_id",
      providerId: "provider_id",
      userId: "user_id",
      accessToken: "access_token",
      refreshToken: "refresh_token",
      idToken: "id_token",
      accessTokenExpiresAt: "access_token_expires_at",
      refreshTokenExpiresAt: "refresh_token_expires_at",
      createdAt: "created_at",
      updatedAt: "updated_at",
    },
  },
  verification: {
    modelName: "verification",
    fields: {
      expiresAt: "expires_at",
      createdAt: "created_at",
      updatedAt: "updated_at",
    },
  },
  emailAndPassword: {
    enabled: true,
    disableSignUp: true,
    requireEmailVerification: true,
    sendResetPassword: async ({ user, token }) => {
      await sendResetPasswordEmail({
        user,
        token,
      });
    },
    resetPasswordTokenExpiresIn: 3600,
  },
  plugins: [
    admin({
      adminUserIds: Array.from(INTERNAL_USER_IDS),
    }),
    organization({
      teams: {
        enabled: true,
      },
      allowUserToCreateOrganization: (user) => isInternalUser(user.id),
      sendInvitationEmail: async (data) => {
        await sendInvitationEmail({
          inviterName: data.inviter.user.name,
          inviterEmail: data.inviter.user.email,
          organizationName: data.organization.name,
          invitation: {
            id: data.invitation.id,
            expires_at: data.invitation.expiresAt.toISOString(),
            role: data.invitation.role,
            email: data.email,
          },
        });
      },
      schema: {
        member: {
          modelName: "member",
          fields: {
            userId: "user_id",
            organizationId: "organization_id",
            createdAt: "created_at",
            teamId: "team_id",
          },
        },
        organization: {
          modelName: "organization",
          fields: {
            createdAt: "created_at",
          },
        },
        invitation: {
          modelName: "invitation",
          fields: {
            createdAt: "created_at",
            inviterId: "inviter_id",
            organizationId: "organization_id",
            expiresAt: "expires_at",
          },
        },
        teams: {
          modelName: "team",
          fields: {
            createdAt: "created_at",
            organizationId: "organization_id",
            updatedAt: "updated_at",
          },
        },
        session: {
          modelName: "session",
          fields: {
            activeOrganizationId: "active_organization_id",
          },
        },
      },
    }),
    oAuthProxy(),
    sso({}),
  ],
  advanced: {
    useSecureCookies: serverEnv.NODE_ENV === "production",
    crossSubDomainCookies: {
      enabled: true,
    },
    generateId: false,
  },
});

Additional context

No response

Originally created by @diego-escobedo on GitHub (Mar 31, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Simply create a `betterAuth` instance with the SSO plugin enabled. ``` import { betterAuth } from "better-auth" import { sso } from "better-auth/plugins/sso"; const auth = betterAuth({ plugins: [ sso() ] }) ``` ### Current vs. Expected behavior I would expect the types to work, but instead I get this error that the OIDCConfig cannot be named. ### What version of Better Auth are you using? 1.2.6-beta.2 ### Provide environment information ```bash - OS: MacOS Sequoia 15.3.2 - Typescript: 5.4.5 - Browser: Chrome 134.0.6998.118 ``` ### Which area(s) are affected? (Select all that apply) Backend, Client ### Auth config (if applicable) ```typescript export const auth = betterAuth({ baseURL: getBaseUrl(), secret: serverEnv.BETTER_AUTH_SECRET, database: drizzleAdapter(db, { provider: "pg", }), socialProviders: { google: { clientId: serverEnv.GOOGLE_OAUTH_CLIENT_ID, clientSecret: serverEnv.GOOGLE_OAUTH_CLIENT_SECRET, }, }, basePath: "/api/auth", user: { fields: { emailVerified: "email_verified", createdAt: "created_at", updatedAt: "updated_at", banReason: "ban_reason", banExpires: "ban_expires", }, }, session: { modelName: "session", fields: { expiresAt: "expires_at", createdAt: "created_at", updatedAt: "updated_at", ipAddress: "ip_address", userAgent: "user_agent", userId: "user_id", impersonatedBy: "impersonated_by", activeOrganizationId: "active_organization_id", }, expiresIn: 60 * 60 * 24 * 7, // 7 days updateAge: 60 * 60 * 24, // 1 day (every 1 day the session expiration is updated) cookieCache: { enabled: true, maxAge: 5 * 60, // Cache duration in seconds }, }, account: { accountLinking: { enabled: true, trustedProviders: ["google"], }, modelName: "account", fields: { accountId: "account_id", providerId: "provider_id", userId: "user_id", accessToken: "access_token", refreshToken: "refresh_token", idToken: "id_token", accessTokenExpiresAt: "access_token_expires_at", refreshTokenExpiresAt: "refresh_token_expires_at", createdAt: "created_at", updatedAt: "updated_at", }, }, verification: { modelName: "verification", fields: { expiresAt: "expires_at", createdAt: "created_at", updatedAt: "updated_at", }, }, emailAndPassword: { enabled: true, disableSignUp: true, requireEmailVerification: true, sendResetPassword: async ({ user, token }) => { await sendResetPasswordEmail({ user, token, }); }, resetPasswordTokenExpiresIn: 3600, }, plugins: [ admin({ adminUserIds: Array.from(INTERNAL_USER_IDS), }), organization({ teams: { enabled: true, }, allowUserToCreateOrganization: (user) => isInternalUser(user.id), sendInvitationEmail: async (data) => { await sendInvitationEmail({ inviterName: data.inviter.user.name, inviterEmail: data.inviter.user.email, organizationName: data.organization.name, invitation: { id: data.invitation.id, expires_at: data.invitation.expiresAt.toISOString(), role: data.invitation.role, email: data.email, }, }); }, schema: { member: { modelName: "member", fields: { userId: "user_id", organizationId: "organization_id", createdAt: "created_at", teamId: "team_id", }, }, organization: { modelName: "organization", fields: { createdAt: "created_at", }, }, invitation: { modelName: "invitation", fields: { createdAt: "created_at", inviterId: "inviter_id", organizationId: "organization_id", expiresAt: "expires_at", }, }, teams: { modelName: "team", fields: { createdAt: "created_at", organizationId: "organization_id", updatedAt: "updated_at", }, }, session: { modelName: "session", fields: { activeOrganizationId: "active_organization_id", }, }, }, }), oAuthProxy(), sso({}), ], advanced: { useSecureCookies: serverEnv.NODE_ENV === "production", crossSubDomainCookies: { enabled: true, }, generateId: false, }, }); ``` ### Additional context _No response_
GiteaMirror added the bug label 2026-03-13 08:11:55 -05:00
Author
Owner

@diego-escobedo commented on GitHub (Apr 3, 2025):

Hello,

Have had this issue for a few days and seems to be something inherent to the types. I am blocked on implementing SSO, would appreciate some guidance on how to fix or work around it.

@diego-escobedo commented on GitHub (Apr 3, 2025): Hello, Have had this issue for a few days and seems to be something inherent to the types. I am blocked on implementing SSO, would appreciate some guidance on how to fix or work around it.
Author
Owner

@waml commented on GitHub (Apr 3, 2025):

any update on this same issue is there a work around ?

@waml commented on GitHub (Apr 3, 2025): any update on this same issue is there a work around ?
Author
Owner

@Kinfe123 commented on GitHub (Apr 12, 2025):

have you tried it with latest beta - "better-auth": "1.2.6-beta.12"

@Kinfe123 commented on GitHub (Apr 12, 2025): have you tried it with latest beta - `"better-auth": "1.2.6-beta.12"`
Author
Owner

@diego-escobedo commented on GitHub (Apr 21, 2025):

Works with https://github.com/better-auth/better-auth/releases/tag/v1.2.8-beta.1

@diego-escobedo commented on GitHub (Apr 21, 2025): Works with https://github.com/better-auth/better-auth/releases/tag/v1.2.8-beta.1
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#955