better-auth
Version:
The most comprehensive authentication framework for TypeScript.
201 lines (200 loc) • 7.83 kB
text/typescript
import { GenericOAuthConfig, GenericOAuthOptions } from "./types.mjs";
import { Auth0Options, auth0 } from "./providers/auth0.mjs";
import { GumroadOptions, gumroad } from "./providers/gumroad.mjs";
import { HubSpotOptions, hubspot } from "./providers/hubspot.mjs";
import { KeycloakOptions, keycloak } from "./providers/keycloak.mjs";
import { LineOptions, line } from "./providers/line.mjs";
import { MicrosoftEntraIdOptions, microsoftEntraId } from "./providers/microsoft-entra-id.mjs";
import { OktaOptions, okta } from "./providers/okta.mjs";
import { PatreonOptions, patreon } from "./providers/patreon.mjs";
import { SlackOptions, slack } from "./providers/slack.mjs";
import { YandexOptions, yandex } from "./providers/yandex.mjs";
import { AuthContext } from "@better-auth/core";
import * as _$_better_auth_core_oauth20 from "@better-auth/core/oauth2";
import { OAuthProvider } from "@better-auth/core/oauth2";
import * as _$_better_auth_core_utils_error_codes0 from "@better-auth/core/utils/error-codes";
import * as _$better_call0 from "better-call";
import * as _$zod from "zod";
import * as _$zod_v4_core0 from "zod/v4/core";
//#region src/plugins/generic-oauth/index.d.ts
declare module "@better-auth/core" {
interface BetterAuthPluginRegistry<AuthOptions, Options> {
"generic-oauth": {
creator: typeof genericOAuth;
};
}
}
/**
* Base type for OAuth provider options.
* Extracts common fields from GenericOAuthConfig and makes clientSecret required.
*/
type BaseOAuthProviderOptions = Omit<Pick<GenericOAuthConfig, "clientId" | "clientSecret" | "scopes" | "redirectURI" | "pkce" | "disableImplicitSignUp" | "disableSignUp" | "overrideUserInfo">, "clientSecret"> & {
/** OAuth client secret (required for provider options) */clientSecret: string;
};
/**
* A generic OAuth plugin that can be used to add OAuth support to any provider
*/
declare const genericOAuth: (options: GenericOAuthOptions) => {
id: "generic-oauth";
version: string;
init: (ctx: AuthContext) => {
context: {
socialProviders: OAuthProvider<Record<string, any>, Partial<_$_better_auth_core_oauth20.ProviderOptions<any>>>[];
};
};
endpoints: {
signInWithOAuth2: _$better_call0.StrictEndpoint<"/sign-in/oauth2", {
method: "POST";
body: _$zod.ZodObject<{
providerId: _$zod.ZodString;
callbackURL: _$zod.ZodOptional<_$zod.ZodString>;
errorCallbackURL: _$zod.ZodOptional<_$zod.ZodString>;
newUserCallbackURL: _$zod.ZodOptional<_$zod.ZodString>;
disableRedirect: _$zod.ZodOptional<_$zod.ZodBoolean>;
scopes: _$zod.ZodOptional<_$zod.ZodArray<_$zod.ZodString>>;
requestSignUp: _$zod.ZodOptional<_$zod.ZodBoolean>;
additionalData: _$zod.ZodOptional<_$zod.ZodRecord<_$zod.ZodString, _$zod.ZodAny>>;
}, _$zod_v4_core0.$strip>;
metadata: {
openapi: {
description: string;
responses: {
200: {
description: string;
content: {
"application/json": {
schema: {
type: "object";
properties: {
url: {
type: string;
};
redirect: {
type: string;
};
};
};
};
};
};
};
};
};
}, {
url: string;
redirect: boolean;
}>;
oAuth2Callback: _$better_call0.StrictEndpoint<"/oauth2/callback/:providerId", {
method: "GET";
query: _$zod.ZodObject<{
code: _$zod.ZodOptional<_$zod.ZodString>;
error: _$zod.ZodOptional<_$zod.ZodString>;
error_description: _$zod.ZodOptional<_$zod.ZodString>;
state: _$zod.ZodOptional<_$zod.ZodString>;
iss: _$zod.ZodOptional<_$zod.ZodString>;
}, _$zod_v4_core0.$strip>;
metadata: {
allowedMediaTypes: string[];
openapi: {
description: string;
responses: {
200: {
description: string;
content: {
"application/json": {
schema: {
type: "object";
properties: {
url: {
type: string;
};
};
};
};
};
};
};
};
scope: "server";
};
}, never>;
oAuth2LinkAccount: _$better_call0.StrictEndpoint<"/oauth2/link", {
method: "POST";
body: _$zod.ZodObject<{
providerId: _$zod.ZodString;
callbackURL: _$zod.ZodString;
scopes: _$zod.ZodOptional<_$zod.ZodArray<_$zod.ZodString>>;
errorCallbackURL: _$zod.ZodOptional<_$zod.ZodString>;
}, _$zod_v4_core0.$strip>;
use: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
session: {
session: Record<string, any> & {
id: string;
createdAt: Date;
updatedAt: Date;
userId: string;
expiresAt: Date;
token: string;
ipAddress?: string | null | undefined;
userAgent?: string | null | undefined;
};
user: Record<string, any> & {
id: string;
createdAt: Date;
updatedAt: Date;
email: string;
emailVerified: boolean;
name: string;
image?: string | null | undefined;
};
};
}>>[];
metadata: {
openapi: {
description: string;
responses: {
"200": {
description: string;
content: {
"application/json": {
schema: {
type: "object";
properties: {
url: {
type: string;
format: string;
description: string;
};
redirect: {
type: string;
description: string;
enum: boolean[];
};
};
required: string[];
};
};
};
};
};
};
};
}, {
url: string;
redirect: boolean;
}>;
};
options: GenericOAuthOptions;
$ERROR_CODES: {
INVALID_OAUTH_CONFIGURATION: _$_better_auth_core_utils_error_codes0.RawError<"INVALID_OAUTH_CONFIGURATION">;
TOKEN_URL_NOT_FOUND: _$_better_auth_core_utils_error_codes0.RawError<"TOKEN_URL_NOT_FOUND">;
PROVIDER_CONFIG_NOT_FOUND: _$_better_auth_core_utils_error_codes0.RawError<"PROVIDER_CONFIG_NOT_FOUND">;
PROVIDER_ID_REQUIRED: _$_better_auth_core_utils_error_codes0.RawError<"PROVIDER_ID_REQUIRED">;
INVALID_OAUTH_CONFIG: _$_better_auth_core_utils_error_codes0.RawError<"INVALID_OAUTH_CONFIG">;
SESSION_REQUIRED: _$_better_auth_core_utils_error_codes0.RawError<"SESSION_REQUIRED">;
ISSUER_MISMATCH: _$_better_auth_core_utils_error_codes0.RawError<"ISSUER_MISMATCH">;
ISSUER_MISSING: _$_better_auth_core_utils_error_codes0.RawError<"ISSUER_MISSING">;
};
};
//#endregion
export { Auth0Options, BaseOAuthProviderOptions, type GenericOAuthConfig, type GenericOAuthOptions, GumroadOptions, HubSpotOptions, KeycloakOptions, LineOptions, MicrosoftEntraIdOptions, OktaOptions, PatreonOptions, SlackOptions, YandexOptions, auth0, genericOAuth, gumroad, hubspot, keycloak, line, microsoftEntraId, okta, patreon, slack, yandex };