mirror of
https://github.com/better-auth/better-auth.git
synced 2026-08-24 14:34:26 -05:00
chore: bump better-call (#5348)
This commit is contained in:
@@ -4,3 +4,39 @@ import { organization } from "better-auth/plugins";
|
||||
export const auth = betterAuth({
|
||||
plugins: [organization({})],
|
||||
});
|
||||
|
||||
auth.api
|
||||
.getSession({
|
||||
headers: new Headers(),
|
||||
})
|
||||
.catch();
|
||||
|
||||
auth.api
|
||||
.getSession({
|
||||
headers: [] as [string, string][],
|
||||
})
|
||||
.catch();
|
||||
|
||||
auth.api
|
||||
.getSession({
|
||||
headers: {} as Record<string, string>,
|
||||
})
|
||||
.catch();
|
||||
|
||||
auth.api
|
||||
.getSession({
|
||||
headers: new Headers(),
|
||||
asResponse: true,
|
||||
})
|
||||
.then((r: Response) => {
|
||||
console.log(r);
|
||||
});
|
||||
|
||||
auth.api
|
||||
.getSession({
|
||||
headers: new Headers(),
|
||||
returnHeaders: true,
|
||||
})
|
||||
.then(({ headers }: { headers: Headers }) => {
|
||||
console.log(headers);
|
||||
});
|
||||
|
||||
@@ -26,3 +26,39 @@ const authClient = createAuthClient({
|
||||
|
||||
authClient.useActiveOrganization();
|
||||
authClient.useSession();
|
||||
|
||||
auth.api
|
||||
.getSession({
|
||||
headers: new Headers(),
|
||||
})
|
||||
.catch();
|
||||
|
||||
auth.api
|
||||
.getSession({
|
||||
headers: [] as [string, string][],
|
||||
})
|
||||
.catch();
|
||||
|
||||
auth.api
|
||||
.getSession({
|
||||
headers: {} as Record<string, string>,
|
||||
})
|
||||
.catch();
|
||||
|
||||
auth.api
|
||||
.getSession({
|
||||
headers: new Headers(),
|
||||
asResponse: true,
|
||||
})
|
||||
.then((r: Response) => {
|
||||
console.log(r);
|
||||
});
|
||||
|
||||
auth.api
|
||||
.getSession({
|
||||
headers: new Headers(),
|
||||
returnHeaders: true,
|
||||
})
|
||||
.then(({ headers }: { headers: Headers }) => {
|
||||
console.log(headers);
|
||||
});
|
||||
|
||||
+37
-1
@@ -2,7 +2,43 @@ import { betterAuth } from "better-auth";
|
||||
import Database from "better-sqlite3";
|
||||
import { expo } from "@better-auth/expo";
|
||||
|
||||
betterAuth({
|
||||
const auth = betterAuth({
|
||||
database: new Database("./sqlite.db"),
|
||||
plugins: [expo()],
|
||||
});
|
||||
|
||||
auth.api
|
||||
.getSession({
|
||||
headers: new Headers(),
|
||||
})
|
||||
.catch();
|
||||
|
||||
auth.api
|
||||
.getSession({
|
||||
headers: [] as [string, string][],
|
||||
})
|
||||
.catch();
|
||||
|
||||
auth.api
|
||||
.getSession({
|
||||
headers: {} as Record<string, string>,
|
||||
})
|
||||
.catch();
|
||||
|
||||
auth.api
|
||||
.getSession({
|
||||
headers: new Headers(),
|
||||
asResponse: true,
|
||||
})
|
||||
.then((r: Response) => {
|
||||
console.log(r);
|
||||
});
|
||||
|
||||
auth.api
|
||||
.getSession({
|
||||
headers: new Headers(),
|
||||
returnHeaders: true,
|
||||
})
|
||||
.then(({ headers }: { headers: Headers }) => {
|
||||
console.log(headers);
|
||||
});
|
||||
|
||||
@@ -612,39 +612,3 @@ describe("cookie cache", async () => {
|
||||
expect(fn).toHaveBeenCalledTimes(5);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getSession type tests", async () => {
|
||||
const { auth } = await getTestInstance();
|
||||
|
||||
it("has parameters", () => {
|
||||
type Params = Parameters<typeof auth.api.getSession>[0]["headers"];
|
||||
|
||||
expectTypeOf<Params>().toEqualTypeOf<
|
||||
[string, string][] | Record<string, string> | Headers
|
||||
>();
|
||||
});
|
||||
|
||||
it("can return a response", () => {
|
||||
type Returns = Awaited<ReturnType<typeof auth.api.getSession<true, false>>>;
|
||||
|
||||
expectTypeOf<{ returns: Returns }>().toMatchObjectType<{
|
||||
returns: Response;
|
||||
}>();
|
||||
});
|
||||
|
||||
it("can return headers", () => {
|
||||
type Returns = Awaited<ReturnType<typeof auth.api.getSession<false, true>>>;
|
||||
|
||||
expectTypeOf<{ returns: Returns["headers"] }>().toMatchObjectType<{
|
||||
returns: Headers;
|
||||
}>();
|
||||
});
|
||||
|
||||
it("asResponse takes prescedence", () => {
|
||||
type Returns = Awaited<ReturnType<typeof auth.api.getSession<true, true>>>;
|
||||
|
||||
expectTypeOf<{ returns: Returns }>().toMatchObjectType<{
|
||||
returns: Response;
|
||||
}>();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -27,10 +27,9 @@ const defuReplaceArrays = createDefu((obj, key, value) => {
|
||||
}
|
||||
});
|
||||
|
||||
export function toAuthEndpoints<E extends Record<string, AuthEndpoint>>(
|
||||
endpoints: E,
|
||||
ctx: AuthContext | Promise<AuthContext>,
|
||||
) {
|
||||
export function toAuthEndpoints<
|
||||
const E extends Record<string, Omit<AuthEndpoint, "wrap">>,
|
||||
>(endpoints: E, ctx: AuthContext | Promise<AuthContext>): E {
|
||||
const api: Record<
|
||||
string,
|
||||
((
|
||||
@@ -98,7 +97,7 @@ export function toAuthEndpoints<E extends Record<string, AuthEndpoint>>(
|
||||
internalContext.asResponse = false;
|
||||
internalContext.returnHeaders = true;
|
||||
const result = (await runWithEndpointContext(internalContext, () =>
|
||||
endpoint(internalContext as any),
|
||||
(endpoint as any)(internalContext as any),
|
||||
).catch((e: any) => {
|
||||
if (e instanceof APIError) {
|
||||
/**
|
||||
@@ -158,7 +157,7 @@ export function toAuthEndpoints<E extends Record<string, AuthEndpoint>>(
|
||||
api[key].path = endpoint.path;
|
||||
api[key].options = endpoint.options;
|
||||
}
|
||||
return api as E;
|
||||
return api as unknown as E;
|
||||
}
|
||||
|
||||
async function runBeforeHooks(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { User } from "../../types";
|
||||
import type { AuthEndpoint } from "@better-auth/core/api";
|
||||
import type { BetterAuthPlugin } from "@better-auth/core";
|
||||
import type { LiteralString } from "../../types/helper";
|
||||
import type { BackupCodeOptions } from "./backup-codes";
|
||||
import type { OTPOptions } from "./otp";
|
||||
@@ -44,7 +44,7 @@ export interface UserWithTwoFactor extends User {
|
||||
|
||||
export interface TwoFactorProvider {
|
||||
id: LiteralString;
|
||||
endpoints?: Record<string, AuthEndpoint>;
|
||||
endpoints?: BetterAuthPlugin["endpoints"];
|
||||
}
|
||||
|
||||
export interface TwoFactorTable {
|
||||
|
||||
Generated
+12
-10
@@ -10,8 +10,8 @@ catalogs:
|
||||
specifier: 1.1.18
|
||||
version: 1.1.18
|
||||
better-call:
|
||||
specifier: 1.0.19
|
||||
version: 1.0.19
|
||||
specifier: 1.0.23
|
||||
version: 1.0.23
|
||||
tsdown:
|
||||
specifier: ^0.15.6
|
||||
version: 0.15.6
|
||||
@@ -322,7 +322,7 @@ importers:
|
||||
version: link:../../packages/better-auth
|
||||
better-call:
|
||||
specifier: 'catalog:'
|
||||
version: 1.0.19
|
||||
version: 1.0.23
|
||||
better-sqlite3:
|
||||
specifier: ^12.2.0
|
||||
version: 12.4.1
|
||||
@@ -905,7 +905,7 @@ importers:
|
||||
version: 13.1.2
|
||||
better-call:
|
||||
specifier: 'catalog:'
|
||||
version: 1.0.19
|
||||
version: 1.0.23
|
||||
defu:
|
||||
specifier: ^6.1.4
|
||||
version: 6.1.4
|
||||
@@ -1145,7 +1145,7 @@ importers:
|
||||
version: 7.6.13
|
||||
better-call:
|
||||
specifier: 'catalog:'
|
||||
version: 1.0.19
|
||||
version: 1.0.23
|
||||
better-sqlite3:
|
||||
specifier: ^12.4.1
|
||||
version: 12.4.1
|
||||
@@ -1234,7 +1234,7 @@ importers:
|
||||
version: link:../better-auth
|
||||
better-call:
|
||||
specifier: 'catalog:'
|
||||
version: 1.0.19
|
||||
version: 1.0.23
|
||||
body-parser:
|
||||
specifier: ^2.2.0
|
||||
version: 2.2.0
|
||||
@@ -1262,7 +1262,7 @@ importers:
|
||||
version: link:../better-auth
|
||||
better-call:
|
||||
specifier: 'catalog:'
|
||||
version: 1.0.19
|
||||
version: 1.0.23
|
||||
stripe:
|
||||
specifier: ^18.5.0
|
||||
version: 18.5.0(@types/node@24.7.2)
|
||||
@@ -6620,8 +6620,8 @@ packages:
|
||||
resolution: {integrity: sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
better-call@1.0.19:
|
||||
resolution: {integrity: sha512-sI3GcA1SCVa3H+CDHl8W8qzhlrckwXOTKhqq3OOPXjgn5aTOMIqGY34zLY/pHA6tRRMjTUC3lz5Mi7EbDA24Kw==}
|
||||
better-call@1.0.23:
|
||||
resolution: {integrity: sha512-t7P/huToNS89LHbuRPrrmdf2Dh9T+fXpEfoFGgadyzOS1AulAP/U/H2TDx/wR0kML4AL+V/lcM1XNeVL2oMV4A==}
|
||||
|
||||
better-opn@3.0.2:
|
||||
resolution: {integrity: sha512-aVNobHnJqLiUelTaHat9DZ1qM2w0C0Eym4LPI/3JxOnSokGVdsl1T1kN7TFvsEAD8G47A6VKQ0TVHqbBnYMJlQ==}
|
||||
@@ -17498,7 +17498,9 @@ snapshots:
|
||||
metro-runtime: 0.83.3
|
||||
transitivePeerDependencies:
|
||||
- '@babel/core'
|
||||
- bufferutil
|
||||
- supports-color
|
||||
- utf-8-validate
|
||||
optional: true
|
||||
|
||||
'@react-native/normalize-colors@0.74.89': {}
|
||||
@@ -19513,7 +19515,7 @@ snapshots:
|
||||
dependencies:
|
||||
safe-buffer: 5.1.2
|
||||
|
||||
better-call@1.0.19:
|
||||
better-call@1.0.23:
|
||||
dependencies:
|
||||
'@better-auth/utils': 0.3.0
|
||||
'@better-fetch/fetch': 1.1.18
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ packages:
|
||||
|
||||
catalog:
|
||||
'@better-fetch/fetch': 1.1.18
|
||||
better-call: 1.0.19
|
||||
better-call: 1.0.23
|
||||
typescript: ^5.9.2
|
||||
tsdown: ^0.15.6
|
||||
vitest: ^3.2.4
|
||||
|
||||
Reference in New Issue
Block a user