mirror of
https://github.com/better-auth/better-auth.git
synced 2026-10-22 15:59:56 -05:00
feat: expose plugin version (#8750)
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
import type { BetterAuthClientPlugin } from "@better-auth/core";
|
||||
import type { apiKey } from ".";
|
||||
import { API_KEY_ERROR_CODES } from "./error-codes";
|
||||
import { PACKAGE_VERSION } from "./version";
|
||||
|
||||
export * from "./error-codes";
|
||||
|
||||
export const apiKeyClient = () => {
|
||||
return {
|
||||
id: "api-key",
|
||||
version: PACKAGE_VERSION,
|
||||
$InferServerPlugin: {} as ReturnType<typeof apiKey>,
|
||||
pathMethods: {
|
||||
"/api-key/create": "POST",
|
||||
|
||||
@@ -13,6 +13,7 @@ import { validateApiKey } from "./routes/verify-api-key";
|
||||
import { apiKeySchema } from "./schema";
|
||||
import type { ApiKeyConfigurationOptions, ApiKeyOptions } from "./types";
|
||||
import { getDate, getIp } from "./utils";
|
||||
import { PACKAGE_VERSION } from "./version";
|
||||
|
||||
declare module "@better-auth/core" {
|
||||
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
||||
@@ -162,6 +163,7 @@ export function apiKey(
|
||||
|
||||
return {
|
||||
id: "api-key",
|
||||
version: PACKAGE_VERSION,
|
||||
$ERROR_CODES: API_KEY_ERROR_CODES,
|
||||
hooks: {
|
||||
before: [
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import pkg from "../package.json" with { type: "json" };
|
||||
|
||||
export const PACKAGE_VERSION = pkg.version;
|
||||
@@ -3,7 +3,7 @@
|
||||
"compilerOptions": {
|
||||
"lib": ["esnext", "dom", "dom.iterable"]
|
||||
},
|
||||
"include": ["./src"],
|
||||
"include": ["./src", "./package.json"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../core/tsconfig.json"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"outDir": "${configDir}/node_modules/.cache/ts/test-out",
|
||||
"tsBuildInfoFile": "${configDir}/node_modules/.cache/ts/test-tsbuildinfo"
|
||||
},
|
||||
"include": ["./test", "./src"],
|
||||
"include": ["./test", "./src", "./package.json"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../better-auth/tsconfig.json"
|
||||
|
||||
@@ -3,6 +3,7 @@ import type {
|
||||
BetterAuthOptions,
|
||||
BetterAuthPlugin,
|
||||
} from "@better-auth/core";
|
||||
import { PACKAGE_VERSION } from "../version";
|
||||
|
||||
export * from "./broadcast-channel";
|
||||
export {
|
||||
@@ -24,6 +25,7 @@ export * from "./vanilla";
|
||||
export const InferPlugin = <T extends BetterAuthPlugin>() => {
|
||||
return {
|
||||
id: "infer-server-plugin",
|
||||
version: PACKAGE_VERSION,
|
||||
$InferServerPlugin: {} as T,
|
||||
} satisfies BetterAuthClientPlugin;
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@ import type {
|
||||
BetterAuthClientPlugin,
|
||||
BetterAuthOptions,
|
||||
} from "@better-auth/core";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
|
||||
export const InferServerPlugin = <
|
||||
AuthOrOption extends
|
||||
@@ -22,6 +23,7 @@ export const InferServerPlugin = <
|
||||
: never;
|
||||
return {
|
||||
id: "infer-server-plugin",
|
||||
version: PACKAGE_VERSION,
|
||||
$InferServerPlugin: {} as Plugin,
|
||||
} satisfies BetterAuthClientPlugin;
|
||||
};
|
||||
|
||||
@@ -5,10 +5,12 @@ import type {
|
||||
import { createAuthEndpoint } from "@better-auth/core/api";
|
||||
import { atom, computed } from "nanostores";
|
||||
import * as z from "zod";
|
||||
import { PACKAGE_VERSION } from "../version";
|
||||
import { useAuthQuery } from "./query";
|
||||
|
||||
const serverPlugin = {
|
||||
id: "test",
|
||||
version: PACKAGE_VERSION,
|
||||
endpoints: {
|
||||
test: createAuthEndpoint(
|
||||
"/test",
|
||||
@@ -120,6 +122,7 @@ export const testClientPlugin = () => {
|
||||
});
|
||||
return {
|
||||
id: "test" as const,
|
||||
version: PACKAGE_VERSION,
|
||||
getActions($fetch) {
|
||||
return {
|
||||
setTestAtom(value: boolean) {
|
||||
@@ -163,6 +166,7 @@ export const testClientPlugin2 = () => {
|
||||
});
|
||||
return {
|
||||
id: "test",
|
||||
version: PACKAGE_VERSION,
|
||||
getAtoms($fetch) {
|
||||
return {
|
||||
$test2,
|
||||
@@ -190,6 +194,7 @@ export const testClientPlugin2 = () => {
|
||||
export const testDeepMergePluginA = () => {
|
||||
return {
|
||||
id: "test-deep-merge-a",
|
||||
version: PACKAGE_VERSION,
|
||||
getActions() {
|
||||
return {
|
||||
signIn: {
|
||||
@@ -203,6 +208,7 @@ export const testDeepMergePluginA = () => {
|
||||
export const testDeepMergePluginB = () => {
|
||||
return {
|
||||
id: "test-deep-merge-b",
|
||||
version: PACKAGE_VERSION,
|
||||
getActions() {
|
||||
return {
|
||||
signIn: {
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { BetterAuthPlugin } from "@better-auth/core";
|
||||
import { createAuthMiddleware } from "@better-auth/core/api";
|
||||
import { setShouldSkipSessionRefresh } from "../api/state/should-session-refresh";
|
||||
import { parseSetCookieHeader } from "../cookies";
|
||||
import { PACKAGE_VERSION } from "../version";
|
||||
|
||||
export function toNextJsHandler(
|
||||
auth:
|
||||
@@ -25,6 +26,7 @@ export function toNextJsHandler(
|
||||
export const nextCookies = () => {
|
||||
return {
|
||||
id: "next-cookies",
|
||||
version: PACKAGE_VERSION,
|
||||
hooks: {
|
||||
before: [
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@ import { createAuthMiddleware } from "@better-auth/core/api";
|
||||
import type { RequestEvent } from "@sveltejs/kit";
|
||||
import { parseSetCookieHeader } from "../cookies";
|
||||
import type { BetterAuthOptions, BetterAuthPlugin } from "../types";
|
||||
import { PACKAGE_VERSION } from "../version";
|
||||
|
||||
export const toSvelteKitHandler = (auth: {
|
||||
handler: (request: Request) => Response | Promise<Response>;
|
||||
@@ -58,6 +59,7 @@ export const sveltekitCookies = (
|
||||
) => {
|
||||
return {
|
||||
id: "sveltekit-cookies",
|
||||
version: PACKAGE_VERSION,
|
||||
hooks: {
|
||||
after: [
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { BetterAuthPlugin } from "@better-auth/core";
|
||||
import { createAuthMiddleware } from "@better-auth/core/api";
|
||||
import { parseSetCookieHeader } from "../cookies";
|
||||
import { PACKAGE_VERSION } from "../version";
|
||||
|
||||
/**
|
||||
* TanStack Start cookie plugin for Solid.js.
|
||||
@@ -22,6 +23,7 @@ import { parseSetCookieHeader } from "../cookies";
|
||||
export const tanstackStartCookies = () => {
|
||||
return {
|
||||
id: "tanstack-start-cookies-solid",
|
||||
version: PACKAGE_VERSION,
|
||||
hooks: {
|
||||
after: [
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { BetterAuthPlugin } from "@better-auth/core";
|
||||
import { createAuthMiddleware } from "@better-auth/core/api";
|
||||
import { parseSetCookieHeader } from "../cookies";
|
||||
import { PACKAGE_VERSION } from "../version";
|
||||
|
||||
/**
|
||||
* TanStack Start cookie plugin for React.
|
||||
@@ -22,6 +23,7 @@ import { parseSetCookieHeader } from "../cookies";
|
||||
export const tanstackStartCookies = () => {
|
||||
return {
|
||||
id: "tanstack-start-cookies",
|
||||
version: PACKAGE_VERSION,
|
||||
hooks: {
|
||||
after: [
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ import type {
|
||||
BetterAuthPlugin,
|
||||
} from "@better-auth/core";
|
||||
import type { DBFieldAttribute } from "@better-auth/core/db";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
|
||||
export const inferAdditionalFields = <
|
||||
T,
|
||||
@@ -45,6 +46,7 @@ export const inferAdditionalFields = <
|
||||
}
|
||||
? {
|
||||
id: "additional-fields-client";
|
||||
version: string;
|
||||
schema: {
|
||||
user: {
|
||||
fields: S["user"] extends object ? S["user"] : {};
|
||||
@@ -58,6 +60,7 @@ export const inferAdditionalFields = <
|
||||
: Opts extends BetterAuthOptions
|
||||
? {
|
||||
id: "additional-fields";
|
||||
version: string;
|
||||
schema: {
|
||||
user: {
|
||||
fields: Opts["user"] extends {
|
||||
@@ -79,6 +82,7 @@ export const inferAdditionalFields = <
|
||||
|
||||
return {
|
||||
id: "additional-fields-client",
|
||||
version: PACKAGE_VERSION,
|
||||
$InferServerPlugin: {} as Plugin extends BetterAuthPlugin
|
||||
? Plugin
|
||||
: undefined,
|
||||
|
||||
@@ -3,6 +3,7 @@ import { createAuthMiddleware } from "@better-auth/core/api";
|
||||
import { APIError, BetterAuthError } from "@better-auth/core/error";
|
||||
import { mergeSchema } from "../../db/schema";
|
||||
import { getEndpointResponse } from "../../utils/plugin-helper";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import { defaultRoles } from "./access";
|
||||
import { ADMIN_ERROR_CODES } from "./error-codes";
|
||||
import {
|
||||
@@ -69,6 +70,7 @@ export const admin = <O extends AdminOptions>(options?: O | undefined) => {
|
||||
|
||||
return {
|
||||
id: "admin",
|
||||
version: PACKAGE_VERSION,
|
||||
init() {
|
||||
return {
|
||||
options: {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { BetterAuthClientPlugin } from "@better-auth/core";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import type { AccessControl, ArrayElement, Role } from "../access";
|
||||
import type { defaultStatements } from "./access";
|
||||
import { adminAc, userAc } from "./access";
|
||||
@@ -42,6 +43,7 @@ export const adminClient = <O extends AdminClientOptions>(
|
||||
|
||||
return {
|
||||
id: "admin-client",
|
||||
version: PACKAGE_VERSION,
|
||||
$InferServerPlugin: {} as ReturnType<
|
||||
typeof admin<{
|
||||
ac: O["ac"] extends AccessControl
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import type { BetterAuthClientPlugin } from "@better-auth/core";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import type { anonymous } from ".";
|
||||
import { ANONYMOUS_ERROR_CODES } from "./error-codes";
|
||||
|
||||
export const anonymousClient = () => {
|
||||
return {
|
||||
id: "anonymous",
|
||||
version: PACKAGE_VERSION,
|
||||
$InferServerPlugin: {} as ReturnType<typeof anonymous>,
|
||||
pathMethods: {
|
||||
"/sign-in/anonymous": "POST",
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
setSessionCookie,
|
||||
} from "../../cookies";
|
||||
import { mergeSchema, parseUserOutput } from "../../db/schema";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import { ANONYMOUS_ERROR_CODES } from "./error-codes";
|
||||
import { schema } from "./schema";
|
||||
import type {
|
||||
@@ -58,6 +59,7 @@ async function getAnonUserEmail(
|
||||
export const anonymous = (options?: AnonymousOptions | undefined) => {
|
||||
return {
|
||||
id: "anonymous",
|
||||
version: PACKAGE_VERSION,
|
||||
endpoints: {
|
||||
signInAnonymous: createAuthEndpoint(
|
||||
"/sign-in/anonymous",
|
||||
|
||||
@@ -3,6 +3,7 @@ import { createAuthMiddleware } from "@better-auth/core/api";
|
||||
import { createHMAC } from "@better-auth/utils/hmac";
|
||||
import { serializeSignedCookie } from "better-call";
|
||||
import { parseSetCookieHeader } from "../../cookies";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
|
||||
declare module "@better-auth/core" {
|
||||
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
||||
@@ -40,6 +41,7 @@ function tryDecode(str: string): string {
|
||||
export const bearer = (options?: BearerOptions | undefined) => {
|
||||
return {
|
||||
id: "bearer",
|
||||
version: PACKAGE_VERSION,
|
||||
hooks: {
|
||||
before: [
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { BetterAuthPlugin } from "@better-auth/core";
|
||||
import { getIp } from "../../utils/get-request-ip";
|
||||
import { middlewareResponse } from "../../utils/middleware-response";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import { defaultEndpoints, Providers, siteVerifyMap } from "./constants";
|
||||
import { EXTERNAL_ERROR_CODES, INTERNAL_ERROR_CODES } from "./error-codes";
|
||||
import type { CaptchaOptions } from "./types";
|
||||
@@ -20,6 +21,7 @@ export type * from "./types";
|
||||
export const captcha = (options: CaptchaOptions) =>
|
||||
({
|
||||
id: "captcha",
|
||||
version: PACKAGE_VERSION,
|
||||
$ERROR_CODES: EXTERNAL_ERROR_CODES,
|
||||
onRequest: async (request, ctx) => {
|
||||
try {
|
||||
|
||||
@@ -12,6 +12,7 @@ import * as z from "zod";
|
||||
import { getSession } from "../../api";
|
||||
import { parseSetCookieHeader } from "../../cookies/cookie-utils";
|
||||
import { getEndpointResponse } from "../../utils/plugin-helper";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
|
||||
declare module "@better-auth/core" {
|
||||
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
||||
@@ -68,6 +69,7 @@ export const customSession = <
|
||||
) => {
|
||||
return {
|
||||
id: "custom-session",
|
||||
version: PACKAGE_VERSION,
|
||||
hooks: {
|
||||
after: [
|
||||
{
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import type { BetterAuthClientPlugin } from "@better-auth/core";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import type { deviceAuthorization } from ".";
|
||||
|
||||
export const deviceAuthorizationClient = () => {
|
||||
return {
|
||||
id: "device-authorization",
|
||||
version: PACKAGE_VERSION,
|
||||
$InferServerPlugin: {} as ReturnType<typeof deviceAuthorization>,
|
||||
pathMethods: {
|
||||
"/device/code": "POST",
|
||||
|
||||
@@ -4,6 +4,7 @@ import { mergeSchema } from "../../db";
|
||||
import type { InferOptionSchema } from "../../types/plugins";
|
||||
import type { TimeString } from "../../utils/time";
|
||||
import { ms } from "../../utils/time";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import { DEVICE_AUTHORIZATION_ERROR_CODES } from "./error-codes";
|
||||
import {
|
||||
deviceApprove,
|
||||
@@ -132,6 +133,7 @@ export const deviceAuthorization = (
|
||||
|
||||
return {
|
||||
id: "device-authorization",
|
||||
version: PACKAGE_VERSION,
|
||||
schema: mergeSchema(schema, options?.schema),
|
||||
endpoints: {
|
||||
deviceCode: deviceCode(opts),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { BetterAuthClientPlugin } from "@better-auth/core";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import type { emailOTP } from ".";
|
||||
|
||||
import { EMAIL_OTP_ERROR_CODES } from "./error-codes";
|
||||
|
||||
export * from "./error-codes";
|
||||
@@ -8,6 +8,7 @@ export * from "./error-codes";
|
||||
export const emailOTPClient = () => {
|
||||
return {
|
||||
id: "email-otp",
|
||||
version: PACKAGE_VERSION,
|
||||
$InferServerPlugin: {} as ReturnType<typeof emailOTP>,
|
||||
atomListeners: [
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ import { createAuthMiddleware } from "@better-auth/core/api";
|
||||
import { generateRandomString } from "../../crypto";
|
||||
import { getDate } from "../../utils/date";
|
||||
import { getEndpointResponse } from "../../utils/plugin-helper";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import { EMAIL_OTP_ERROR_CODES } from "./error-codes";
|
||||
import { storeOTP } from "./otp-token";
|
||||
import {
|
||||
@@ -46,6 +47,7 @@ export const emailOTP = (options: EmailOTPOptions) => {
|
||||
|
||||
return {
|
||||
id: "email-otp",
|
||||
version: PACKAGE_VERSION,
|
||||
init(ctx) {
|
||||
if (!opts.overrideDefaultEmailVerification) {
|
||||
return;
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import type { BetterAuthClientPlugin } from "@better-auth/core";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import type { genericOAuth } from ".";
|
||||
import { GENERIC_OAUTH_ERROR_CODES } from "./error-codes";
|
||||
|
||||
export const genericOAuthClient = () => {
|
||||
return {
|
||||
id: "generic-oauth-client",
|
||||
version: PACKAGE_VERSION,
|
||||
$InferServerPlugin: {} as ReturnType<typeof genericOAuth>,
|
||||
$ERROR_CODES: GENERIC_OAUTH_ERROR_CODES,
|
||||
} satisfies BetterAuthClientPlugin;
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
validateAuthorizationCode,
|
||||
} from "@better-auth/core/oauth2";
|
||||
import { betterFetch } from "@better-fetch/fetch";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import { GENERIC_OAUTH_ERROR_CODES } from "./error-codes";
|
||||
import {
|
||||
getUserInfo,
|
||||
@@ -72,6 +73,7 @@ export const genericOAuth = (options: GenericOAuthOptions) => {
|
||||
|
||||
return {
|
||||
id: "generic-oauth",
|
||||
version: PACKAGE_VERSION,
|
||||
init: (ctx: AuthContext) => {
|
||||
const genericProviders = options.config.map((c) => {
|
||||
let finalUserInfoUrl = c.userInfoUrl;
|
||||
|
||||
@@ -5,6 +5,7 @@ import { createHash } from "@better-auth/utils/hash";
|
||||
import { betterFetch } from "@better-fetch/fetch";
|
||||
import { APIError } from "../../api";
|
||||
import { isAPIError } from "../../utils/is-api-error";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
|
||||
declare module "@better-auth/core" {
|
||||
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
||||
@@ -93,6 +94,7 @@ export const haveIBeenPwned = (options?: HaveIBeenPwnedOptions | undefined) => {
|
||||
|
||||
return {
|
||||
id: "have-i-been-pwned",
|
||||
version: PACKAGE_VERSION,
|
||||
init(ctx) {
|
||||
const originalHash = ctx.password.hash;
|
||||
return {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { BetterAuthClientPlugin } from "@better-auth/core";
|
||||
import type { JSONWebKeySet } from "jose";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import type { jwt } from "./index";
|
||||
|
||||
interface JwtClientOptions {
|
||||
@@ -19,6 +20,7 @@ export const jwtClient = (options?: JwtClientOptions) => {
|
||||
|
||||
return {
|
||||
id: "better-auth-client",
|
||||
version: PACKAGE_VERSION,
|
||||
$InferServerPlugin: {} as ReturnType<typeof jwt>,
|
||||
pathMethods: {
|
||||
[jwksPath]: "GET",
|
||||
|
||||
@@ -8,6 +8,7 @@ import type { JSONWebKeySet, JWTPayload } from "jose";
|
||||
import * as z from "zod";
|
||||
import { APIError, sessionMiddleware } from "../../api";
|
||||
import { mergeSchema } from "../../db/schema";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import { getJwksAdapter } from "./adapter";
|
||||
import { schema } from "./schema";
|
||||
import { getJwtToken, signJWT } from "./sign";
|
||||
@@ -67,6 +68,7 @@ export const jwt = <O extends JwtOptions>(options?: O) => {
|
||||
|
||||
return {
|
||||
id: "jwt",
|
||||
version: PACKAGE_VERSION,
|
||||
options: options as NoInfer<O>,
|
||||
endpoints: {
|
||||
getJwks: createAuthEndpoint(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { BetterAuthClientPlugin } from "@better-auth/core";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
|
||||
/**
|
||||
* Configuration for the client-side last login method plugin
|
||||
@@ -33,6 +34,7 @@ export const lastLoginMethodClient = (
|
||||
|
||||
return {
|
||||
id: "last-login-method-client",
|
||||
version: PACKAGE_VERSION,
|
||||
getActions() {
|
||||
return {
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,7 @@ import type {
|
||||
GenericEndpointContext,
|
||||
} from "@better-auth/core";
|
||||
import { createAuthMiddleware } from "@better-auth/core/api";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
|
||||
declare module "@better-auth/core" {
|
||||
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
||||
@@ -95,6 +96,7 @@ export const lastLoginMethod = <O extends LastLoginMethodOptions>(
|
||||
|
||||
return {
|
||||
id: "last-login-method",
|
||||
version: PACKAGE_VERSION,
|
||||
init(ctx) {
|
||||
return {
|
||||
options: {
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import type { BetterAuthClientPlugin } from "@better-auth/core";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import type { magicLink } from ".";
|
||||
|
||||
export const magicLinkClient = () => {
|
||||
return {
|
||||
id: "magic-link",
|
||||
version: PACKAGE_VERSION,
|
||||
$InferServerPlugin: {} as ReturnType<typeof magicLink>,
|
||||
} satisfies BetterAuthClientPlugin;
|
||||
};
|
||||
|
||||
@@ -9,6 +9,7 @@ import { originCheck } from "../../api";
|
||||
import { setSessionCookie } from "../../cookies";
|
||||
import { generateRandomString } from "../../crypto";
|
||||
import { parseSessionOutput, parseUserOutput } from "../../db";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import { defaultKeyHasher } from "./utils";
|
||||
|
||||
declare module "@better-auth/core" {
|
||||
@@ -168,6 +169,7 @@ export const magicLink = (options: MagicLinkOptions) => {
|
||||
|
||||
return {
|
||||
id: "magic-link",
|
||||
version: PACKAGE_VERSION,
|
||||
endpoints: {
|
||||
/**
|
||||
* ### Endpoint
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
isDynamicBaseURLConfig,
|
||||
resolveBaseURL,
|
||||
} from "../../utils/url";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import type {
|
||||
Client,
|
||||
CodeVerificationValue,
|
||||
@@ -192,6 +193,7 @@ export const mcp = (options: MCPOptions) => {
|
||||
const provider = oidcProvider(opts);
|
||||
return {
|
||||
id: "mcp",
|
||||
version: PACKAGE_VERSION,
|
||||
hooks: {
|
||||
after: [
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { BetterAuthClientPlugin } from "@better-auth/core";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import type { multiSession } from ".";
|
||||
import { MULTI_SESSION_ERROR_CODES } from "./error-codes";
|
||||
|
||||
@@ -7,6 +8,7 @@ export * from "./error-codes";
|
||||
export const multiSessionClient = () => {
|
||||
return {
|
||||
id: "multi-session",
|
||||
version: PACKAGE_VERSION,
|
||||
$InferServerPlugin: {} as ReturnType<typeof multiSession>,
|
||||
atomListeners: [
|
||||
{
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
setSessionCookie,
|
||||
} from "../../cookies";
|
||||
import { parseSessionOutput, parseUserOutput } from "../../db/schema";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
|
||||
declare module "@better-auth/core" {
|
||||
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
||||
@@ -58,6 +59,7 @@ export const multiSession = (options?: MultiSessionConfig | undefined) => {
|
||||
|
||||
return {
|
||||
id: "multi-session",
|
||||
version: PACKAGE_VERSION,
|
||||
endpoints: {
|
||||
/**
|
||||
* ### Endpoint
|
||||
|
||||
@@ -19,6 +19,7 @@ import type { StateData } from "../../state";
|
||||
import { parseGenericState } from "../../state";
|
||||
import type { Account, User } from "../../types";
|
||||
import { getOrigin } from "../../utils/url";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import {
|
||||
checkSkipProxy,
|
||||
redirectOnError,
|
||||
@@ -126,6 +127,7 @@ export const oAuthProxy = <O extends OAuthProxyOptions>(opts?: O) => {
|
||||
|
||||
return {
|
||||
id: "oauth-proxy",
|
||||
version: PACKAGE_VERSION,
|
||||
options: opts as NoInfer<O>,
|
||||
endpoints: {
|
||||
oAuthProxy: createAuthEndpoint(
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import type { BetterAuthClientPlugin } from "@better-auth/core";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import type { oidcProvider } from ".";
|
||||
|
||||
export const oidcClient = () => {
|
||||
return {
|
||||
id: "oidc-client",
|
||||
version: PACKAGE_VERSION,
|
||||
$InferServerPlugin: {} as ReturnType<typeof oidcProvider>,
|
||||
} satisfies BetterAuthClientPlugin;
|
||||
};
|
||||
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
} from "../../crypto";
|
||||
import { mergeSchema } from "../../db";
|
||||
import { HIDE_METADATA } from "../../utils";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import { getJwtToken, verifyJWT } from "../jwt";
|
||||
import { authorize } from "./authorize";
|
||||
import type { OAuthApplication } from "./schema";
|
||||
@@ -381,6 +382,7 @@ export const oidcProvider = (options: OIDCOptions) => {
|
||||
|
||||
return {
|
||||
id: "oidc-provider",
|
||||
version: PACKAGE_VERSION,
|
||||
hooks: {
|
||||
after: [
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ import type {
|
||||
BetterAuthClientPlugin,
|
||||
ClientFetchOption,
|
||||
} from "@better-auth/core";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
@@ -192,6 +193,7 @@ const noRetryReasons = {
|
||||
export const oneTapClient = (options: GoogleOneTapOptions) => {
|
||||
return {
|
||||
id: "one-tap",
|
||||
version: PACKAGE_VERSION,
|
||||
fetchPlugins: [
|
||||
{
|
||||
id: "fedcm-signout-handle",
|
||||
|
||||
@@ -6,6 +6,7 @@ import { APIError } from "../../api";
|
||||
import { setSessionCookie } from "../../cookies";
|
||||
import { parseUserOutput } from "../../db/schema";
|
||||
import { toBoolean } from "../../utils/boolean";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
|
||||
declare module "@better-auth/core" {
|
||||
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
||||
@@ -41,6 +42,7 @@ const oneTapCallbackBodySchema = z.object({
|
||||
export const oneTap = (options?: OneTapOptions | undefined) =>
|
||||
({
|
||||
id: "one-tap",
|
||||
version: PACKAGE_VERSION,
|
||||
endpoints: {
|
||||
oneTapCallback: createAuthEndpoint(
|
||||
"/one-tap/callback",
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import type { BetterAuthClientPlugin } from "@better-auth/core";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import type { oneTimeToken } from "./index";
|
||||
|
||||
export const oneTimeTokenClient = () => {
|
||||
return {
|
||||
id: "one-time-token",
|
||||
version: PACKAGE_VERSION,
|
||||
$InferServerPlugin: {} as ReturnType<typeof oneTimeToken>,
|
||||
} satisfies BetterAuthClientPlugin;
|
||||
};
|
||||
|
||||
@@ -11,6 +11,7 @@ import { sessionMiddleware } from "../../api";
|
||||
import { setSessionCookie } from "../../cookies";
|
||||
import { generateRandomString } from "../../crypto";
|
||||
import type { Session, User } from "../../types";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import { defaultKeyHasher } from "./utils";
|
||||
|
||||
declare module "@better-auth/core" {
|
||||
@@ -116,6 +117,7 @@ export const oneTimeToken = (options?: OneTimeTokenOptions | undefined) => {
|
||||
|
||||
return {
|
||||
id: "one-time-token",
|
||||
version: PACKAGE_VERSION,
|
||||
endpoints: {
|
||||
/**
|
||||
* ### Endpoint
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { BetterAuthPlugin, LiteralString } from "@better-auth/core";
|
||||
import { createAuthEndpoint } from "@better-auth/core/api";
|
||||
import { APIError } from "../../api";
|
||||
import { HIDE_METADATA } from "../../utils";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import { generator } from "./generator";
|
||||
import { logo } from "./logo";
|
||||
|
||||
@@ -102,6 +103,7 @@ export const openAPI = <O extends OpenAPIOptions>(options?: O | undefined) => {
|
||||
const path = options?.path ?? "/reference";
|
||||
return {
|
||||
id: "open-api",
|
||||
version: PACKAGE_VERSION,
|
||||
endpoints: {
|
||||
generateOpenAPISchema: createAuthEndpoint(
|
||||
"/open-api/generate-schema",
|
||||
|
||||
@@ -11,6 +11,7 @@ import type {
|
||||
} from "../../plugins/organization/schema";
|
||||
import type { BetterAuthOptions, BetterAuthPlugin } from "../../types";
|
||||
import type { Prettify } from "../../types/helper";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import type { AccessControl, ArrayElement, Role } from "../access";
|
||||
import type { defaultStatements } from "./access";
|
||||
import { adminAc, defaultRoles, memberAc, ownerAc } from "./access";
|
||||
@@ -124,6 +125,7 @@ export const organizationClient = <CO extends OrganizationClientOptions>(
|
||||
type Schema = CO["schema"];
|
||||
return {
|
||||
id: "organization",
|
||||
version: PACKAGE_VERSION,
|
||||
$InferServerPlugin: {} as OrganizationPlugin<{
|
||||
ac: CO["ac"] extends AccessControl
|
||||
? CO["ac"]
|
||||
|
||||
@@ -5,6 +5,7 @@ import { APIError } from "@better-auth/core/error";
|
||||
import * as z from "zod";
|
||||
import { getSessionFromCtx } from "../../api";
|
||||
import { shimContext } from "../../utils/shim";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import type { AccessControl, ArrayElement } from "../access";
|
||||
import type { defaultStatements } from "./access";
|
||||
import { defaultRoles } from "./access";
|
||||
@@ -81,6 +82,7 @@ export type { OrganizationOptions } from "./types";
|
||||
|
||||
export type DefaultOrganizationPlugin<Options extends OrganizationOptions> = {
|
||||
id: "organization";
|
||||
version: string;
|
||||
endpoints: OrganizationEndpoints<Options>;
|
||||
schema: OrganizationSchema<Options>;
|
||||
$Infer: {
|
||||
@@ -292,6 +294,7 @@ const createHasPermission = <O extends OrganizationOptions>(options: O) => {
|
||||
|
||||
export type OrganizationPlugin<O extends OrganizationOptions> = {
|
||||
id: "organization";
|
||||
version: string;
|
||||
endpoints: OrganizationEndpoints<O> &
|
||||
(O extends { teams: { enabled: true } } ? TeamEndpoints<O> : {}) &
|
||||
(O extends { dynamicAccessControl: { enabled: true } }
|
||||
@@ -347,6 +350,7 @@ export function organization<
|
||||
options?: O | undefined,
|
||||
): {
|
||||
id: "organization";
|
||||
version: string;
|
||||
endpoints: OrganizationEndpoints<O> & TeamEndpoints<O>;
|
||||
schema: OrganizationSchema<O>;
|
||||
$Infer: {
|
||||
@@ -378,6 +382,7 @@ export function organization<
|
||||
options?: O | undefined,
|
||||
): {
|
||||
id: "organization";
|
||||
version: string;
|
||||
endpoints: OrganizationEndpoints<O> &
|
||||
TeamEndpoints<O> &
|
||||
DynamicAccessControlEndpoints<O>;
|
||||
@@ -411,6 +416,7 @@ export function organization<
|
||||
options?: O | undefined,
|
||||
): {
|
||||
id: "organization";
|
||||
version: string;
|
||||
endpoints: OrganizationEndpoints<O> & DynamicAccessControlEndpoints<O>;
|
||||
schema: OrganizationSchema<O>;
|
||||
$Infer: {
|
||||
@@ -1204,6 +1210,7 @@ export function organization<O extends OrganizationOptions>(options?: O) {
|
||||
|
||||
return {
|
||||
id: "organization",
|
||||
version: PACKAGE_VERSION,
|
||||
endpoints: {
|
||||
...(api as OrganizationEndpoints<O>),
|
||||
hasPermission: createHasPermission(opts),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { BetterAuthClientPlugin } from "@better-auth/core";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import type { phoneNumber } from ".";
|
||||
|
||||
import { PHONE_NUMBER_ERROR_CODES } from "./error-codes";
|
||||
|
||||
export * from "./error-codes";
|
||||
@@ -8,6 +8,7 @@ export * from "./error-codes";
|
||||
export const phoneNumberClient = () => {
|
||||
return {
|
||||
id: "phoneNumber",
|
||||
version: PACKAGE_VERSION,
|
||||
$InferServerPlugin: {} as ReturnType<typeof phoneNumber>,
|
||||
atomListeners: [
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { BetterAuthPlugin } from "@better-auth/core";
|
||||
import { createAuthMiddleware } from "@better-auth/core/api";
|
||||
import { APIError } from "@better-auth/core/error";
|
||||
import { mergeSchema } from "../../db/schema";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import { PHONE_NUMBER_ERROR_CODES } from "./error-codes";
|
||||
import type { RequiredPhoneNumberOptions } from "./routes";
|
||||
import {
|
||||
@@ -37,6 +38,7 @@ export const phoneNumber = (options?: PhoneNumberOptions | undefined) => {
|
||||
|
||||
return {
|
||||
id: "phone-number",
|
||||
version: PACKAGE_VERSION,
|
||||
hooks: {
|
||||
before: [
|
||||
{
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import type { BetterAuthClientPlugin } from "@better-auth/core";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import type { siwe } from ".";
|
||||
|
||||
export const siweClient = () => {
|
||||
return {
|
||||
id: "siwe",
|
||||
version: PACKAGE_VERSION,
|
||||
$InferServerPlugin: {} as ReturnType<typeof siwe>,
|
||||
} satisfies BetterAuthClientPlugin;
|
||||
};
|
||||
|
||||
@@ -8,6 +8,7 @@ import type { InferOptionSchema, User } from "../../types";
|
||||
import { toChecksumAddress } from "../../utils/hashing";
|
||||
import { isAPIError } from "../../utils/is-api-error";
|
||||
import { getOrigin } from "../../utils/url";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import type { WalletAddressSchema } from "./schema";
|
||||
import { schema } from "./schema";
|
||||
import type {
|
||||
@@ -46,6 +47,7 @@ const getSiweNonceBodySchema = z.object({
|
||||
export const siwe = (options: SIWEPluginOptions) =>
|
||||
({
|
||||
id: "siwe",
|
||||
version: PACKAGE_VERSION,
|
||||
schema: mergeSchema(schema, options?.schema) as WalletAddressSchema,
|
||||
endpoints: {
|
||||
getSiweNonce: createAuthEndpoint(
|
||||
|
||||
@@ -22,6 +22,8 @@ export type {
|
||||
TestUtilsOptions,
|
||||
} from "./types";
|
||||
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
|
||||
declare module "@better-auth/core" {
|
||||
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
||||
"test-utils": {
|
||||
@@ -62,6 +64,7 @@ declare module "@better-auth/core" {
|
||||
export const testUtils = (options: TestUtilsOptions = {}) => {
|
||||
return {
|
||||
id: "test-utils",
|
||||
version: PACKAGE_VERSION,
|
||||
init(ctx) {
|
||||
// Check if organization plugin is present
|
||||
const hasOrgPlugin = ctx.hasPlugin("organization");
|
||||
|
||||
@@ -8,6 +8,7 @@ import { symmetricDecrypt, symmetricEncrypt } from "../../../crypto";
|
||||
import { generateRandomString } from "../../../crypto/random";
|
||||
import { parseUserOutput } from "../../../db/schema";
|
||||
import { shouldRequirePassword } from "../../../utils/password";
|
||||
import { PACKAGE_VERSION } from "../../../version";
|
||||
import { TWO_FACTOR_ERROR_CODES } from "../error-code";
|
||||
import type {
|
||||
TwoFactorProvider,
|
||||
@@ -185,6 +186,7 @@ export const backupCode2fa = (opts: BackupCodeOptions) => {
|
||||
|
||||
return {
|
||||
id: "backup_code",
|
||||
version: PACKAGE_VERSION,
|
||||
endpoints: {
|
||||
/**
|
||||
* ### Endpoint
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { BetterAuthClientPlugin } from "@better-auth/core";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import type { twoFactor as twoFa } from ".";
|
||||
import { TWO_FACTOR_ERROR_CODES } from "./error-code";
|
||||
|
||||
@@ -24,6 +25,7 @@ export const twoFactorClient = (
|
||||
) => {
|
||||
return {
|
||||
id: "two-factor",
|
||||
version: PACKAGE_VERSION,
|
||||
$InferServerPlugin: {} as ReturnType<typeof twoFa>,
|
||||
atomListeners: [
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@ import { symmetricEncrypt } from "../../crypto";
|
||||
import { generateRandomString } from "../../crypto/random";
|
||||
import { mergeSchema } from "../../db/schema";
|
||||
import { shouldRequirePassword, validatePassword } from "../../utils/password";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import type { BackupCodeOptions } from "./backup-codes";
|
||||
import { backupCode2fa, generateBackupCodes } from "./backup-codes";
|
||||
import {
|
||||
@@ -93,6 +94,7 @@ export const twoFactor = <O extends TwoFactorOptions>(options?: O) => {
|
||||
|
||||
return {
|
||||
id: "two-factor",
|
||||
version: PACKAGE_VERSION,
|
||||
endpoints: {
|
||||
...totp.endpoints,
|
||||
...otp.endpoints,
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
symmetricEncrypt,
|
||||
} from "../../../crypto";
|
||||
import { parseUserOutput } from "../../../db/schema";
|
||||
import { PACKAGE_VERSION } from "../../../version";
|
||||
import { TWO_FACTOR_ERROR_CODES } from "../error-code";
|
||||
import type { TwoFactorProvider, UserWithTwoFactor } from "../types";
|
||||
import { defaultKeyHasher } from "../utils";
|
||||
@@ -386,6 +387,7 @@ export const otp2fa = (options?: OTPOptions | undefined) => {
|
||||
|
||||
return {
|
||||
id: "otp",
|
||||
version: PACKAGE_VERSION,
|
||||
endpoints: {
|
||||
/**
|
||||
* ### Endpoint
|
||||
|
||||
@@ -6,6 +6,7 @@ import { sessionMiddleware } from "../../../api";
|
||||
import { setSessionCookie } from "../../../cookies";
|
||||
import { symmetricDecrypt } from "../../../crypto";
|
||||
import { shouldRequirePassword } from "../../../utils/password";
|
||||
import { PACKAGE_VERSION } from "../../../version";
|
||||
import type { BackupCodeOptions } from "../backup-codes";
|
||||
import { TWO_FACTOR_ERROR_CODES } from "../error-code";
|
||||
import type {
|
||||
@@ -318,6 +319,7 @@ export const totp2fa = (options?: TOTPOptions | undefined) => {
|
||||
|
||||
return {
|
||||
id: "totp",
|
||||
version: PACKAGE_VERSION,
|
||||
endpoints: {
|
||||
/**
|
||||
* ### Endpoint
|
||||
|
||||
@@ -72,6 +72,7 @@ export interface UserWithTwoFactor extends User {
|
||||
|
||||
export interface TwoFactorProvider {
|
||||
id: LiteralString;
|
||||
version?: string | undefined;
|
||||
endpoints?: BetterAuthPlugin["endpoints"] | undefined;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { BetterAuthClientPlugin } from "@better-auth/core";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import type { username } from ".";
|
||||
|
||||
import { USERNAME_ERROR_CODES } from "./error-codes";
|
||||
|
||||
export * from "./error-codes";
|
||||
@@ -8,6 +8,7 @@ export * from "./error-codes";
|
||||
export const usernameClient = () => {
|
||||
return {
|
||||
id: "username",
|
||||
version: PACKAGE_VERSION,
|
||||
$InferServerPlugin: {} as ReturnType<typeof username>,
|
||||
atomListeners: [
|
||||
{
|
||||
|
||||
@@ -11,6 +11,7 @@ import { getSessionFromCtx } from "../../api/routes/session";
|
||||
import { setSessionCookie } from "../../cookies";
|
||||
import { mergeSchema, parseUserOutput } from "../../db";
|
||||
import type { InferOptionSchema } from "../../types/plugins";
|
||||
import { PACKAGE_VERSION } from "../../version";
|
||||
import { USERNAME_ERROR_CODES as ERROR_CODES } from "./error-codes";
|
||||
import type { UsernameSchema } from "./schema";
|
||||
import { getSchema } from "./schema";
|
||||
@@ -138,6 +139,7 @@ export const username = (options?: UsernameOptions | undefined) => {
|
||||
|
||||
return {
|
||||
id: "username",
|
||||
version: PACKAGE_VERSION,
|
||||
init(ctx) {
|
||||
return {
|
||||
options: {
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import pkg from "../package.json" with { type: "json" };
|
||||
|
||||
export const PACKAGE_VERSION = pkg.version;
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"include": ["src/**/*.ts", "package.json"],
|
||||
"compilerOptions": {
|
||||
"lib": ["esnext", "dom", "dom.iterable"],
|
||||
"types": ["node", "bun"]
|
||||
|
||||
@@ -58,6 +58,7 @@ type InferPluginOptions<
|
||||
*
|
||||
* const createMyPlugin = <Options extends MyPluginOptions>(options?: Options) => ({
|
||||
* id: 'my-plugin',
|
||||
* version: '1.0.0',
|
||||
* options,
|
||||
* } satisfies BetterAuthPlugin);
|
||||
*
|
||||
|
||||
@@ -79,6 +79,7 @@ export interface BetterAuthClientOptions {
|
||||
|
||||
export interface BetterAuthClientPlugin {
|
||||
id: LiteralString;
|
||||
version?: string | undefined;
|
||||
/**
|
||||
* only used for type inference. don't pass the
|
||||
* actual plugin
|
||||
|
||||
@@ -51,6 +51,7 @@ export type BetterAuthPluginErrorCodePart = {
|
||||
|
||||
export type BetterAuthPlugin = BetterAuthPluginErrorCodePart & {
|
||||
id: LiteralString;
|
||||
version?: string | undefined;
|
||||
/**
|
||||
* The init function is called when the plugin is initialized.
|
||||
* You can return a new context or modify the existing context.
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
isProcessType,
|
||||
parseProtocolScheme,
|
||||
} from "./utils";
|
||||
import { PACKAGE_VERSION } from "./version";
|
||||
|
||||
const { app, safeStorage, webContents } = electron;
|
||||
|
||||
@@ -91,6 +92,7 @@ export const electronClient = <O extends ElectronClientOptions>(options: O) => {
|
||||
|
||||
return {
|
||||
id: "electron",
|
||||
version: PACKAGE_VERSION,
|
||||
fetchPlugins: [
|
||||
{
|
||||
id: "electron",
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
electronTransferUser,
|
||||
} from "./routes";
|
||||
import type { ElectronOptions } from "./types";
|
||||
import { PACKAGE_VERSION } from "./version";
|
||||
|
||||
declare module "@better-auth/core" {
|
||||
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
||||
@@ -109,6 +110,7 @@ export const electron = (options?: ElectronOptions | undefined) => {
|
||||
|
||||
return {
|
||||
id: "electron",
|
||||
version: PACKAGE_VERSION,
|
||||
async onRequest(request, _ctx) {
|
||||
if (opts.disableOriginOverride || request.headers.get("origin")) {
|
||||
return;
|
||||
|
||||
@@ -3,6 +3,7 @@ import { parseCookies } from "better-auth/cookies";
|
||||
import type { electron } from "./index";
|
||||
import type { ElectronProxyClientOptions } from "./types/client";
|
||||
import { parseProtocolScheme } from "./utils";
|
||||
import { PACKAGE_VERSION } from "./version";
|
||||
|
||||
export const electronProxyClient = (options: ElectronProxyClientOptions) => {
|
||||
const opts = {
|
||||
@@ -16,6 +17,7 @@ export const electronProxyClient = (options: ElectronProxyClientOptions) => {
|
||||
|
||||
return {
|
||||
id: "electron-proxy",
|
||||
version: PACKAGE_VERSION,
|
||||
getActions: () => {
|
||||
const getAuthorizationCode = () => {
|
||||
if (typeof document === "undefined") return null;
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import pkg from "../package.json" with { type: "json" };
|
||||
|
||||
export const PACKAGE_VERSION = pkg.version;
|
||||
@@ -3,7 +3,7 @@
|
||||
"compilerOptions": {
|
||||
"lib": ["esnext", "dom", "dom.iterable"]
|
||||
},
|
||||
"include": ["./src"],
|
||||
"include": ["./src", "./package.json"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../core/tsconfig.json"
|
||||
|
||||
@@ -14,6 +14,7 @@ import * as Linking from "expo-linking";
|
||||
import { Platform } from "react-native";
|
||||
import { setupExpoFocusManager } from "./focus-manager";
|
||||
import { setupExpoOnlineManager } from "./online-manager";
|
||||
import { PACKAGE_VERSION } from "./version";
|
||||
|
||||
if (Platform.OS !== "web") {
|
||||
setupExpoFocusManager();
|
||||
@@ -286,6 +287,7 @@ export const expoClient = (opts: ExpoClientOptions) => {
|
||||
}
|
||||
return {
|
||||
id: "expo",
|
||||
version: PACKAGE_VERSION,
|
||||
getActions(_, $store) {
|
||||
store = $store;
|
||||
return {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { BetterAuthPlugin } from "@better-auth/core";
|
||||
import { createAuthMiddleware } from "@better-auth/core/api";
|
||||
import { expoAuthorizationProxy } from "./routes";
|
||||
import { PACKAGE_VERSION } from "./version";
|
||||
|
||||
export interface ExpoOptions {
|
||||
/**
|
||||
@@ -21,6 +22,7 @@ declare module "@better-auth/core" {
|
||||
export const expo = (options?: ExpoOptions | undefined) => {
|
||||
return {
|
||||
id: "expo",
|
||||
version: PACKAGE_VERSION,
|
||||
init: (ctx) => {
|
||||
const trustedOrigins =
|
||||
process.env.NODE_ENV === "development" ? ["exp://"] : [];
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { Awaitable, BetterAuthClientPlugin } from "@better-auth/core";
|
||||
import { PACKAGE_VERSION } from "../version";
|
||||
|
||||
export interface LastLoginMethodClientConfig {
|
||||
storage: {
|
||||
@@ -47,6 +48,7 @@ export const lastLoginMethodClient = (config: LastLoginMethodClientConfig) => {
|
||||
|
||||
return {
|
||||
id: "last-login-method-expo",
|
||||
version: PACKAGE_VERSION,
|
||||
fetchPlugins: [
|
||||
{
|
||||
id: "last-login-method-expo",
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import pkg from "../package.json" with { type: "json" };
|
||||
|
||||
export const PACKAGE_VERSION = pkg.version;
|
||||
@@ -3,7 +3,7 @@
|
||||
"compilerOptions": {
|
||||
"lib": ["esnext", "dom", "dom.iterable"]
|
||||
},
|
||||
"include": ["./src"],
|
||||
"include": ["./src", "./package.json"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../core/tsconfig.json"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"outDir": "${configDir}/node_modules/.cache/ts/test-out",
|
||||
"tsBuildInfoFile": "${configDir}/node_modules/.cache/ts/test-tsbuildinfo"
|
||||
},
|
||||
"include": ["./test", "./src"],
|
||||
"include": ["./test", "./src", "./package.json"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../better-auth/tsconfig.json"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { BetterAuthClientPlugin } from "@better-auth/core";
|
||||
import type { i18n } from ".";
|
||||
import { PACKAGE_VERSION } from "./version";
|
||||
|
||||
/**
|
||||
* i18n client plugin for Better Auth
|
||||
@@ -21,6 +22,7 @@ import type { i18n } from ".";
|
||||
export const i18nClient = () => {
|
||||
return {
|
||||
id: "i18n",
|
||||
version: PACKAGE_VERSION,
|
||||
$InferServerPlugin: {} as ReturnType<typeof i18n>,
|
||||
} satisfies BetterAuthClientPlugin;
|
||||
};
|
||||
|
||||
@@ -5,6 +5,7 @@ import type {
|
||||
import { APIError, createAuthMiddleware, isAPIError } from "better-auth/api";
|
||||
import { parseCookies } from "better-auth/cookies";
|
||||
import type { I18nOptions, LocaleDetectionStrategy } from "./types";
|
||||
import { PACKAGE_VERSION } from "./version";
|
||||
|
||||
export type {
|
||||
I18nOptions,
|
||||
@@ -151,6 +152,7 @@ export const i18n = <Locales extends string[]>(
|
||||
|
||||
return {
|
||||
id: "i18n",
|
||||
version: PACKAGE_VERSION,
|
||||
hooks: {
|
||||
after: [
|
||||
{
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import pkg from "../package.json" with { type: "json" };
|
||||
|
||||
export const PACKAGE_VERSION = pkg.version;
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"include": ["./src", "./package.json"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../core/tsconfig.json"
|
||||
|
||||
@@ -7,6 +7,7 @@ import type { JWTPayload, JWTVerifyOptions } from "jose";
|
||||
import { handleMcpErrors } from "./mcp";
|
||||
import type { ResourceServerMetadata } from "./types/oauth";
|
||||
import { getJwtPlugin, getOAuthProviderPlugin } from "./utils";
|
||||
import { PACKAGE_VERSION } from "./version";
|
||||
|
||||
export const oauthProviderResourceClient = <T extends Auth | undefined>(
|
||||
auth?: T,
|
||||
@@ -44,6 +45,7 @@ export const oauthProviderResourceClient = <T extends Auth | undefined>(
|
||||
|
||||
return {
|
||||
id: "oauth-provider-resource-client",
|
||||
version: PACKAGE_VERSION,
|
||||
getActions() {
|
||||
return {
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { safeJSONParse } from "@better-auth/core/utils/json";
|
||||
import type { BetterAuthClientPlugin } from "better-auth/types";
|
||||
import type { oauthProvider } from "./oauth";
|
||||
import { PACKAGE_VERSION } from "./version";
|
||||
|
||||
function parseSignedQuery(search: string) {
|
||||
const params = new URLSearchParams(search);
|
||||
@@ -17,6 +18,7 @@ function parseSignedQuery(search: string) {
|
||||
export const oauthProviderClient = () => {
|
||||
return {
|
||||
id: "oauth-provider-client",
|
||||
version: PACKAGE_VERSION,
|
||||
fetchPlugins: [
|
||||
{
|
||||
id: "oauth-provider-signin",
|
||||
|
||||
@@ -32,6 +32,7 @@ import {
|
||||
getJwtPlugin,
|
||||
verifyOAuthQueryParams,
|
||||
} from "./utils";
|
||||
import { PACKAGE_VERSION } from "./version";
|
||||
|
||||
declare module "@better-auth/core" {
|
||||
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
||||
@@ -164,6 +165,7 @@ export const oauthProvider = <O extends OAuthOptions<Scope[]>>(options: O) => {
|
||||
|
||||
return {
|
||||
id: "oauth-provider",
|
||||
version: PACKAGE_VERSION,
|
||||
options: opts as NoInfer<O>,
|
||||
init: (ctx) => {
|
||||
// Require session id storage on database (secondary-storage only solution not yet supported)
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import pkg from "../package.json" with { type: "json" };
|
||||
|
||||
export const PACKAGE_VERSION = pkg.version;
|
||||
@@ -3,7 +3,7 @@
|
||||
"compilerOptions": {
|
||||
"lib": ["esnext", "dom", "dom.iterable"]
|
||||
},
|
||||
"include": ["./src"],
|
||||
"include": ["./src", "./package.json"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../better-auth/tsconfig.json"
|
||||
|
||||
@@ -25,6 +25,7 @@ import { atom } from "nanostores";
|
||||
import type { passkey } from ".";
|
||||
import { PASSKEY_ERROR_CODES } from "./error-codes";
|
||||
import type { Passkey } from "./types";
|
||||
import { PACKAGE_VERSION } from "./version";
|
||||
|
||||
export const getPasskeyActions = (
|
||||
$fetch: BetterFetch,
|
||||
@@ -292,6 +293,7 @@ export const passkeyClient = () => {
|
||||
const $listPasskeys = atom<any>();
|
||||
return {
|
||||
id: "passkey",
|
||||
version: PACKAGE_VERSION,
|
||||
$InferServerPlugin: {} as ReturnType<typeof passkey>,
|
||||
getActions: ($fetch, $store) =>
|
||||
getPasskeyActions($fetch, {
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
} from "./routes";
|
||||
import { schema } from "./schema";
|
||||
import type { Passkey, PasskeyOptions } from "./types";
|
||||
import { PACKAGE_VERSION } from "./version";
|
||||
|
||||
declare module "@better-auth/core" {
|
||||
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
||||
@@ -37,6 +38,7 @@ export const passkey = (options?: PasskeyOptions | undefined) => {
|
||||
|
||||
return {
|
||||
id: "passkey",
|
||||
version: PACKAGE_VERSION,
|
||||
endpoints: {
|
||||
generatePasskeyRegistrationOptions: generatePasskeyRegistrationOptions(
|
||||
opts,
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import pkg from "../package.json" with { type: "json" };
|
||||
|
||||
export const PACKAGE_VERSION = pkg.version;
|
||||
@@ -3,7 +3,7 @@
|
||||
"compilerOptions": {
|
||||
"lib": ["esnext", "dom", "dom.iterable"]
|
||||
},
|
||||
"include": ["./src"],
|
||||
"include": ["./src", "./package.json"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../better-auth/tsconfig.json"
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import type { BetterAuthClientPlugin } from "better-auth/client";
|
||||
import type { scim } from "./index";
|
||||
import { PACKAGE_VERSION } from "./version";
|
||||
|
||||
export const scimClient = () => {
|
||||
return {
|
||||
id: "scim-client",
|
||||
version: PACKAGE_VERSION,
|
||||
$InferServerPlugin: {} as ReturnType<typeof scim>,
|
||||
} satisfies BetterAuthClientPlugin;
|
||||
};
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
updateSCIMUser,
|
||||
} from "./routes";
|
||||
import type { SCIMOptions } from "./types";
|
||||
import { PACKAGE_VERSION } from "./version";
|
||||
|
||||
declare module "@better-auth/core" {
|
||||
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
||||
@@ -38,6 +39,7 @@ export const scim = (options?: SCIMOptions) => {
|
||||
|
||||
return {
|
||||
id: "scim",
|
||||
version: PACKAGE_VERSION,
|
||||
endpoints: {
|
||||
generateSCIMToken: generateSCIMToken(opts),
|
||||
listSCIMProviderConnections: listSCIMProviderConnections(),
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import pkg from "../package.json" with { type: "json" };
|
||||
|
||||
export const PACKAGE_VERSION = pkg.version;
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"include": ["./src", "./package.json"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../better-auth/tsconfig.json"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { BetterAuthClientPlugin } from "better-auth/client";
|
||||
import type { SSOPlugin } from "./index";
|
||||
import { PACKAGE_VERSION } from "./version";
|
||||
|
||||
interface SSOClientOptions {
|
||||
domainVerification?:
|
||||
@@ -14,6 +15,7 @@ export const ssoClient = <CO extends SSOClientOptions>(
|
||||
) => {
|
||||
return {
|
||||
id: "sso-client",
|
||||
version: PACKAGE_VERSION,
|
||||
$InferServerPlugin: {} as SSOPlugin<{
|
||||
domainVerification: {
|
||||
enabled: CO["domainVerification"] extends { enabled: true }
|
||||
|
||||
@@ -48,6 +48,7 @@ export {
|
||||
} from "./saml";
|
||||
|
||||
import type { OIDCConfig, SAMLConfig, SSOOptions, SSOProvider } from "./types";
|
||||
import { PACKAGE_VERSION } from "./version";
|
||||
|
||||
export type { SAMLConfig, OIDCConfig, SSOOptions, SSOProvider };
|
||||
|
||||
@@ -113,6 +114,7 @@ type SSOEndpoints<O extends SSOOptions> = {
|
||||
|
||||
export type SSOPlugin<O extends SSOOptions> = {
|
||||
id: "sso";
|
||||
version: string;
|
||||
endpoints: SSOEndpoints<O> &
|
||||
(O extends { domainVerification: { enabled: true } }
|
||||
? DomainVerificationEndpoints
|
||||
@@ -138,6 +140,7 @@ export function sso<
|
||||
options?: O | undefined,
|
||||
): {
|
||||
id: "sso";
|
||||
version: string;
|
||||
endpoints: SSOEndpoints<O> & DomainVerificationEndpoints;
|
||||
schema: NonNullable<BetterAuthPlugin["schema"]>;
|
||||
options: NoInfer<O>;
|
||||
@@ -146,6 +149,7 @@ export function sso<O extends SSOOptions>(
|
||||
options?: O | undefined,
|
||||
): {
|
||||
id: "sso";
|
||||
version: string;
|
||||
endpoints: SSOEndpoints<O>;
|
||||
options: NoInfer<O>;
|
||||
};
|
||||
@@ -185,6 +189,7 @@ export function sso<O extends SSOOptions>(
|
||||
|
||||
return {
|
||||
id: "sso",
|
||||
version: PACKAGE_VERSION,
|
||||
init(ctx) {
|
||||
const existing = ctx.skipOriginCheck;
|
||||
if (existing === true) {
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import pkg from "../package.json" with { type: "json" };
|
||||
|
||||
export const PACKAGE_VERSION = pkg.version;
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"include": ["./src", "./package.json"],
|
||||
"compilerOptions": {
|
||||
"lib": ["esnext", "dom", "dom.iterable"]
|
||||
},
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import type { BetterAuthClientPlugin } from "better-auth/client";
|
||||
import { STRIPE_ERROR_CODES } from "./error-codes";
|
||||
import type { StripePlan, stripe } from "./index";
|
||||
import { PACKAGE_VERSION } from "./version";
|
||||
|
||||
export const stripeClient = <
|
||||
O extends {
|
||||
subscription: boolean;
|
||||
@@ -10,6 +12,7 @@ export const stripeClient = <
|
||||
) => {
|
||||
return {
|
||||
id: "stripe-client",
|
||||
version: PACKAGE_VERSION,
|
||||
$InferServerPlugin: {} as ReturnType<
|
||||
typeof stripe<
|
||||
O["subscription"] extends true
|
||||
|
||||
@@ -22,6 +22,7 @@ import type {
|
||||
WithStripeCustomerId,
|
||||
} from "./types";
|
||||
import { escapeStripeSearchValue, getPlans, isActiveOrTrialing } from "./utils";
|
||||
import { PACKAGE_VERSION } from "./version";
|
||||
|
||||
declare module "@better-auth/core" {
|
||||
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
||||
@@ -45,6 +46,7 @@ export const stripe = <O extends StripeOptions>(options: O) => {
|
||||
|
||||
return {
|
||||
id: "stripe",
|
||||
version: PACKAGE_VERSION,
|
||||
endpoints: {
|
||||
stripeWebhook: stripeWebhook(options),
|
||||
...((options.subscription?.enabled
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import pkg from "../package.json" with { type: "json" };
|
||||
|
||||
export const PACKAGE_VERSION = pkg.version;
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"include": ["./src", "./package.json"],
|
||||
"compilerOptions": {
|
||||
"lib": ["esnext", "dom", "dom.iterable"]
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user