mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-08 12:27:44 +00:00
chore: enable lint rule noTsIgnore (#4296)
This commit is contained in:
@@ -12,7 +12,8 @@
|
|||||||
"recommended": false,
|
"recommended": false,
|
||||||
"suspicious": {
|
"suspicious": {
|
||||||
"noImplicitAnyLet": "warn",
|
"noImplicitAnyLet": "warn",
|
||||||
"noDuplicateObjectKeys": "warn"
|
"noDuplicateObjectKeys": "warn",
|
||||||
|
"noTsIgnore": "error"
|
||||||
},
|
},
|
||||||
"performance": {
|
"performance": {
|
||||||
"noDelete": "error"
|
"noDelete": "error"
|
||||||
|
|||||||
@@ -393,7 +393,6 @@ export default function UserCard(props: {
|
|||||||
setIsPendingTwoFa(true);
|
setIsPendingTwoFa(true);
|
||||||
if (session?.user.twoFactorEnabled) {
|
if (session?.user.twoFactorEnabled) {
|
||||||
const res = await client.twoFactor.disable({
|
const res = await client.twoFactor.disable({
|
||||||
//@ts-ignore
|
|
||||||
password: twoFaPassword,
|
password: twoFaPassword,
|
||||||
fetchOptions: {
|
fetchOptions: {
|
||||||
onError(context) {
|
onError(context) {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export default async function AuthorizePage({
|
|||||||
const session = await auth.api.getSession({
|
const session = await auth.api.getSession({
|
||||||
headers: await headers(),
|
headers: await headers(),
|
||||||
});
|
});
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
const clientDetails = await auth.api.getOAuthClient({
|
const clientDetails = await auth.api.getOAuthClient({
|
||||||
params: {
|
params: {
|
||||||
id: client_id,
|
id: client_id,
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ function toast({ ...props }: Toast) {
|
|||||||
...props,
|
...props,
|
||||||
id,
|
id,
|
||||||
open: true,
|
open: true,
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
onOpenChange: (open) => {
|
onOpenChange: (open) => {
|
||||||
if (!open) dismiss();
|
if (!open) dismiss();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ export default async function Page({
|
|||||||
const { slug } = await params;
|
const { slug } = await params;
|
||||||
const page = changelogs.getPage(slug);
|
const page = changelogs.getPage(slug);
|
||||||
if (!slug) {
|
if (!slug) {
|
||||||
//@ts-ignore
|
|
||||||
return <ChangelogPage />;
|
return <ChangelogPage />;
|
||||||
}
|
}
|
||||||
if (!page) {
|
if (!page) {
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ export const NavbarProvider = ({ children }: { children: React.ReactNode }) => {
|
|||||||
const toggleDocsNavbar = () => {
|
const toggleDocsNavbar = () => {
|
||||||
setIsDocsOpen((prevIsOpen) => !prevIsOpen);
|
setIsDocsOpen((prevIsOpen) => !prevIsOpen);
|
||||||
};
|
};
|
||||||
// @ts-ignore
|
|
||||||
return (
|
return (
|
||||||
<NavbarContext.Provider
|
<NavbarContext.Provider
|
||||||
value={{ isOpen, toggleNavbar, isDocsOpen, toggleDocsNavbar }}
|
value={{ isOpen, toggleNavbar, isDocsOpen, toggleDocsNavbar }}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ async function generateMDX() {
|
|||||||
const functionName = Object.keys(exports)[0]! as string;
|
const functionName = Object.keys(exports)[0]! as string;
|
||||||
|
|
||||||
const [path, options]: [string, Options] =
|
const [path, options]: [string, Options] =
|
||||||
//@ts-ignore
|
//@ts-expect-error
|
||||||
await exports[Object.keys(exports)[0]!];
|
await exports[Object.keys(exports)[0]!];
|
||||||
if (!path || !options) return console.error(`No path or options.`);
|
if (!path || !options) return console.error(`No path or options.`);
|
||||||
|
|
||||||
@@ -194,17 +194,17 @@ function parseZodShape(zod: z.ZodAny, path: string[]) {
|
|||||||
{ description: "some descriptiom" },
|
{ description: "some descriptiom" },
|
||||||
).shape;
|
).shape;
|
||||||
|
|
||||||
//@ts-ignore
|
//@ts-expect-error
|
||||||
if (zod._def.typeName === "ZodOptional") {
|
if (zod._def.typeName === "ZodOptional") {
|
||||||
isRootOptional = true;
|
isRootOptional = true;
|
||||||
const eg = z.optional(z.object({}));
|
const eg = z.optional(z.object({}));
|
||||||
const x = zod as never as typeof eg;
|
const x = zod as never as typeof eg;
|
||||||
//@ts-ignore
|
//@ts-expect-error
|
||||||
shape = x._def.innerType.shape;
|
shape = x._def.innerType.shape;
|
||||||
} else {
|
} else {
|
||||||
const eg = z.object({});
|
const eg = z.object({});
|
||||||
const x = zod as never as typeof eg;
|
const x = zod as never as typeof eg;
|
||||||
//@ts-ignore
|
//@ts-expect-error
|
||||||
shape = x.shape;
|
shape = x.shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -587,7 +587,7 @@ export const createAdapter =
|
|||||||
.join("\n")
|
.join("\n")
|
||||||
.replace("Error:", "Create method with `id` being called at:");
|
.replace("Error:", "Create method with `id` being called at:");
|
||||||
console.log(stack);
|
console.log(stack);
|
||||||
//@ts-ignore
|
//@ts-expect-error
|
||||||
unsafeData.id = undefined;
|
unsafeData.id = undefined;
|
||||||
}
|
}
|
||||||
debugLog(
|
debugLog(
|
||||||
|
|||||||
@@ -161,7 +161,6 @@ describe("Create Adapter Helper", async () => {
|
|||||||
data: { name: "test-name" },
|
data: { name: "test-name" },
|
||||||
});
|
});
|
||||||
expect(res).toHaveProperty("id");
|
expect(res).toHaveProperty("id");
|
||||||
//@ts-ignore
|
|
||||||
expect(res.id).toBe("HARD-CODED-ID");
|
expect(res.id).toBe("HARD-CODED-ID");
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -225,17 +224,11 @@ describe("Create Adapter Helper", async () => {
|
|||||||
expect(res).toHaveProperty("image");
|
expect(res).toHaveProperty("image");
|
||||||
expect(res).toHaveProperty("createdAt");
|
expect(res).toHaveProperty("createdAt");
|
||||||
expect(res).toHaveProperty("updatedAt");
|
expect(res).toHaveProperty("updatedAt");
|
||||||
//@ts-ignore
|
|
||||||
expect(res?.emailVerified).toEqual(false);
|
expect(res?.emailVerified).toEqual(false);
|
||||||
//@ts-ignore
|
|
||||||
expect(res?.name).toEqual("test-name");
|
expect(res?.name).toEqual("test-name");
|
||||||
//@ts-ignore
|
|
||||||
expect(res?.email).toEqual(undefined);
|
expect(res?.email).toEqual(undefined);
|
||||||
//@ts-ignore
|
|
||||||
expect(res?.image).toEqual(undefined);
|
expect(res?.image).toEqual(undefined);
|
||||||
//@ts-ignore
|
|
||||||
expect(res?.createdAt).toBeInstanceOf(Date);
|
expect(res?.createdAt).toBeInstanceOf(Date);
|
||||||
//@ts-ignore
|
|
||||||
expect(res?.updatedAt).toBeInstanceOf(Date);
|
expect(res?.updatedAt).toBeInstanceOf(Date);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -245,7 +238,6 @@ describe("Create Adapter Helper", async () => {
|
|||||||
data: { name: "test-name" },
|
data: { name: "test-name" },
|
||||||
});
|
});
|
||||||
expect(res).toHaveProperty("id");
|
expect(res).toHaveProperty("id");
|
||||||
//@ts-ignore
|
|
||||||
expect(typeof res?.id).toEqual("string");
|
expect(typeof res?.id).toEqual("string");
|
||||||
|
|
||||||
const adapterWithoutIdGeneration = await createTestAdapter({
|
const adapterWithoutIdGeneration = await createTestAdapter({
|
||||||
@@ -343,11 +335,9 @@ describe("Create Adapter Helper", async () => {
|
|||||||
data: { emailVerified: true },
|
data: { emailVerified: true },
|
||||||
});
|
});
|
||||||
expect(res).toHaveProperty("emailVerified");
|
expect(res).toHaveProperty("emailVerified");
|
||||||
//@ts-ignore
|
|
||||||
expect(res.emailVerified).toBe(true);
|
expect(res.emailVerified).toBe(true);
|
||||||
});
|
});
|
||||||
expect(createTRUEParameters.data).toHaveProperty("emailVerified");
|
expect(createTRUEParameters.data).toHaveProperty("emailVerified");
|
||||||
//@ts-ignore
|
|
||||||
expect(createTRUEParameters.data.emailVerified).toBe(1);
|
expect(createTRUEParameters.data.emailVerified).toBe(1);
|
||||||
|
|
||||||
// Testing false
|
// Testing false
|
||||||
@@ -371,11 +361,9 @@ describe("Create Adapter Helper", async () => {
|
|||||||
data: { emailVerified: false },
|
data: { emailVerified: false },
|
||||||
});
|
});
|
||||||
expect(res).toHaveProperty("emailVerified");
|
expect(res).toHaveProperty("emailVerified");
|
||||||
//@ts-ignore
|
|
||||||
expect(res.emailVerified).toBe(false);
|
expect(res.emailVerified).toBe(false);
|
||||||
});
|
});
|
||||||
expect(createFALSEParameters.data).toHaveProperty("emailVerified");
|
expect(createFALSEParameters.data).toHaveProperty("emailVerified");
|
||||||
//@ts-ignore
|
|
||||||
expect(createFALSEParameters.data.emailVerified).toBe(0);
|
expect(createFALSEParameters.data.emailVerified).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -904,11 +892,10 @@ describe("Create Adapter Helper", async () => {
|
|||||||
update: { emailVerified: true },
|
update: { emailVerified: true },
|
||||||
});
|
});
|
||||||
expect(res).toHaveProperty("emailVerified");
|
expect(res).toHaveProperty("emailVerified");
|
||||||
//@ts-ignore
|
//@ts-expect-error
|
||||||
expect(res.emailVerified).toBe(true);
|
expect(res.emailVerified).toBe(true);
|
||||||
});
|
});
|
||||||
expect(updateTRUEParameters.update).toHaveProperty("emailVerified");
|
expect(updateTRUEParameters.update).toHaveProperty("emailVerified");
|
||||||
//@ts-ignore
|
|
||||||
expect(updateTRUEParameters.update.emailVerified).toBe(1);
|
expect(updateTRUEParameters.update.emailVerified).toBe(1);
|
||||||
|
|
||||||
// Testing false
|
// Testing false
|
||||||
@@ -938,11 +925,10 @@ describe("Create Adapter Helper", async () => {
|
|||||||
update: { emailVerified: false },
|
update: { emailVerified: false },
|
||||||
});
|
});
|
||||||
expect(res).toHaveProperty("emailVerified");
|
expect(res).toHaveProperty("emailVerified");
|
||||||
//@ts-ignore
|
//@ts-expect-error
|
||||||
expect(res.emailVerified).toBe(false);
|
expect(res.emailVerified).toBe(false);
|
||||||
});
|
});
|
||||||
expect(createFALSEParameters.update).toHaveProperty("emailVerified");
|
expect(createFALSEParameters.update).toHaveProperty("emailVerified");
|
||||||
//@ts-ignore
|
|
||||||
expect(createFALSEParameters.update.emailVerified).toBe(0);
|
expect(createFALSEParameters.update.emailVerified).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1471,7 +1457,6 @@ describe("Create Adapter Helper", async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(res).toHaveProperty("id");
|
expect(res).toHaveProperty("id");
|
||||||
//@ts-ignore
|
|
||||||
expect(res?.id).toEqual("1");
|
expect(res?.id).toEqual("1");
|
||||||
});
|
});
|
||||||
// The where clause should convert the string id value of `"1"` to an int since `useNumberId` is true
|
// The where clause should convert the string id value of `"1"` to an int since `useNumberId` is true
|
||||||
@@ -1513,7 +1498,6 @@ describe("Create Adapter Helper", async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(res[0]).toHaveProperty("id");
|
expect(res[0]).toHaveProperty("id");
|
||||||
//@ts-ignore
|
|
||||||
expect(res[0].id).toEqual("1");
|
expect(res[0].id).toEqual("1");
|
||||||
});
|
});
|
||||||
// The where clause should convert the string id value of `"1"` to an int since `useNumberId` is true
|
// The where clause should convert the string id value of `"1"` to an int since `useNumberId` is true
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ describe("Drizzle Adapter Tests", async () => {
|
|||||||
await runAdapterTest({
|
await runAdapterTest({
|
||||||
getAdapter: async (customOptions = {}) => {
|
getAdapter: async (customOptions = {}) => {
|
||||||
const db = opts.database;
|
const db = opts.database;
|
||||||
//@ts-ignore
|
//@ts-expect-error
|
||||||
opts.database = undefined;
|
opts.database = undefined;
|
||||||
const merged = merge(opts, customOptions);
|
const merged = merge(opts, customOptions);
|
||||||
merged.database = db;
|
merged.database = db;
|
||||||
@@ -144,7 +144,7 @@ describe("Drizzle Adapter Number Id Test", async () => {
|
|||||||
await runNumberIdAdapterTest({
|
await runNumberIdAdapterTest({
|
||||||
getAdapter: async (customOptions = {}) => {
|
getAdapter: async (customOptions = {}) => {
|
||||||
const db = opts.database;
|
const db = opts.database;
|
||||||
//@ts-ignore
|
//@ts-expect-error
|
||||||
opts.database = undefined;
|
opts.database = undefined;
|
||||||
const merged = merge(opts, customOptions);
|
const merged = merge(opts, customOptions);
|
||||||
merged.database = db;
|
merged.database = db;
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import {
|
|||||||
} from "kysely";
|
} from "kysely";
|
||||||
import { DefaultQueryCompiler } from "kysely";
|
import { DefaultQueryCompiler } from "kysely";
|
||||||
import { DialectAdapterBase } from "kysely";
|
import { DialectAdapterBase } from "kysely";
|
||||||
//@ts-ignore - we need to import this to get the type of the database
|
|
||||||
import type { Database } from "bun:sqlite";
|
import type { Database } from "bun:sqlite";
|
||||||
|
|
||||||
export class BunSqliteAdapter implements DialectAdapterBase {
|
export class BunSqliteAdapter implements DialectAdapterBase {
|
||||||
@@ -178,21 +177,20 @@ export class BunSqliteIntrospector implements DatabaseIntrospector {
|
|||||||
options: DatabaseMetadataOptions = { withInternalKyselyTables: false },
|
options: DatabaseMetadataOptions = { withInternalKyselyTables: false },
|
||||||
): Promise<TableMetadata[]> {
|
): Promise<TableMetadata[]> {
|
||||||
let query = this.#db
|
let query = this.#db
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
.selectFrom("sqlite_schema")
|
.selectFrom("sqlite_schema")
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
.where("type", "=", "table")
|
.where("type", "=", "table")
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
.where("name", "not like", "sqlite_%")
|
.where("name", "not like", "sqlite_%")
|
||||||
// @ts-ignore
|
|
||||||
.select("name")
|
.select("name")
|
||||||
.$castTo<{ name: string }>();
|
.$castTo<{ name: string }>();
|
||||||
|
|
||||||
if (!options.withInternalKyselyTables) {
|
if (!options.withInternalKyselyTables) {
|
||||||
query = query
|
query = query
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
.where("name", "!=", DEFAULT_MIGRATION_TABLE)
|
.where("name", "!=", DEFAULT_MIGRATION_TABLE)
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
.where("name", "!=", DEFAULT_MIGRATION_LOCK_TABLE);
|
.where("name", "!=", DEFAULT_MIGRATION_LOCK_TABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,11 +211,10 @@ export class BunSqliteIntrospector implements DatabaseIntrospector {
|
|||||||
|
|
||||||
// Get the SQL that was used to create the table.
|
// Get the SQL that was used to create the table.
|
||||||
const createSql = await db
|
const createSql = await db
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
.selectFrom("sqlite_master")
|
.selectFrom("sqlite_master")
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
.where("name", "=", table)
|
.where("name", "=", table)
|
||||||
// @ts-ignore
|
|
||||||
.select("sql")
|
.select("sql")
|
||||||
.$castTo<{ sql: string | undefined }>()
|
.$castTo<{ sql: string | undefined }>()
|
||||||
.execute();
|
.execute();
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ export const createKyselyAdapter = async (config: BetterAuthOptions) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ("getConnection" in db) {
|
if ("getConnection" in db) {
|
||||||
// @ts-ignore - mysql2/promise
|
// @ts-expect-error - mysql2/promise
|
||||||
dialect = new MysqlDialect(db);
|
dialect = new MysqlDialect(db);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -179,21 +179,20 @@ export class NodeSqliteIntrospector implements DatabaseIntrospector {
|
|||||||
options: DatabaseMetadataOptions = { withInternalKyselyTables: false },
|
options: DatabaseMetadataOptions = { withInternalKyselyTables: false },
|
||||||
): Promise<TableMetadata[]> {
|
): Promise<TableMetadata[]> {
|
||||||
let query = this.#db
|
let query = this.#db
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
.selectFrom("sqlite_schema")
|
.selectFrom("sqlite_schema")
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
.where("type", "=", "table")
|
.where("type", "=", "table")
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
.where("name", "not like", "sqlite_%")
|
.where("name", "not like", "sqlite_%")
|
||||||
// @ts-ignore
|
|
||||||
.select("name")
|
.select("name")
|
||||||
.$castTo<{ name: string }>();
|
.$castTo<{ name: string }>();
|
||||||
|
|
||||||
if (!options.withInternalKyselyTables) {
|
if (!options.withInternalKyselyTables) {
|
||||||
query = query
|
query = query
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
.where("name", "!=", DEFAULT_MIGRATION_TABLE)
|
.where("name", "!=", DEFAULT_MIGRATION_TABLE)
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
.where("name", "!=", DEFAULT_MIGRATION_LOCK_TABLE);
|
.where("name", "!=", DEFAULT_MIGRATION_LOCK_TABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,11 +213,10 @@ export class NodeSqliteIntrospector implements DatabaseIntrospector {
|
|||||||
|
|
||||||
// Get the SQL that was used to create the table.
|
// Get the SQL that was used to create the table.
|
||||||
const createSql = await db
|
const createSql = await db
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
.selectFrom("sqlite_master")
|
.selectFrom("sqlite_master")
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
.where("name", "=", table)
|
.where("name", "=", table)
|
||||||
// @ts-ignore
|
|
||||||
.select("sql")
|
.select("sql")
|
||||||
.$castTo<{ sql: string | undefined }>()
|
.$castTo<{ sql: string | undefined }>()
|
||||||
.execute();
|
.execute();
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ export const memoryAdapter = (db: MemoryDB, config?: MemoryAdapterConfig) =>
|
|||||||
if (!Array.isArray(value)) {
|
if (!Array.isArray(value)) {
|
||||||
throw new Error("Value must be an array");
|
throw new Error("Value must be an array");
|
||||||
}
|
}
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
return value.includes(record[field]);
|
return value.includes(record[field]);
|
||||||
} else if (operator === "contains") {
|
} else if (operator === "contains") {
|
||||||
return record[field].includes(value);
|
return record[field].includes(value);
|
||||||
@@ -66,7 +66,7 @@ export const memoryAdapter = (db: MemoryDB, config?: MemoryAdapterConfig) =>
|
|||||||
return {
|
return {
|
||||||
create: async ({ model, data }) => {
|
create: async ({ model, data }) => {
|
||||||
if (options.advanced?.database?.useNumberId) {
|
if (options.advanced?.database?.useNumberId) {
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
data.id = db[model].length + 1;
|
data.id = db[model].length + 1;
|
||||||
}
|
}
|
||||||
if (!db[model]) {
|
if (!db[model]) {
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ const numberIdAdapterTests = {
|
|||||||
SHOULD_RETURN_A_NUMBER_ID_AS_A_RESULT:
|
SHOULD_RETURN_A_NUMBER_ID_AS_A_RESULT:
|
||||||
"Should return a number id as a result",
|
"Should return a number id as a result",
|
||||||
SHOULD_INCREMENT_THE_ID_BY_1: "Should increment the id by 1",
|
SHOULD_INCREMENT_THE_ID_BY_1: "Should increment the id by 1",
|
||||||
} as const;
|
};
|
||||||
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
// biome-ignore lint/performance/noDelete: testing propose
|
// biome-ignore lint/performance/noDelete: testing propose
|
||||||
@@ -134,7 +134,6 @@ async function adapterTest(
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
expect(res).toHaveProperty("id");
|
expect(res).toHaveProperty("id");
|
||||||
//@ts-ignore
|
|
||||||
expect(typeof res?.id).toEqual("string");
|
expect(typeof res?.id).toEqual("string");
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -89,7 +89,6 @@ describe(
|
|||||||
for (let i = 0; i < 25; i++) {
|
for (let i = 0; i < 25; i++) {
|
||||||
const response = await client.listSessions({
|
const response = await client.listSessions({
|
||||||
fetchOptions: {
|
fetchOptions: {
|
||||||
// @ts-ignore
|
|
||||||
query: {
|
query: {
|
||||||
"test-query": Math.random().toString(),
|
"test-query": Math.random().toString(),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -335,7 +335,7 @@ describe("updateUser", async () => {
|
|||||||
throw: true,
|
throw: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
expect(session?.user.newField).toBe("new");
|
expect(session?.user.newField).toBe("new");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export async function getAdapter(options: BetterAuthOptions): Promise<Adapter> {
|
|||||||
if (!options.database) {
|
if (!options.database) {
|
||||||
const tables = getAuthTables(options);
|
const tables = getAuthTables(options);
|
||||||
const memoryDB = Object.keys(tables).reduce((acc, key) => {
|
const memoryDB = Object.keys(tables).reduce((acc, key) => {
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
acc[key] = [];
|
acc[key] = [];
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
|
|||||||
@@ -429,7 +429,7 @@ export function createApiKey({
|
|||||||
? (opts.rateLimit.enabled ?? true)
|
? (opts.rateLimit.enabled ?? true)
|
||||||
: rateLimitEnabled,
|
: rateLimitEnabled,
|
||||||
requestCount: 0,
|
requestCount: 0,
|
||||||
//@ts-ignore - we intentionally save the permissions as string on DB.
|
//@ts-expect-error - we intentionally save the permissions as string on DB.
|
||||||
permissions: permissionsToApply,
|
permissions: permissionsToApply,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -451,10 +451,7 @@ export function createApiKey({
|
|||||||
key: key,
|
key: key,
|
||||||
metadata: metadata ?? null,
|
metadata: metadata ?? null,
|
||||||
permissions: apiKey.permissions
|
permissions: apiKey.permissions
|
||||||
? safeJSONParse(
|
? safeJSONParse(apiKey.permissions)
|
||||||
//@ts-ignore - from DB, this value is always a string
|
|
||||||
apiKey.permissions,
|
|
||||||
)
|
|
||||||
: null,
|
: null,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -205,10 +205,7 @@ export function getApiKey({
|
|||||||
permissions: returningApiKey.permissions
|
permissions: returningApiKey.permissions
|
||||||
? safeJSONParse<{
|
? safeJSONParse<{
|
||||||
[key: string]: string[];
|
[key: string]: string[];
|
||||||
}>(
|
}>(returningApiKey.permissions)
|
||||||
//@ts-ignore - From DB this is always a string
|
|
||||||
returningApiKey.permissions,
|
|
||||||
)
|
|
||||||
: null,
|
: null,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -191,10 +191,7 @@ export function listApiKeys({
|
|||||||
permissions: returningApiKey.permissions
|
permissions: returningApiKey.permissions
|
||||||
? safeJSONParse<{
|
? safeJSONParse<{
|
||||||
[key: string]: string[];
|
[key: string]: string[];
|
||||||
}>(
|
}>(returningApiKey.permissions)
|
||||||
//@ts-ignore - From DB this is always a string
|
|
||||||
returningApiKey.permissions,
|
|
||||||
)
|
|
||||||
: null,
|
: null,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -351,7 +351,7 @@ export function updateApiKey({
|
|||||||
message: ERROR_CODES.INVALID_METADATA_TYPE,
|
message: ERROR_CODES.INVALID_METADATA_TYPE,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
//@ts-ignore - we need this to be a string to save into DB.
|
//@ts-expect-error - we need this to be a string to save into DB.
|
||||||
newValues.metadata =
|
newValues.metadata =
|
||||||
schema.apikey.fields.metadata.transform.input(metadata);
|
schema.apikey.fields.metadata.transform.input(metadata);
|
||||||
}
|
}
|
||||||
@@ -383,7 +383,7 @@ export function updateApiKey({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (permissions !== undefined) {
|
if (permissions !== undefined) {
|
||||||
//@ts-ignore - we need this to be a string to save into DB.
|
//@ts-expect-error - we need this to be a string to save into DB.
|
||||||
newValues.permissions = JSON.stringify(permissions);
|
newValues.permissions = JSON.stringify(permissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -430,10 +430,7 @@ export function updateApiKey({
|
|||||||
permissions: returningApiKey.permissions
|
permissions: returningApiKey.permissions
|
||||||
? safeJSONParse<{
|
? safeJSONParse<{
|
||||||
[key: string]: string[];
|
[key: string]: string[];
|
||||||
}>(
|
}>(returningApiKey.permissions)
|
||||||
//@ts-ignore - from DB, this value is always a string
|
|
||||||
returningApiKey.permissions,
|
|
||||||
)
|
|
||||||
: null,
|
: null,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -75,10 +75,7 @@ export async function validateApiKey({
|
|||||||
const apiKeyPermissions = apiKey.permissions
|
const apiKeyPermissions = apiKey.permissions
|
||||||
? safeJSONParse<{
|
? safeJSONParse<{
|
||||||
[key: string]: string[];
|
[key: string]: string[];
|
||||||
}>(
|
}>(apiKey.permissions)
|
||||||
//@ts-ignore - from DB, this value is always a string
|
|
||||||
apiKey.permissions,
|
|
||||||
)
|
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
if (!apiKeyPermissions) {
|
if (!apiKeyPermissions) {
|
||||||
@@ -295,10 +292,7 @@ export function verifyApiKey({
|
|||||||
returningApiKey.permissions = returningApiKey.permissions
|
returningApiKey.permissions = returningApiKey.permissions
|
||||||
? safeJSONParse<{
|
? safeJSONParse<{
|
||||||
[key: string]: string[];
|
[key: string]: string[];
|
||||||
}>(
|
}>(returningApiKey.permissions)
|
||||||
//@ts-ignore - from DB, this value is always a string
|
|
||||||
returningApiKey.permissions,
|
|
||||||
)
|
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
return ctx.json({
|
return ctx.json({
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ function getRequestBody(options: EndpointOptions): any {
|
|||||||
options.body instanceof ZodObject ||
|
options.body instanceof ZodObject ||
|
||||||
options.body instanceof ZodOptional
|
options.body instanceof ZodOptional
|
||||||
) {
|
) {
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
const shape = options.body.shape;
|
const shape = options.body.shape;
|
||||||
if (!shape) return undefined;
|
if (!shape) return undefined;
|
||||||
const properties: Record<string, any> = {};
|
const properties: Record<string, any> = {};
|
||||||
@@ -319,7 +319,7 @@ export async function generator(ctx: AuthContext, options: BetterAuthOptions) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
acc[modelName] = {
|
acc[modelName] = {
|
||||||
type: "object",
|
type: "object",
|
||||||
properties,
|
properties,
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import type { Logger } from "../utils";
|
|||||||
import type { AuthMiddleware } from "../plugins";
|
import type { AuthMiddleware } from "../plugins";
|
||||||
import type { LiteralUnion, OmitId } from "./helper";
|
import type { LiteralUnion, OmitId } from "./helper";
|
||||||
import type { AdapterDebugLogs } from "../adapters";
|
import type { AdapterDebugLogs } from "../adapters";
|
||||||
//@ts-ignore - we need to import this to get the type of the database
|
|
||||||
import type { Database as BunDatabase } from "bun:sqlite";
|
import type { Database as BunDatabase } from "bun:sqlite";
|
||||||
import type { DatabaseSync } from "node:sqlite";
|
import type { DatabaseSync } from "node:sqlite";
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ export const shimEndpoint = (ctx: AuthContext, value: any) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//@ts-ignore
|
|
||||||
const endpointRes = value({
|
const endpointRes = value({
|
||||||
...context,
|
...context,
|
||||||
context: {
|
context: {
|
||||||
|
|||||||
@@ -704,7 +704,7 @@ export async function initAction(opts: any) {
|
|||||||
const { dependencies, envs, generatedCode } = await generateAuthConfig({
|
const { dependencies, envs, generatedCode } = await generateAuthConfig({
|
||||||
current_user_config,
|
current_user_config,
|
||||||
format,
|
format,
|
||||||
//@ts-ignore
|
//@ts-expect-error
|
||||||
s,
|
s,
|
||||||
plugins: add_plugins,
|
plugins: add_plugins,
|
||||||
database,
|
database,
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ import { loadConfig } from "c12";
|
|||||||
import type { BetterAuthOptions } from "better-auth";
|
import type { BetterAuthOptions } from "better-auth";
|
||||||
import { logger } from "better-auth";
|
import { logger } from "better-auth";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
import babelPresetTypeScript from "@babel/preset-typescript";
|
import babelPresetTypeScript from "@babel/preset-typescript";
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
import babelPresetReact from "@babel/preset-react";
|
import babelPresetReact from "@babel/preset-react";
|
||||||
import fs, { existsSync } from "fs";
|
import fs, { existsSync } from "fs";
|
||||||
import { BetterAuthError } from "better-auth";
|
import { BetterAuthError } from "better-auth";
|
||||||
|
|||||||
Reference in New Issue
Block a user