better-auth 0.0.9-beta.6 → 0.0.9-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/plugins.d.ts +3 -3
- package/dist/client.d.ts +3 -3
- package/dist/client.js +4 -2
- package/dist/client.js.map +1 -1
- package/dist/{index-BPt7eYOq.d.ts → index-Bh0E6nXA.d.ts} +1 -1
- package/dist/{index-7qDK4y_k.d.ts → index-BqqlGo3a.d.ts} +379 -13
- package/dist/index.d.ts +2 -2
- package/dist/index.js +221 -140
- package/dist/index.js.map +1 -1
- package/dist/{internal-adapter-BCNEGkr4.d.ts → internal-adapter-DXjewSmi.d.ts} +104 -1
- package/dist/next-js.d.ts +2 -2
- package/dist/plugins.d.ts +3 -3
- package/dist/plugins.js +63 -13
- package/dist/plugins.js.map +1 -1
- package/dist/react.d.ts +3 -3
- package/dist/react.js +4 -2
- package/dist/react.js.map +1 -1
- package/dist/solid-start.d.ts +2 -2
- package/dist/solid.d.ts +3 -3
- package/dist/solid.js +4 -2
- package/dist/solid.js.map +1 -1
- package/dist/svelte-kit.d.ts +2 -2
- package/dist/svelte.d.ts +3 -3
- package/dist/svelte.js +4 -2
- package/dist/svelte.js.map +1 -1
- package/dist/{types-Dtas7YiL.d.ts → types-DPwV7Ir2.d.ts} +2 -2
- package/dist/types.d.ts +2 -2
- package/dist/vue.d.ts +3 -3
- package/dist/vue.js +4 -2
- package/dist/vue.js.map +1 -1
- package/package.json +1 -1
package/dist/client/plugins.d.ts
CHANGED
|
@@ -2,14 +2,14 @@ import * as nanostores from 'nanostores';
|
|
|
2
2
|
import { A as AccessControl, S as StatementsPrimitive, R as Role } from '../statement-D6SPoYOh.js';
|
|
3
3
|
import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
4
4
|
import { BetterFetchOption } from '@better-fetch/fetch';
|
|
5
|
-
import { o as organization, M as Member, I as Invitation, u as username } from '../index-
|
|
6
|
-
export { g as getPasskeyActions, c as passkeyClient, a as twoFactorClient } from '../index-
|
|
5
|
+
import { o as organization, M as Member, I as Invitation, u as username } from '../index-Bh0E6nXA.js';
|
|
6
|
+
export { g as getPasskeyActions, c as passkeyClient, a as twoFactorClient } from '../index-Bh0E6nXA.js';
|
|
7
7
|
import '../helper-D8dhRz72.js';
|
|
8
8
|
import '../index-CcxejJTH.js';
|
|
9
9
|
import 'arctic';
|
|
10
10
|
import 'zod';
|
|
11
11
|
import 'better-call';
|
|
12
|
-
import '../internal-adapter-
|
|
12
|
+
import '../internal-adapter-DXjewSmi.js';
|
|
13
13
|
import 'kysely';
|
|
14
14
|
import '@simplewebauthn/types';
|
|
15
15
|
|
package/dist/client.d.ts
CHANGED
|
@@ -3,14 +3,14 @@ import * as nanostores from 'nanostores';
|
|
|
3
3
|
import { PreinitializedWritableAtom } from 'nanostores';
|
|
4
4
|
import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
5
5
|
import { BetterFetch, BetterFetchOption, BetterFetchError } from '@better-fetch/fetch';
|
|
6
|
-
import { B as BetterAuthPlugin, F as FieldAttribute, I as InferFieldOutput } from './internal-adapter-
|
|
6
|
+
import { B as BetterAuthPlugin, F as FieldAttribute, I as InferFieldOutput } from './internal-adapter-DXjewSmi.js';
|
|
7
7
|
import { U as UnionToIntersection } from './helper-D8dhRz72.js';
|
|
8
|
-
import { C as ClientOptions, I as InferClientAPI, a as InferActions, A as AuthClientPlugin, c as InferSessionFromClient, d as InferUserFromClient, b as IsSignal } from './types-
|
|
8
|
+
import { C as ClientOptions, I as InferClientAPI, a as InferActions, A as AuthClientPlugin, c as InferSessionFromClient, d as InferUserFromClient, b as IsSignal } from './types-DPwV7Ir2.js';
|
|
9
9
|
import 'kysely';
|
|
10
10
|
import './index-CcxejJTH.js';
|
|
11
11
|
import 'arctic';
|
|
12
12
|
import 'better-call';
|
|
13
|
-
import './index-
|
|
13
|
+
import './index-BqqlGo3a.js';
|
|
14
14
|
|
|
15
15
|
type InferResolvedHooks<O extends ClientOptions> = O["plugins"] extends Array<infer Plugin> ? Plugin extends AuthClientPlugin ? Plugin["getAtoms"] extends (fetch: any) => infer Atoms ? Atoms extends Record<string, any> ? {
|
|
16
16
|
[key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: Atoms[key];
|
package/dist/client.js
CHANGED
|
@@ -124,7 +124,8 @@ var getClientConfig = (options) => {
|
|
|
124
124
|
let pluginsActions = {};
|
|
125
125
|
let pluginsAtoms = {};
|
|
126
126
|
let pluginPathMethods = {
|
|
127
|
-
"/sign-out": "POST"
|
|
127
|
+
"/sign-out": "POST",
|
|
128
|
+
"/user/revoke-sessions": "POST"
|
|
128
129
|
};
|
|
129
130
|
const atomListeners = [
|
|
130
131
|
{
|
|
@@ -218,8 +219,9 @@ function createDynamicPathProxy(routes, client, knownPathMethods, atoms, atomLis
|
|
|
218
219
|
if (!matches) return;
|
|
219
220
|
const signal = atoms[matches.signal];
|
|
220
221
|
if (!signal) return;
|
|
222
|
+
const val = signal.get();
|
|
221
223
|
setTimeout(() => {
|
|
222
|
-
signal.set(
|
|
224
|
+
signal.set(!val);
|
|
223
225
|
}, 0);
|
|
224
226
|
}
|
|
225
227
|
});
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/error/better-auth-error.ts","../src/utils/base-url.ts","../src/client/fetch-plugins.ts","../src/client/config.ts","../src/utils/misc.ts","../src/client/proxy.ts","../src/client/query.ts","../src/client/session-atom.ts","../src/client/vanilla.ts"],"names":["value","atom"],"mappings":";;;;;;AAAO,IAAM,eAAA,GAAN,cAA8B,KAAM,CAAA;AAAA,EAC1C,YAAY,OAAiB,EAAA;AAC5B,IAAA,KAAA,CAAM,OAAO,CAAA,CAAA;AAAA,GACd;AACD,CAAA,CAAA;;;ACFA,SAAS,aAAa,GAAsB,EAAA;AAC3C,EAAI,IAAA;AACH,IAAM,MAAA,SAAA,GAAY,IAAI,GAAA,CAAI,GAAG,CAAA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B,QAAQ,EAAC;AAAA,GAMV,CAAA;AACD,CAAA;;;ACrBO,SAAS,iBACf,OACC,EAAA;AACD,EAAM,MAAA;AAAA,IACL,iBAAA;AAAA,IACA,cAAA;AAAA,IACA,YAAA;AAAA,IACA,MAAA;AAAA,IACA,aAAA;AAAA,GACD,GAAI,gBAAgB,OAAO,CAAA,CAAA;AAC3B,EAAA,IAAI,gBAAqC,EAAC,CAAA;AAC1C,EAAA,KAAA,MAAW,CAAC,GAAK,EAAA,KAAK,KAAK,MAAO,CAAA,OAAA,CAAQ,YAAY,CAAG,EAAA;AACxD,IAAA,aAAA,CAAc,CAAM,GAAA,EAAA,qBAAA,CAAsB,GAAG,CAAC,EAAE,CAAI,GAAA,KAAA,CAAA;AAAA,GACrD;AAEA,EAAA,MAAM,EAAE,QAAA,EAAU,cAAe,EAAA,GAAI,eAAuB,MAAM,CAAA,CAAA;AAClE,EAAA,MAAM,MAAS,GAAA;AAAA,IACd,GAAG,cAAA;AAAA,IACH,GAAG,aAAA;AAAA,IACH,MAAA;AAAA,IACA,UAAY,EAAA,QAAA;AAAA,GACb,CAAA;AACA,EAAA,MAAM,KAAQ,GAAA,sBAAA;AAAA,IACb,MAAA;AAAA,IACA,MAAA;AAAA,IACA,iBAAA;AAAA,IACA;AAAA,MACC,GAAG,YAAA;AAAA,MACH,cAAA;AAAA,KACD;AAAA,IACA,aAAA;AAAA,GACD,CAAA;AACA,EAAO,OAAA,KAAA,CAAA;AAUR","file":"client.js","sourcesContent":["export class BetterAuthError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t}\n}\n","import { BetterAuthError } from \"../error/better-auth-error\";\n\nfunction checkHasPath(url: string): boolean {\n\ttry {\n\t\tconst parsedUrl = new URL(url);\n\t\treturn parsedUrl.pathname !== \"/\";\n\t} catch (error) {\n\t\tthrow new BetterAuthError(\n\t\t\t`Invalid base URL: ${url}. Please provide a valid base URL.`,\n\t\t);\n\t}\n}\n\nfunction withPath(url: string, path = \"/api/auth\") {\n\tconst hasPath = checkHasPath(url);\n\tif (hasPath) {\n\t\treturn url;\n\t}\n\tpath = path.startsWith(\"/\") ? path : `/${path}`;\n\treturn `${url}${path}`;\n}\n\nexport function getBaseURL(url?: string, path?: string) {\n\tif (url) {\n\t\treturn withPath(url, path);\n\t}\n\tconst env: any = typeof process !== \"undefined\" ? process.env : {};\n\tconst fromEnv =\n\t\tenv.BETTER_AUTH_URL ||\n\t\tenv.NEXT_PUBLIC_BETTER_AUTH_URL ||\n\t\tenv.PUBLIC_BETTER_AUTH_URL ||\n\t\tenv.NUXT_PUBLIC_BETTER_AUTH_URL ||\n\t\tenv.NUXT_PUBLIC_AUTH_URL;\n\tif (fromEnv) {\n\t\treturn withPath(fromEnv, path);\n\t}\n\n\tif (typeof window !== \"undefined\") {\n\t\treturn withPath(window.location.origin, path);\n\t}\n\treturn undefined;\n}\n","import { type BetterFetchPlugin, betterFetch } from \"@better-fetch/fetch\";\nimport { BetterAuthError } from \"../error/better-auth-error\";\n\nexport const redirectPlugin = {\n\tid: \"redirect\",\n\tname: \"Redirect\",\n\thooks: {\n\t\tonSuccess(context) {\n\t\t\tif (context.data?.url && context.data?.redirect) {\n\t\t\t\tif (typeof window !== \"undefined\") {\n\t\t\t\t\twindow.location.href = context.data.url;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t},\n} satisfies BetterFetchPlugin;\n\nexport const addCurrentURL = {\n\tid: \"add-current-url\",\n\tname: \"Add current URL\",\n\thooks: {\n\t\tonRequest(context) {\n\t\t\tif (typeof window !== \"undefined\") {\n\t\t\t\tconst url = new URL(context.url);\n\t\t\t\turl.searchParams.set(\"currentURL\", window.location.href);\n\t\t\t\tcontext.url = url;\n\t\t\t}\n\t\t\treturn context;\n\t\t},\n\t},\n} satisfies BetterFetchPlugin;\n\nexport const csrfPlugin = {\n\tid: \"csrf\",\n\tname: \"CSRF Check\",\n\tasync init(url, options) {\n\t\tif (!options?.baseURL) {\n\t\t\tthrow new BetterAuthError(\n\t\t\t\t\"API Base URL on the auth client isn't configured. Please pass it directly to the client `baseURL`\",\n\t\t\t);\n\t\t}\n\n\t\tif (options?.method !== \"GET\") {\n\t\t\toptions = options || {};\n\t\t\tconst { data, error } = await betterFetch<{\n\t\t\t\tcsrfToken: string;\n\t\t\t}>(\"/csrf\", {\n\t\t\t\tbody: undefined,\n\t\t\t\tbaseURL: options.baseURL,\n\t\t\t\tplugins: [],\n\t\t\t\tmethod: \"GET\",\n\t\t\t\tcredentials: \"include\",\n\t\t\t\tcustomFetchImpl: options.customFetchImpl,\n\t\t\t});\n\t\t\tif (error?.status === 404) {\n\t\t\t\tthrow new BetterAuthError(\n\t\t\t\t\t\"Route not found. Make sure the server is running and the base URL is correct and includes the path (e.g. http://localhost:3000/api/auth).\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (error) {\n\t\t\t\tthrow new BetterAuthError(error.message || \"Failed to get CSRF token.\");\n\t\t\t}\n\t\t\toptions.body = {\n\t\t\t\t...options?.body,\n\t\t\t\tcsrfToken: data.csrfToken,\n\t\t\t};\n\t\t}\n\t\toptions.credentials = \"include\";\n\t\treturn { url, options };\n\t},\n} satisfies BetterFetchPlugin;\n","import { createFetch } from \"@better-fetch/fetch\";\nimport { getBaseURL } from \"../utils/base-url\";\nimport { type Atom } from \"nanostores\";\nimport type { AtomListener, ClientOptions } from \"./types\";\n\nimport { addCurrentURL, csrfPlugin, redirectPlugin } from \"./fetch-plugins\";\nimport type { InferSession } from \"../types\";\n\nexport const getClientConfig = <O extends ClientOptions>(options?: O) => {\n\tconst $fetch = createFetch({\n\t\tbaseURL: getBaseURL(options?.fetchOptions?.baseURL || options?.baseURL),\n\t\t...options?.fetchOptions,\n\t\tplugins: [\n\t\t\tcsrfPlugin,\n\t\t\tredirectPlugin,\n\t\t\taddCurrentURL,\n\t\t\t...(options?.fetchOptions?.plugins || []),\n\t\t\t...(options?.plugins\n\t\t\t\t?.flatMap((plugin) => plugin.fetchPlugins)\n\t\t\t\t.filter((pl) => pl !== undefined) || []),\n\t\t],\n\t});\n\tconst plugins = options?.plugins || [];\n\tlet pluginsActions = {} as Record<string, any>;\n\tlet pluginsAtoms = {} as Record<string, Atom<any>>;\n\tlet pluginPathMethods: Record<string, \"POST\" | \"GET\"> = {\n\t\t\"/sign-out\": \"POST\",\n\t};\n\tconst atomListeners: AtomListener[] = [\n\t\t{\n\t\t\tsignal: \"_sessionSignal\",\n\t\t\tmatcher(path) {\n\t\t\t\treturn (\n\t\t\t\t\tpath === \"/sign-out\" ||\n\t\t\t\t\tpath === \"sign-up/email\" ||\n\t\t\t\t\tpath === \"/user/update\"\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t];\n\tfor (const plugin of plugins) {\n\t\tif (plugin.getActions) {\n\t\t\tObject.assign(pluginsActions, plugin.getActions?.($fetch));\n\t\t}\n\t\tif (plugin.getAtoms) {\n\t\t\tObject.assign(pluginsAtoms, plugin.getAtoms?.($fetch));\n\t\t}\n\t\tif (plugin.pathMethods) {\n\t\t\tObject.assign(pluginPathMethods, plugin.pathMethods);\n\t\t}\n\t\tif (plugin.atomListeners) {\n\t\t\tatomListeners.push(...plugin.atomListeners);\n\t\t}\n\t}\n\treturn {\n\t\tpluginsActions,\n\t\tpluginsAtoms,\n\t\tpluginPathMethods,\n\t\tatomListeners,\n\t\t$fetch,\n\t};\n};\n","export function capitalizeFirstLetter(str: string) {\n\treturn str.charAt(0).toUpperCase() + str.slice(1);\n}\n","import type { BetterFetch } from \"@better-fetch/fetch\";\nimport type { Atom, PreinitializedWritableAtom } from \"nanostores\";\nimport type { ProxyRequest } from \"./path-to-object\";\nimport type { AuthClientPlugin } from \"./types\";\n\nfunction getMethod(\n\tpath: string,\n\tknownPathMethods: Record<string, \"POST\" | \"GET\">,\n\targs?: ProxyRequest,\n) {\n\tconst method = knownPathMethods[path];\n\tconst { options, query, ...body } = args || {};\n\tif (method) {\n\t\treturn method;\n\t}\n\tif (options?.method) {\n\t\treturn options.method;\n\t}\n\tif (body && Object.keys(body).length > 0) {\n\t\treturn \"POST\";\n\t}\n\treturn \"GET\";\n}\n\nexport type AuthProxySignal = {\n\tatom: PreinitializedWritableAtom<boolean>;\n\tmatcher: (path: string) => boolean;\n};\n\nexport function createDynamicPathProxy<T extends Record<string, any>>(\n\troutes: T,\n\tclient: BetterFetch,\n\tknownPathMethods: Record<string, \"POST\" | \"GET\">,\n\tatoms: Record<string, Atom>,\n\tatomListeners: AuthClientPlugin[\"atomListeners\"],\n): T {\n\tfunction createProxy(path: string[] = []): any {\n\t\treturn new Proxy(function () {}, {\n\t\t\tget(target, prop: string) {\n\t\t\t\tconst fullPath = [...path, prop];\n\t\t\t\tlet current: any = routes;\n\t\t\t\tfor (const segment of fullPath) {\n\t\t\t\t\tif (current && typeof current === \"object\" && segment in current) {\n\t\t\t\t\t\tcurrent = current[segment];\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcurrent = undefined;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (typeof current === \"function\") {\n\t\t\t\t\treturn current;\n\t\t\t\t}\n\t\t\t\treturn createProxy(fullPath);\n\t\t\t},\n\t\t\tapply: async (_, __, args) => {\n\t\t\t\tconst routePath =\n\t\t\t\t\t\"/\" +\n\t\t\t\t\tpath\n\t\t\t\t\t\t.map((segment) =>\n\t\t\t\t\t\t\tsegment.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`),\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.join(\"/\");\n\n\t\t\t\tconst arg = (args[0] || {}) as ProxyRequest;\n\t\t\t\tconst method = getMethod(routePath, knownPathMethods, arg);\n\t\t\t\tconst { query, options, ...body } = arg;\n\n\t\t\t\treturn await client(routePath, {\n\t\t\t\t\t...options,\n\t\t\t\t\tbody:\n\t\t\t\t\t\tmethod === \"GET\"\n\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\t...body,\n\t\t\t\t\t\t\t\t\t...(options?.body || {}),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\tquery: query,\n\t\t\t\t\tmethod,\n\t\t\t\t\tasync onSuccess(context) {\n\t\t\t\t\t\tawait options?.onSuccess?.(context);\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * We trigger listeners\n\t\t\t\t\t\t */\n\t\t\t\t\t\tconst matches = atomListeners?.find((s) => s.matcher(routePath));\n\n\t\t\t\t\t\tif (!matches) return;\n\t\t\t\t\t\tconst signal = atoms[matches.signal];\n\t\t\t\t\t\tif (!signal) return;\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * To avoid race conditions we set the signal in a setTimeout\n\t\t\t\t\t\t */\n\n\t\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\t\t//@ts-expect-error\n\t\t\t\t\t\t\tsignal.set(Math.random());\n\t\t\t\t\t\t}, 0);\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t},\n\t\t});\n\t}\n\n\treturn createProxy() as T;\n}\n","import {\n\tBetterFetchError,\n\ttype BetterFetch,\n\ttype BetterFetchOption,\n} from \"@better-fetch/fetch\";\nimport { atom, type PreinitializedWritableAtom } from \"nanostores\";\n\nexport const useAuthQuery = <T>(\n\tinitializedAtom:\n\t\t| PreinitializedWritableAtom<any>\n\t\t| PreinitializedWritableAtom<any>[],\n\tpath: string,\n\t$fetch: BetterFetch,\n\toptions?: (() => BetterFetchOption) | BetterFetchOption,\n) => {\n\tconst value = atom<{\n\t\tdata: null | T;\n\t\terror: null | BetterFetchError;\n\t\tisPending: boolean;\n\t}>({\n\t\tdata: null,\n\t\terror: null,\n\t\tisPending: false,\n\t});\n\n\tconst fn = () => {\n\t\tconst opts = typeof options === \"function\" ? options() : options;\n\t\treturn $fetch<T>(path, {\n\t\t\t...opts,\n\t\t\tonSuccess: async (context) => {\n\t\t\t\tvalue.set({\n\t\t\t\t\tdata: context.data,\n\t\t\t\t\terror: null,\n\t\t\t\t\tisPending: false,\n\t\t\t\t});\n\t\t\t\tawait opts?.onSuccess?.(context);\n\t\t\t},\n\t\t\tasync onError(context) {\n\t\t\t\tvalue.set({\n\t\t\t\t\terror: context.error,\n\t\t\t\t\tdata: null,\n\t\t\t\t\tisPending: false,\n\t\t\t\t});\n\t\t\t\tawait opts?.onError?.(context);\n\t\t\t},\n\t\t\tasync onRequest(context) {\n\t\t\t\tconst currentValue = value.get();\n\t\t\t\tvalue.set({\n\t\t\t\t\tisPending: true,\n\t\t\t\t\tdata: currentValue.data,\n\t\t\t\t\terror: currentValue.error,\n\t\t\t\t});\n\t\t\t\tawait opts?.onRequest?.(context);\n\t\t\t},\n\t\t});\n\t};\n\tfn();\n\tinitializedAtom = Array.isArray(initializedAtom)\n\t\t? initializedAtom\n\t\t: [initializedAtom];\n\tlet firstRun = true;\n\tfor (const initAtom of initializedAtom) {\n\t\tinitAtom.subscribe((value) => {\n\t\t\tif (value && !firstRun) {\n\t\t\t\tfn();\n\t\t\t}\n\t\t});\n\t}\n\tfirstRun = false;\n\treturn value;\n};\n","import type { BetterFetch } from \"@better-fetch/fetch\";\nimport { atom } from \"nanostores\";\nimport type { Auth as BetterAuth } from \"../auth\";\nimport type { Prettify, UnionToIntersection } from \"../types/helper\";\nimport type { InferSession, InferUser } from \"../types/models\";\nimport type { AuthClientPlugin, ClientOptions } from \"./types\";\nimport { useAuthQuery } from \"./query\";\nimport type { BetterAuthPlugin } from \"../plugins\";\n\nexport function getSessionAtom<Option extends ClientOptions>(\n\tclient: BetterFetch,\n) {\n\ttype Plugins = Option[\"plugins\"] extends Array<AuthClientPlugin>\n\t\t? Array<\n\t\t\t\tOption[\"plugins\"][number] extends infer T\n\t\t\t\t\t? T extends AuthClientPlugin\n\t\t\t\t\t\t? T[\"$InferServerPlugin\"] extends infer U\n\t\t\t\t\t\t\t? U extends BetterAuthPlugin\n\t\t\t\t\t\t\t\t? U\n\t\t\t\t\t\t\t\t: never\n\t\t\t\t\t\t\t: never\n\t\t\t\t\t\t: never\n\t\t\t\t\t: never\n\t\t\t>\n\t\t: never;\n\n\ttype Auth = {\n\t\thandler: any;\n\t\tapi: any;\n\t\toptions: {\n\t\t\tdatabase: any;\n\t\t\tplugins: Plugins;\n\t\t};\n\t};\n\n\ttype UserWithAdditionalFields = InferUser<Auth[\"options\"]>;\n\ttype SessionWithAdditionalFields = InferSession<Auth[\"options\"]>;\n\tconst $signal = atom<boolean>(false);\n\tconst session = useAuthQuery<{\n\t\tuser: Prettify<UserWithAdditionalFields>;\n\t\tsession: Prettify<SessionWithAdditionalFields>;\n\t}>($signal, \"/session\", client, {\n\t\tmethod: \"GET\",\n\t});\n\treturn {\n\t\t$session: session,\n\t\t_sessionSignal: $signal,\n\t\t$infer: {} as {\n\t\t\tsession: {\n\t\t\t\tsession: Prettify<SessionWithAdditionalFields>;\n\t\t\t\tuser: Prettify<UserWithAdditionalFields>;\n\t\t\t};\n\t\t},\n\t};\n}\n","import { getClientConfig } from \"./config\";\nimport { capitalizeFirstLetter } from \"../utils/misc\";\nimport type {\n\tAuthClientPlugin,\n\tClientOptions,\n\tInferActions,\n\tInferClientAPI,\n\tInferSessionFromClient,\n\tInferUserFromClient,\n\tIsSignal,\n} from \"./types\";\nimport { createDynamicPathProxy } from \"./proxy\";\nimport { getSessionAtom } from \"./session-atom\";\nimport type { UnionToIntersection } from \"../types/helper\";\n\ntype InferResolvedHooks<O extends ClientOptions> = O[\"plugins\"] extends Array<\n\tinfer Plugin\n>\n\t? Plugin extends AuthClientPlugin\n\t\t? Plugin[\"getAtoms\"] extends (fetch: any) => infer Atoms\n\t\t\t? Atoms extends Record<string, any>\n\t\t\t\t? {\n\t\t\t\t\t\t[key in keyof Atoms as IsSignal<key> extends true\n\t\t\t\t\t\t\t? never\n\t\t\t\t\t\t\t: key extends string\n\t\t\t\t\t\t\t\t? `use${Capitalize<key>}`\n\t\t\t\t\t\t\t\t: never]: Atoms[key];\n\t\t\t\t\t}\n\t\t\t\t: {}\n\t\t\t: {}\n\t\t: {}\n\t: {};\n\nexport function createAuthClient<Option extends ClientOptions>(\n\toptions?: Option,\n) {\n\tconst {\n\t\tpluginPathMethods,\n\t\tpluginsActions,\n\t\tpluginsAtoms,\n\t\t$fetch,\n\t\tatomListeners,\n\t} = getClientConfig(options);\n\tlet resolvedHooks: Record<string, any> = {};\n\tfor (const [key, value] of Object.entries(pluginsAtoms)) {\n\t\tresolvedHooks[`use${capitalizeFirstLetter(key)}`] = value;\n\t}\n\n\tconst { $session, _sessionSignal } = getSessionAtom<Option>($fetch);\n\tconst routes = {\n\t\t...pluginsActions,\n\t\t...resolvedHooks,\n\t\t$fetch,\n\t\tuseSession: $session,\n\t};\n\tconst proxy = createDynamicPathProxy(\n\t\troutes,\n\t\t$fetch,\n\t\tpluginPathMethods,\n\t\t{\n\t\t\t...pluginsAtoms,\n\t\t\t_sessionSignal,\n\t\t},\n\t\tatomListeners,\n\t);\n\treturn proxy as UnionToIntersection<InferResolvedHooks<Option>> &\n\t\tInferClientAPI<Option> &\n\t\tInferActions<Option> & {\n\t\t\tuseSession: typeof $session;\n\t\t\t$fetch: typeof $fetch;\n\t\t\t$infer: {\n\t\t\t\tsession: InferSessionFromClient<Option>;\n\t\t\t\tuser: InferUserFromClient<Option>;\n\t\t\t};\n\t\t};\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/error/better-auth-error.ts","../src/utils/base-url.ts","../src/client/fetch-plugins.ts","../src/client/config.ts","../src/utils/misc.ts","../src/client/proxy.ts","../src/client/query.ts","../src/client/session-atom.ts","../src/client/vanilla.ts"],"names":["value","atom"],"mappings":";;;;;;AAAO,IAAM,eAAA,GAAN,cAA8B,KAAM,CAAA;AAAA,EAC1C,YAAY,OAAiB,EAAA;AAC5B,IAAA,KAAA,CAAM,OAAO,CAAA,CAAA;AAAA,GACd;AACD,CAAA,CAAA;;;ACFA,SAAS,aAAa,GAAsB,EAAA;AAC3C,EAAI,IAAA;AACH,IAAM,MAAA,SAAA,GAAY,IAAI,GAAA,CAAI,GAAG,CAAA,CAAA;AAC7B,IAAA,O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AA,OAAA;AAAA,IACV,cAAgB,EAAA,OAAA;AAAA,IAChB,QAAQ,EAAC;AAAA,GAMV,CAAA;AACD,CAAA;;;ACrBO,SAAS,iBACf,OACC,EAAA;AACD,EAAM,MAAA;AAAA,IACL,iBAAA;AAAA,IACA,cAAA;AAAA,IACA,YAAA;AAAA,IACA,MAAA;AAAA,IACA,aAAA;AAAA,GACD,GAAI,gBAAgB,OAAO,CAAA,CAAA;AAC3B,EAAA,IAAI,gBAAqC,EAAC,CAAA;AAC1C,EAAA,KAAA,MAAW,CAAC,GAAK,EAAA,KAAK,KAAK,MAAO,CAAA,OAAA,CAAQ,YAAY,CAAG,EAAA;AACxD,IAAA,aAAA,CAAc,CAAM,GAAA,EAAA,qBAAA,CAAsB,GAAG,CAAC,EAAE,CAAI,GAAA,KAAA,CAAA;AAAA,GACrD;AAEA,EAAA,MAAM,EAAE,QAAA,EAAU,cAAe,EAAA,GAAI,eAAuB,MAAM,CAAA,CAAA;AAClE,EAAA,MAAM,MAAS,GAAA;AAAA,IACd,GAAG,cAAA;AAAA,IACH,GAAG,aAAA;AAAA,IACH,MAAA;AAAA,IACA,UAAY,EAAA,QAAA;AAAA,GACb,CAAA;AACA,EAAA,MAAM,KAAQ,GAAA,sBAAA;AAAA,IACb,MAAA;AAAA,IACA,MAAA;AAAA,IACA,iBAAA;AAAA,IACA;AAAA,MACC,GAAG,YAAA;AAAA,MACH,cAAA;AAAA,KACD;AAAA,IACA,aAAA;AAAA,GACD,CAAA;AACA,EAAO,OAAA,KAAA,CAAA;AAUR","file":"client.js","sourcesContent":["export class BetterAuthError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t}\n}\n","import { BetterAuthError } from \"../error/better-auth-error\";\n\nfunction checkHasPath(url: string): boolean {\n\ttry {\n\t\tconst parsedUrl = new URL(url);\n\t\treturn parsedUrl.pathname !== \"/\";\n\t} catch (error) {\n\t\tthrow new BetterAuthError(\n\t\t\t`Invalid base URL: ${url}. Please provide a valid base URL.`,\n\t\t);\n\t}\n}\n\nfunction withPath(url: string, path = \"/api/auth\") {\n\tconst hasPath = checkHasPath(url);\n\tif (hasPath) {\n\t\treturn url;\n\t}\n\tpath = path.startsWith(\"/\") ? path : `/${path}`;\n\treturn `${url}${path}`;\n}\n\nexport function getBaseURL(url?: string, path?: string) {\n\tif (url) {\n\t\treturn withPath(url, path);\n\t}\n\tconst env: any = typeof process !== \"undefined\" ? process.env : {};\n\tconst fromEnv =\n\t\tenv.BETTER_AUTH_URL ||\n\t\tenv.NEXT_PUBLIC_BETTER_AUTH_URL ||\n\t\tenv.PUBLIC_BETTER_AUTH_URL ||\n\t\tenv.NUXT_PUBLIC_BETTER_AUTH_URL ||\n\t\tenv.NUXT_PUBLIC_AUTH_URL;\n\tif (fromEnv) {\n\t\treturn withPath(fromEnv, path);\n\t}\n\n\tif (typeof window !== \"undefined\") {\n\t\treturn withPath(window.location.origin, path);\n\t}\n\treturn undefined;\n}\n","import { type BetterFetchPlugin, betterFetch } from \"@better-fetch/fetch\";\nimport { BetterAuthError } from \"../error/better-auth-error\";\n\nexport const redirectPlugin = {\n\tid: \"redirect\",\n\tname: \"Redirect\",\n\thooks: {\n\t\tonSuccess(context) {\n\t\t\tif (context.data?.url && context.data?.redirect) {\n\t\t\t\tif (typeof window !== \"undefined\") {\n\t\t\t\t\twindow.location.href = context.data.url;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t},\n} satisfies BetterFetchPlugin;\n\nexport const addCurrentURL = {\n\tid: \"add-current-url\",\n\tname: \"Add current URL\",\n\thooks: {\n\t\tonRequest(context) {\n\t\t\tif (typeof window !== \"undefined\") {\n\t\t\t\tconst url = new URL(context.url);\n\t\t\t\turl.searchParams.set(\"currentURL\", window.location.href);\n\t\t\t\tcontext.url = url;\n\t\t\t}\n\t\t\treturn context;\n\t\t},\n\t},\n} satisfies BetterFetchPlugin;\n\nexport const csrfPlugin = {\n\tid: \"csrf\",\n\tname: \"CSRF Check\",\n\tasync init(url, options) {\n\t\tif (!options?.baseURL) {\n\t\t\tthrow new BetterAuthError(\n\t\t\t\t\"API Base URL on the auth client isn't configured. Please pass it directly to the client `baseURL`\",\n\t\t\t);\n\t\t}\n\n\t\tif (options?.method !== \"GET\") {\n\t\t\toptions = options || {};\n\t\t\tconst { data, error } = await betterFetch<{\n\t\t\t\tcsrfToken: string;\n\t\t\t}>(\"/csrf\", {\n\t\t\t\tbody: undefined,\n\t\t\t\tbaseURL: options.baseURL,\n\t\t\t\tplugins: [],\n\t\t\t\tmethod: \"GET\",\n\t\t\t\tcredentials: \"include\",\n\t\t\t\tcustomFetchImpl: options.customFetchImpl,\n\t\t\t});\n\t\t\tif (error?.status === 404) {\n\t\t\t\tthrow new BetterAuthError(\n\t\t\t\t\t\"Route not found. Make sure the server is running and the base URL is correct and includes the path (e.g. http://localhost:3000/api/auth).\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (error) {\n\t\t\t\tthrow new BetterAuthError(error.message || \"Failed to get CSRF token.\");\n\t\t\t}\n\t\t\toptions.body = {\n\t\t\t\t...options?.body,\n\t\t\t\tcsrfToken: data.csrfToken,\n\t\t\t};\n\t\t}\n\t\toptions.credentials = \"include\";\n\t\treturn { url, options };\n\t},\n} satisfies BetterFetchPlugin;\n","import { createFetch } from \"@better-fetch/fetch\";\nimport { getBaseURL } from \"../utils/base-url\";\nimport { type Atom } from \"nanostores\";\nimport type { AtomListener, ClientOptions } from \"./types\";\n\nimport { addCurrentURL, csrfPlugin, redirectPlugin } from \"./fetch-plugins\";\nimport type { InferSession } from \"../types\";\n\nexport const getClientConfig = <O extends ClientOptions>(options?: O) => {\n\tconst $fetch = createFetch({\n\t\tbaseURL: getBaseURL(options?.fetchOptions?.baseURL || options?.baseURL),\n\t\t...options?.fetchOptions,\n\t\tplugins: [\n\t\t\tcsrfPlugin,\n\t\t\tredirectPlugin,\n\t\t\taddCurrentURL,\n\t\t\t...(options?.fetchOptions?.plugins || []),\n\t\t\t...(options?.plugins\n\t\t\t\t?.flatMap((plugin) => plugin.fetchPlugins)\n\t\t\t\t.filter((pl) => pl !== undefined) || []),\n\t\t],\n\t});\n\tconst plugins = options?.plugins || [];\n\tlet pluginsActions = {} as Record<string, any>;\n\tlet pluginsAtoms = {} as Record<string, Atom<any>>;\n\tlet pluginPathMethods: Record<string, \"POST\" | \"GET\"> = {\n\t\t\"/sign-out\": \"POST\",\n\t\t\"/user/revoke-sessions\": \"POST\",\n\t};\n\tconst atomListeners: AtomListener[] = [\n\t\t{\n\t\t\tsignal: \"_sessionSignal\",\n\t\t\tmatcher(path) {\n\t\t\t\treturn (\n\t\t\t\t\tpath === \"/sign-out\" ||\n\t\t\t\t\tpath === \"sign-up/email\" ||\n\t\t\t\t\tpath === \"/user/update\"\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t];\n\tfor (const plugin of plugins) {\n\t\tif (plugin.getActions) {\n\t\t\tObject.assign(pluginsActions, plugin.getActions?.($fetch));\n\t\t}\n\t\tif (plugin.getAtoms) {\n\t\t\tObject.assign(pluginsAtoms, plugin.getAtoms?.($fetch));\n\t\t}\n\t\tif (plugin.pathMethods) {\n\t\t\tObject.assign(pluginPathMethods, plugin.pathMethods);\n\t\t}\n\t\tif (plugin.atomListeners) {\n\t\t\tatomListeners.push(...plugin.atomListeners);\n\t\t}\n\t}\n\treturn {\n\t\tpluginsActions,\n\t\tpluginsAtoms,\n\t\tpluginPathMethods,\n\t\tatomListeners,\n\t\t$fetch,\n\t};\n};\n","export function capitalizeFirstLetter(str: string) {\n\treturn str.charAt(0).toUpperCase() + str.slice(1);\n}\n","import type { BetterFetch } from \"@better-fetch/fetch\";\nimport type { Atom, PreinitializedWritableAtom } from \"nanostores\";\nimport type { ProxyRequest } from \"./path-to-object\";\nimport type { AuthClientPlugin } from \"./types\";\n\nfunction getMethod(\n\tpath: string,\n\tknownPathMethods: Record<string, \"POST\" | \"GET\">,\n\targs?: ProxyRequest,\n) {\n\tconst method = knownPathMethods[path];\n\tconst { options, query, ...body } = args || {};\n\tif (method) {\n\t\treturn method;\n\t}\n\tif (options?.method) {\n\t\treturn options.method;\n\t}\n\tif (body && Object.keys(body).length > 0) {\n\t\treturn \"POST\";\n\t}\n\treturn \"GET\";\n}\n\nexport type AuthProxySignal = {\n\tatom: PreinitializedWritableAtom<boolean>;\n\tmatcher: (path: string) => boolean;\n};\n\nexport function createDynamicPathProxy<T extends Record<string, any>>(\n\troutes: T,\n\tclient: BetterFetch,\n\tknownPathMethods: Record<string, \"POST\" | \"GET\">,\n\tatoms: Record<string, Atom>,\n\tatomListeners: AuthClientPlugin[\"atomListeners\"],\n): T {\n\tfunction createProxy(path: string[] = []): any {\n\t\treturn new Proxy(function () {}, {\n\t\t\tget(target, prop: string) {\n\t\t\t\tconst fullPath = [...path, prop];\n\t\t\t\tlet current: any = routes;\n\t\t\t\tfor (const segment of fullPath) {\n\t\t\t\t\tif (current && typeof current === \"object\" && segment in current) {\n\t\t\t\t\t\tcurrent = current[segment];\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcurrent = undefined;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (typeof current === \"function\") {\n\t\t\t\t\treturn current;\n\t\t\t\t}\n\t\t\t\treturn createProxy(fullPath);\n\t\t\t},\n\t\t\tapply: async (_, __, args) => {\n\t\t\t\tconst routePath =\n\t\t\t\t\t\"/\" +\n\t\t\t\t\tpath\n\t\t\t\t\t\t.map((segment) =>\n\t\t\t\t\t\t\tsegment.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`),\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.join(\"/\");\n\n\t\t\t\tconst arg = (args[0] || {}) as ProxyRequest;\n\t\t\t\tconst method = getMethod(routePath, knownPathMethods, arg);\n\t\t\t\tconst { query, options, ...body } = arg;\n\n\t\t\t\treturn await client(routePath, {\n\t\t\t\t\t...options,\n\t\t\t\t\tbody:\n\t\t\t\t\t\tmethod === \"GET\"\n\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\t...body,\n\t\t\t\t\t\t\t\t\t...(options?.body || {}),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\tquery: query,\n\t\t\t\t\tmethod,\n\t\t\t\t\tasync onSuccess(context) {\n\t\t\t\t\t\tawait options?.onSuccess?.(context);\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * We trigger listeners\n\t\t\t\t\t\t */\n\t\t\t\t\t\tconst matches = atomListeners?.find((s) => s.matcher(routePath));\n\n\t\t\t\t\t\tif (!matches) return;\n\t\t\t\t\t\tconst signal = atoms[matches.signal];\n\t\t\t\t\t\tif (!signal) return;\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * To avoid race conditions we set the signal in a setTimeout\n\t\t\t\t\t\t */\n\t\t\t\t\t\tconst val = signal.get();\n\t\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\t\t//@ts-expect-error\n\t\t\t\t\t\t\tsignal.set(!val);\n\t\t\t\t\t\t}, 0);\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t},\n\t\t});\n\t}\n\treturn createProxy() as T;\n}\n","import {\n\tBetterFetchError,\n\ttype BetterFetch,\n\ttype BetterFetchOption,\n} from \"@better-fetch/fetch\";\nimport { atom, type PreinitializedWritableAtom } from \"nanostores\";\n\nexport const useAuthQuery = <T>(\n\tinitializedAtom:\n\t\t| PreinitializedWritableAtom<any>\n\t\t| PreinitializedWritableAtom<any>[],\n\tpath: string,\n\t$fetch: BetterFetch,\n\toptions?: (() => BetterFetchOption) | BetterFetchOption,\n) => {\n\tconst value = atom<{\n\t\tdata: null | T;\n\t\terror: null | BetterFetchError;\n\t\tisPending: boolean;\n\t}>({\n\t\tdata: null,\n\t\terror: null,\n\t\tisPending: false,\n\t});\n\n\tconst fn = () => {\n\t\tconst opts = typeof options === \"function\" ? options() : options;\n\t\treturn $fetch<T>(path, {\n\t\t\t...opts,\n\t\t\tonSuccess: async (context) => {\n\t\t\t\tvalue.set({\n\t\t\t\t\tdata: context.data,\n\t\t\t\t\terror: null,\n\t\t\t\t\tisPending: false,\n\t\t\t\t});\n\t\t\t\tawait opts?.onSuccess?.(context);\n\t\t\t},\n\t\t\tasync onError(context) {\n\t\t\t\tvalue.set({\n\t\t\t\t\terror: context.error,\n\t\t\t\t\tdata: null,\n\t\t\t\t\tisPending: false,\n\t\t\t\t});\n\t\t\t\tawait opts?.onError?.(context);\n\t\t\t},\n\t\t\tasync onRequest(context) {\n\t\t\t\tconst currentValue = value.get();\n\t\t\t\tvalue.set({\n\t\t\t\t\tisPending: true,\n\t\t\t\t\tdata: currentValue.data,\n\t\t\t\t\terror: currentValue.error,\n\t\t\t\t});\n\t\t\t\tawait opts?.onRequest?.(context);\n\t\t\t},\n\t\t});\n\t};\n\tfn();\n\tinitializedAtom = Array.isArray(initializedAtom)\n\t\t? initializedAtom\n\t\t: [initializedAtom];\n\tlet firstRun = true;\n\tfor (const initAtom of initializedAtom) {\n\t\tinitAtom.subscribe((value) => {\n\t\t\tif (value && !firstRun) {\n\t\t\t\tfn();\n\t\t\t}\n\t\t});\n\t}\n\tfirstRun = false;\n\treturn value;\n};\n","import type { BetterFetch } from \"@better-fetch/fetch\";\nimport { atom } from \"nanostores\";\nimport type { Auth as BetterAuth } from \"../auth\";\nimport type { Prettify, UnionToIntersection } from \"../types/helper\";\nimport type { InferSession, InferUser } from \"../types/models\";\nimport type { AuthClientPlugin, ClientOptions } from \"./types\";\nimport { useAuthQuery } from \"./query\";\nimport type { BetterAuthPlugin } from \"../plugins\";\n\nexport function getSessionAtom<Option extends ClientOptions>(\n\tclient: BetterFetch,\n) {\n\ttype Plugins = Option[\"plugins\"] extends Array<AuthClientPlugin>\n\t\t? Array<\n\t\t\t\tOption[\"plugins\"][number] extends infer T\n\t\t\t\t\t? T extends AuthClientPlugin\n\t\t\t\t\t\t? T[\"$InferServerPlugin\"] extends infer U\n\t\t\t\t\t\t\t? U extends BetterAuthPlugin\n\t\t\t\t\t\t\t\t? U\n\t\t\t\t\t\t\t\t: never\n\t\t\t\t\t\t\t: never\n\t\t\t\t\t\t: never\n\t\t\t\t\t: never\n\t\t\t>\n\t\t: never;\n\n\ttype Auth = {\n\t\thandler: any;\n\t\tapi: any;\n\t\toptions: {\n\t\t\tdatabase: any;\n\t\t\tplugins: Plugins;\n\t\t};\n\t};\n\n\ttype UserWithAdditionalFields = InferUser<Auth[\"options\"]>;\n\ttype SessionWithAdditionalFields = InferSession<Auth[\"options\"]>;\n\tconst $signal = atom<boolean>(false);\n\tconst session = useAuthQuery<{\n\t\tuser: Prettify<UserWithAdditionalFields>;\n\t\tsession: Prettify<SessionWithAdditionalFields>;\n\t}>($signal, \"/session\", client, {\n\t\tmethod: \"GET\",\n\t});\n\treturn {\n\t\t$session: session,\n\t\t_sessionSignal: $signal,\n\t\t$infer: {} as {\n\t\t\tsession: {\n\t\t\t\tsession: Prettify<SessionWithAdditionalFields>;\n\t\t\t\tuser: Prettify<UserWithAdditionalFields>;\n\t\t\t};\n\t\t},\n\t};\n}\n","import { getClientConfig } from \"./config\";\nimport { capitalizeFirstLetter } from \"../utils/misc\";\nimport type {\n\tAuthClientPlugin,\n\tClientOptions,\n\tInferActions,\n\tInferClientAPI,\n\tInferSessionFromClient,\n\tInferUserFromClient,\n\tIsSignal,\n} from \"./types\";\nimport { createDynamicPathProxy } from \"./proxy\";\nimport { getSessionAtom } from \"./session-atom\";\nimport type { UnionToIntersection } from \"../types/helper\";\n\ntype InferResolvedHooks<O extends ClientOptions> = O[\"plugins\"] extends Array<\n\tinfer Plugin\n>\n\t? Plugin extends AuthClientPlugin\n\t\t? Plugin[\"getAtoms\"] extends (fetch: any) => infer Atoms\n\t\t\t? Atoms extends Record<string, any>\n\t\t\t\t? {\n\t\t\t\t\t\t[key in keyof Atoms as IsSignal<key> extends true\n\t\t\t\t\t\t\t? never\n\t\t\t\t\t\t\t: key extends string\n\t\t\t\t\t\t\t\t? `use${Capitalize<key>}`\n\t\t\t\t\t\t\t\t: never]: Atoms[key];\n\t\t\t\t\t}\n\t\t\t\t: {}\n\t\t\t: {}\n\t\t: {}\n\t: {};\n\nexport function createAuthClient<Option extends ClientOptions>(\n\toptions?: Option,\n) {\n\tconst {\n\t\tpluginPathMethods,\n\t\tpluginsActions,\n\t\tpluginsAtoms,\n\t\t$fetch,\n\t\tatomListeners,\n\t} = getClientConfig(options);\n\tlet resolvedHooks: Record<string, any> = {};\n\tfor (const [key, value] of Object.entries(pluginsAtoms)) {\n\t\tresolvedHooks[`use${capitalizeFirstLetter(key)}`] = value;\n\t}\n\n\tconst { $session, _sessionSignal } = getSessionAtom<Option>($fetch);\n\tconst routes = {\n\t\t...pluginsActions,\n\t\t...resolvedHooks,\n\t\t$fetch,\n\t\tuseSession: $session,\n\t};\n\tconst proxy = createDynamicPathProxy(\n\t\troutes,\n\t\t$fetch,\n\t\tpluginPathMethods,\n\t\t{\n\t\t\t...pluginsAtoms,\n\t\t\t_sessionSignal,\n\t\t},\n\t\tatomListeners,\n\t);\n\treturn proxy as UnionToIntersection<InferResolvedHooks<Option>> &\n\t\tInferClientAPI<Option> &\n\t\tInferActions<Option> & {\n\t\t\tuseSession: typeof $session;\n\t\t\t$fetch: typeof $fetch;\n\t\t\t$infer: {\n\t\t\t\tsession: InferSessionFromClient<Option>;\n\t\t\t\tuser: InferUserFromClient<Option>;\n\t\t\t};\n\t\t};\n}\n"]}
|
|
@@ -4,7 +4,7 @@ import { A as AccessControl, R as Role, S as StatementsPrimitive, g as defaultRo
|
|
|
4
4
|
import { z, ZodObject, ZodOptional, ZodArray, ZodLiteral } from 'zod';
|
|
5
5
|
import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
6
6
|
import { BetterFetch } from '@better-fetch/fetch';
|
|
7
|
-
import { H as HookEndpointContext } from './internal-adapter-
|
|
7
|
+
import { H as HookEndpointContext } from './internal-adapter-DXjewSmi.js';
|
|
8
8
|
import * as _simplewebauthn_types from '@simplewebauthn/types';
|
|
9
9
|
import { CredentialDeviceType, PublicKeyCredentialCreationOptionsJSON } from '@simplewebauthn/types';
|
|
10
10
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as BetterAuthOptions, F as FieldAttribute, I as InferFieldOutput, e as AuthContext } from './internal-adapter-
|
|
1
|
+
import { a as BetterAuthOptions, F as FieldAttribute, I as InferFieldOutput, e as AuthContext } from './internal-adapter-DXjewSmi.js';
|
|
2
2
|
import { U as UnionToIntersection, P as Prettify } from './helper-D8dhRz72.js';
|
|
3
3
|
import { U as User, S as Session } from './index-CcxejJTH.js';
|
|
4
4
|
import * as zod from 'zod';
|
|
@@ -567,13 +567,16 @@ declare const router: <C extends AuthContext, Option extends BetterAuthOptions>(
|
|
|
567
567
|
method: "POST";
|
|
568
568
|
body: zod.ZodObject<{
|
|
569
569
|
newPassword: zod.ZodString;
|
|
570
|
-
|
|
570
|
+
currentPassword: zod.ZodString;
|
|
571
|
+
revokeOtherSessions: zod.ZodOptional<zod.ZodBoolean>;
|
|
571
572
|
}, "strip", zod.ZodTypeAny, {
|
|
572
573
|
newPassword: string;
|
|
573
|
-
|
|
574
|
+
currentPassword: string;
|
|
575
|
+
revokeOtherSessions?: boolean | undefined;
|
|
574
576
|
}, {
|
|
575
577
|
newPassword: string;
|
|
576
|
-
|
|
578
|
+
currentPassword: string;
|
|
579
|
+
revokeOtherSessions?: boolean | undefined;
|
|
577
580
|
}>;
|
|
578
581
|
use: Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
|
|
579
582
|
session: {
|
|
@@ -609,13 +612,16 @@ declare const router: <C extends AuthContext, Option extends BetterAuthOptions>(
|
|
|
609
612
|
method: "POST";
|
|
610
613
|
body: zod.ZodObject<{
|
|
611
614
|
newPassword: zod.ZodString;
|
|
612
|
-
|
|
615
|
+
currentPassword: zod.ZodString;
|
|
616
|
+
revokeOtherSessions: zod.ZodOptional<zod.ZodBoolean>;
|
|
613
617
|
}, "strip", zod.ZodTypeAny, {
|
|
614
618
|
newPassword: string;
|
|
615
|
-
|
|
619
|
+
currentPassword: string;
|
|
620
|
+
revokeOtherSessions?: boolean | undefined;
|
|
616
621
|
}, {
|
|
617
622
|
newPassword: string;
|
|
618
|
-
|
|
623
|
+
currentPassword: string;
|
|
624
|
+
revokeOtherSessions?: boolean | undefined;
|
|
619
625
|
}>;
|
|
620
626
|
use: Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
|
|
621
627
|
session: {
|
|
@@ -720,6 +726,183 @@ declare const router: <C extends AuthContext, Option extends BetterAuthOptions>(
|
|
|
720
726
|
method: better_call.Method | better_call.Method[];
|
|
721
727
|
headers: Headers;
|
|
722
728
|
};
|
|
729
|
+
listSessions: {
|
|
730
|
+
(ctx_0?: Context<"/user/list-sessions", {
|
|
731
|
+
method: "GET";
|
|
732
|
+
use: Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
|
|
733
|
+
session: {
|
|
734
|
+
session: {
|
|
735
|
+
id: string;
|
|
736
|
+
userId: string;
|
|
737
|
+
expiresAt: Date;
|
|
738
|
+
ipAddress?: string | undefined;
|
|
739
|
+
userAgent?: string | undefined;
|
|
740
|
+
};
|
|
741
|
+
user: {
|
|
742
|
+
id: string;
|
|
743
|
+
email: string;
|
|
744
|
+
emailVerified: boolean;
|
|
745
|
+
name: string;
|
|
746
|
+
createdAt: Date;
|
|
747
|
+
updatedAt: Date;
|
|
748
|
+
image?: string | undefined;
|
|
749
|
+
};
|
|
750
|
+
};
|
|
751
|
+
}>, better_call.EndpointOptions>[];
|
|
752
|
+
}> | undefined): Promise<{
|
|
753
|
+
id: string;
|
|
754
|
+
userId: string;
|
|
755
|
+
expiresAt: Date;
|
|
756
|
+
ipAddress?: string | undefined;
|
|
757
|
+
userAgent?: string | undefined;
|
|
758
|
+
}[]>;
|
|
759
|
+
path: "/user/list-sessions";
|
|
760
|
+
options: {
|
|
761
|
+
method: "GET";
|
|
762
|
+
use: Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
|
|
763
|
+
session: {
|
|
764
|
+
session: {
|
|
765
|
+
id: string;
|
|
766
|
+
userId: string;
|
|
767
|
+
expiresAt: Date;
|
|
768
|
+
ipAddress?: string | undefined;
|
|
769
|
+
userAgent?: string | undefined;
|
|
770
|
+
};
|
|
771
|
+
user: {
|
|
772
|
+
id: string;
|
|
773
|
+
email: string;
|
|
774
|
+
emailVerified: boolean;
|
|
775
|
+
name: string;
|
|
776
|
+
createdAt: Date;
|
|
777
|
+
updatedAt: Date;
|
|
778
|
+
image?: string | undefined;
|
|
779
|
+
};
|
|
780
|
+
};
|
|
781
|
+
}>, better_call.EndpointOptions>[];
|
|
782
|
+
};
|
|
783
|
+
method: better_call.Method | better_call.Method[];
|
|
784
|
+
headers: Headers;
|
|
785
|
+
};
|
|
786
|
+
revokeSession: {
|
|
787
|
+
(ctx_0: Context<"/user/revoke-session", {
|
|
788
|
+
method: "POST";
|
|
789
|
+
body: zod.ZodObject<{
|
|
790
|
+
id: zod.ZodString;
|
|
791
|
+
}, "strip", zod.ZodTypeAny, {
|
|
792
|
+
id: string;
|
|
793
|
+
}, {
|
|
794
|
+
id: string;
|
|
795
|
+
}>;
|
|
796
|
+
use: Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
|
|
797
|
+
session: {
|
|
798
|
+
session: {
|
|
799
|
+
id: string;
|
|
800
|
+
userId: string;
|
|
801
|
+
expiresAt: Date;
|
|
802
|
+
ipAddress?: string | undefined;
|
|
803
|
+
userAgent?: string | undefined;
|
|
804
|
+
};
|
|
805
|
+
user: {
|
|
806
|
+
id: string;
|
|
807
|
+
email: string;
|
|
808
|
+
emailVerified: boolean;
|
|
809
|
+
name: string;
|
|
810
|
+
createdAt: Date;
|
|
811
|
+
updatedAt: Date;
|
|
812
|
+
image?: string | undefined;
|
|
813
|
+
};
|
|
814
|
+
};
|
|
815
|
+
}>, better_call.EndpointOptions>[];
|
|
816
|
+
}>): Promise<{
|
|
817
|
+
status: boolean;
|
|
818
|
+
}>;
|
|
819
|
+
path: "/user/revoke-session";
|
|
820
|
+
options: {
|
|
821
|
+
method: "POST";
|
|
822
|
+
body: zod.ZodObject<{
|
|
823
|
+
id: zod.ZodString;
|
|
824
|
+
}, "strip", zod.ZodTypeAny, {
|
|
825
|
+
id: string;
|
|
826
|
+
}, {
|
|
827
|
+
id: string;
|
|
828
|
+
}>;
|
|
829
|
+
use: Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
|
|
830
|
+
session: {
|
|
831
|
+
session: {
|
|
832
|
+
id: string;
|
|
833
|
+
userId: string;
|
|
834
|
+
expiresAt: Date;
|
|
835
|
+
ipAddress?: string | undefined;
|
|
836
|
+
userAgent?: string | undefined;
|
|
837
|
+
};
|
|
838
|
+
user: {
|
|
839
|
+
id: string;
|
|
840
|
+
email: string;
|
|
841
|
+
emailVerified: boolean;
|
|
842
|
+
name: string;
|
|
843
|
+
createdAt: Date;
|
|
844
|
+
updatedAt: Date;
|
|
845
|
+
image?: string | undefined;
|
|
846
|
+
};
|
|
847
|
+
};
|
|
848
|
+
}>, better_call.EndpointOptions>[];
|
|
849
|
+
};
|
|
850
|
+
method: better_call.Method | better_call.Method[];
|
|
851
|
+
headers: Headers;
|
|
852
|
+
};
|
|
853
|
+
revokeSessions: {
|
|
854
|
+
(ctx_0?: Context<"/user/revoke-sessions", {
|
|
855
|
+
method: "POST";
|
|
856
|
+
use: Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
|
|
857
|
+
session: {
|
|
858
|
+
session: {
|
|
859
|
+
id: string;
|
|
860
|
+
userId: string;
|
|
861
|
+
expiresAt: Date;
|
|
862
|
+
ipAddress?: string | undefined;
|
|
863
|
+
userAgent?: string | undefined;
|
|
864
|
+
};
|
|
865
|
+
user: {
|
|
866
|
+
id: string;
|
|
867
|
+
email: string;
|
|
868
|
+
emailVerified: boolean;
|
|
869
|
+
name: string;
|
|
870
|
+
createdAt: Date;
|
|
871
|
+
updatedAt: Date;
|
|
872
|
+
image?: string | undefined;
|
|
873
|
+
};
|
|
874
|
+
};
|
|
875
|
+
}>, better_call.EndpointOptions>[];
|
|
876
|
+
}> | undefined): Promise<{
|
|
877
|
+
status: boolean;
|
|
878
|
+
}>;
|
|
879
|
+
path: "/user/revoke-sessions";
|
|
880
|
+
options: {
|
|
881
|
+
method: "POST";
|
|
882
|
+
use: Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
|
|
883
|
+
session: {
|
|
884
|
+
session: {
|
|
885
|
+
id: string;
|
|
886
|
+
userId: string;
|
|
887
|
+
expiresAt: Date;
|
|
888
|
+
ipAddress?: string | undefined;
|
|
889
|
+
userAgent?: string | undefined;
|
|
890
|
+
};
|
|
891
|
+
user: {
|
|
892
|
+
id: string;
|
|
893
|
+
email: string;
|
|
894
|
+
emailVerified: boolean;
|
|
895
|
+
name: string;
|
|
896
|
+
createdAt: Date;
|
|
897
|
+
updatedAt: Date;
|
|
898
|
+
image?: string | undefined;
|
|
899
|
+
};
|
|
900
|
+
};
|
|
901
|
+
}>, better_call.EndpointOptions>[];
|
|
902
|
+
};
|
|
903
|
+
method: better_call.Method | better_call.Method[];
|
|
904
|
+
headers: Headers;
|
|
905
|
+
};
|
|
723
906
|
}, "error" | "ok" | "welcome">;
|
|
724
907
|
};
|
|
725
908
|
|
|
@@ -1267,13 +1450,16 @@ declare const betterAuth: <O extends BetterAuthOptions>(options: O) => {
|
|
|
1267
1450
|
method: "POST";
|
|
1268
1451
|
body: zod.ZodObject<{
|
|
1269
1452
|
newPassword: zod.ZodString;
|
|
1270
|
-
|
|
1453
|
+
currentPassword: zod.ZodString;
|
|
1454
|
+
revokeOtherSessions: zod.ZodOptional<zod.ZodBoolean>;
|
|
1271
1455
|
}, "strip", zod.ZodTypeAny, {
|
|
1272
1456
|
newPassword: string;
|
|
1273
|
-
|
|
1457
|
+
currentPassword: string;
|
|
1458
|
+
revokeOtherSessions?: boolean | undefined;
|
|
1274
1459
|
}, {
|
|
1275
1460
|
newPassword: string;
|
|
1276
|
-
|
|
1461
|
+
currentPassword: string;
|
|
1462
|
+
revokeOtherSessions?: boolean | undefined;
|
|
1277
1463
|
}>;
|
|
1278
1464
|
use: Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
|
|
1279
1465
|
session: {
|
|
@@ -1309,13 +1495,16 @@ declare const betterAuth: <O extends BetterAuthOptions>(options: O) => {
|
|
|
1309
1495
|
method: "POST";
|
|
1310
1496
|
body: zod.ZodObject<{
|
|
1311
1497
|
newPassword: zod.ZodString;
|
|
1312
|
-
|
|
1498
|
+
currentPassword: zod.ZodString;
|
|
1499
|
+
revokeOtherSessions: zod.ZodOptional<zod.ZodBoolean>;
|
|
1313
1500
|
}, "strip", zod.ZodTypeAny, {
|
|
1314
1501
|
newPassword: string;
|
|
1315
|
-
|
|
1502
|
+
currentPassword: string;
|
|
1503
|
+
revokeOtherSessions?: boolean | undefined;
|
|
1316
1504
|
}, {
|
|
1317
1505
|
newPassword: string;
|
|
1318
|
-
|
|
1506
|
+
currentPassword: string;
|
|
1507
|
+
revokeOtherSessions?: boolean | undefined;
|
|
1319
1508
|
}>;
|
|
1320
1509
|
use: Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
|
|
1321
1510
|
session: {
|
|
@@ -1420,6 +1609,183 @@ declare const betterAuth: <O extends BetterAuthOptions>(options: O) => {
|
|
|
1420
1609
|
method: better_call.Method | better_call.Method[];
|
|
1421
1610
|
headers: Headers;
|
|
1422
1611
|
};
|
|
1612
|
+
listSessions: {
|
|
1613
|
+
(ctx_0?: better_call.Context<"/user/list-sessions", {
|
|
1614
|
+
method: "GET";
|
|
1615
|
+
use: Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
|
|
1616
|
+
session: {
|
|
1617
|
+
session: {
|
|
1618
|
+
id: string;
|
|
1619
|
+
userId: string;
|
|
1620
|
+
expiresAt: Date;
|
|
1621
|
+
ipAddress?: string | undefined;
|
|
1622
|
+
userAgent?: string | undefined;
|
|
1623
|
+
};
|
|
1624
|
+
user: {
|
|
1625
|
+
id: string;
|
|
1626
|
+
email: string;
|
|
1627
|
+
emailVerified: boolean;
|
|
1628
|
+
name: string;
|
|
1629
|
+
createdAt: Date;
|
|
1630
|
+
updatedAt: Date;
|
|
1631
|
+
image?: string | undefined;
|
|
1632
|
+
};
|
|
1633
|
+
};
|
|
1634
|
+
}>, better_call.EndpointOptions>[];
|
|
1635
|
+
}> | undefined): Promise<{
|
|
1636
|
+
id: string;
|
|
1637
|
+
userId: string;
|
|
1638
|
+
expiresAt: Date;
|
|
1639
|
+
ipAddress?: string | undefined;
|
|
1640
|
+
userAgent?: string | undefined;
|
|
1641
|
+
}[]>;
|
|
1642
|
+
path: "/user/list-sessions";
|
|
1643
|
+
options: {
|
|
1644
|
+
method: "GET";
|
|
1645
|
+
use: Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
|
|
1646
|
+
session: {
|
|
1647
|
+
session: {
|
|
1648
|
+
id: string;
|
|
1649
|
+
userId: string;
|
|
1650
|
+
expiresAt: Date;
|
|
1651
|
+
ipAddress?: string | undefined;
|
|
1652
|
+
userAgent?: string | undefined;
|
|
1653
|
+
};
|
|
1654
|
+
user: {
|
|
1655
|
+
id: string;
|
|
1656
|
+
email: string;
|
|
1657
|
+
emailVerified: boolean;
|
|
1658
|
+
name: string;
|
|
1659
|
+
createdAt: Date;
|
|
1660
|
+
updatedAt: Date;
|
|
1661
|
+
image?: string | undefined;
|
|
1662
|
+
};
|
|
1663
|
+
};
|
|
1664
|
+
}>, better_call.EndpointOptions>[];
|
|
1665
|
+
};
|
|
1666
|
+
method: better_call.Method | better_call.Method[];
|
|
1667
|
+
headers: Headers;
|
|
1668
|
+
};
|
|
1669
|
+
revokeSession: {
|
|
1670
|
+
(ctx_0: better_call.Context<"/user/revoke-session", {
|
|
1671
|
+
method: "POST";
|
|
1672
|
+
body: zod.ZodObject<{
|
|
1673
|
+
id: zod.ZodString;
|
|
1674
|
+
}, "strip", zod.ZodTypeAny, {
|
|
1675
|
+
id: string;
|
|
1676
|
+
}, {
|
|
1677
|
+
id: string;
|
|
1678
|
+
}>;
|
|
1679
|
+
use: Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
|
|
1680
|
+
session: {
|
|
1681
|
+
session: {
|
|
1682
|
+
id: string;
|
|
1683
|
+
userId: string;
|
|
1684
|
+
expiresAt: Date;
|
|
1685
|
+
ipAddress?: string | undefined;
|
|
1686
|
+
userAgent?: string | undefined;
|
|
1687
|
+
};
|
|
1688
|
+
user: {
|
|
1689
|
+
id: string;
|
|
1690
|
+
email: string;
|
|
1691
|
+
emailVerified: boolean;
|
|
1692
|
+
name: string;
|
|
1693
|
+
createdAt: Date;
|
|
1694
|
+
updatedAt: Date;
|
|
1695
|
+
image?: string | undefined;
|
|
1696
|
+
};
|
|
1697
|
+
};
|
|
1698
|
+
}>, better_call.EndpointOptions>[];
|
|
1699
|
+
}>): Promise<{
|
|
1700
|
+
status: boolean;
|
|
1701
|
+
}>;
|
|
1702
|
+
path: "/user/revoke-session";
|
|
1703
|
+
options: {
|
|
1704
|
+
method: "POST";
|
|
1705
|
+
body: zod.ZodObject<{
|
|
1706
|
+
id: zod.ZodString;
|
|
1707
|
+
}, "strip", zod.ZodTypeAny, {
|
|
1708
|
+
id: string;
|
|
1709
|
+
}, {
|
|
1710
|
+
id: string;
|
|
1711
|
+
}>;
|
|
1712
|
+
use: Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
|
|
1713
|
+
session: {
|
|
1714
|
+
session: {
|
|
1715
|
+
id: string;
|
|
1716
|
+
userId: string;
|
|
1717
|
+
expiresAt: Date;
|
|
1718
|
+
ipAddress?: string | undefined;
|
|
1719
|
+
userAgent?: string | undefined;
|
|
1720
|
+
};
|
|
1721
|
+
user: {
|
|
1722
|
+
id: string;
|
|
1723
|
+
email: string;
|
|
1724
|
+
emailVerified: boolean;
|
|
1725
|
+
name: string;
|
|
1726
|
+
createdAt: Date;
|
|
1727
|
+
updatedAt: Date;
|
|
1728
|
+
image?: string | undefined;
|
|
1729
|
+
};
|
|
1730
|
+
};
|
|
1731
|
+
}>, better_call.EndpointOptions>[];
|
|
1732
|
+
};
|
|
1733
|
+
method: better_call.Method | better_call.Method[];
|
|
1734
|
+
headers: Headers;
|
|
1735
|
+
};
|
|
1736
|
+
revokeSessions: {
|
|
1737
|
+
(ctx_0?: better_call.Context<"/user/revoke-sessions", {
|
|
1738
|
+
method: "POST";
|
|
1739
|
+
use: Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
|
|
1740
|
+
session: {
|
|
1741
|
+
session: {
|
|
1742
|
+
id: string;
|
|
1743
|
+
userId: string;
|
|
1744
|
+
expiresAt: Date;
|
|
1745
|
+
ipAddress?: string | undefined;
|
|
1746
|
+
userAgent?: string | undefined;
|
|
1747
|
+
};
|
|
1748
|
+
user: {
|
|
1749
|
+
id: string;
|
|
1750
|
+
email: string;
|
|
1751
|
+
emailVerified: boolean;
|
|
1752
|
+
name: string;
|
|
1753
|
+
createdAt: Date;
|
|
1754
|
+
updatedAt: Date;
|
|
1755
|
+
image?: string | undefined;
|
|
1756
|
+
};
|
|
1757
|
+
};
|
|
1758
|
+
}>, better_call.EndpointOptions>[];
|
|
1759
|
+
}> | undefined): Promise<{
|
|
1760
|
+
status: boolean;
|
|
1761
|
+
}>;
|
|
1762
|
+
path: "/user/revoke-sessions";
|
|
1763
|
+
options: {
|
|
1764
|
+
method: "POST";
|
|
1765
|
+
use: Endpoint<better_call.Handler<string, better_call.EndpointOptions, {
|
|
1766
|
+
session: {
|
|
1767
|
+
session: {
|
|
1768
|
+
id: string;
|
|
1769
|
+
userId: string;
|
|
1770
|
+
expiresAt: Date;
|
|
1771
|
+
ipAddress?: string | undefined;
|
|
1772
|
+
userAgent?: string | undefined;
|
|
1773
|
+
};
|
|
1774
|
+
user: {
|
|
1775
|
+
id: string;
|
|
1776
|
+
email: string;
|
|
1777
|
+
emailVerified: boolean;
|
|
1778
|
+
name: string;
|
|
1779
|
+
createdAt: Date;
|
|
1780
|
+
updatedAt: Date;
|
|
1781
|
+
image?: string | undefined;
|
|
1782
|
+
};
|
|
1783
|
+
};
|
|
1784
|
+
}>, better_call.EndpointOptions>[];
|
|
1785
|
+
};
|
|
1786
|
+
method: better_call.Method | better_call.Method[];
|
|
1787
|
+
headers: Headers;
|
|
1788
|
+
};
|
|
1423
1789
|
}>;
|
|
1424
1790
|
options: O;
|
|
1425
1791
|
$infer: {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { A as Auth, b as betterAuth } from './index-
|
|
2
|
-
import './internal-adapter-
|
|
1
|
+
export { A as Auth, b as betterAuth } from './index-BqqlGo3a.js';
|
|
2
|
+
import './internal-adapter-DXjewSmi.js';
|
|
3
3
|
import 'kysely';
|
|
4
4
|
import './index-CcxejJTH.js';
|
|
5
5
|
import 'arctic';
|