better-auth 0.0.4 → 0.0.6
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/cli.js +805 -2
- package/dist/cli.js.map +1 -1
- package/dist/client.js +1 -4
- package/dist/client.js.map +1 -1
- package/dist/index.js +806 -6
- package/dist/index.js.map +1 -1
- package/dist/plugins.js +1 -4
- package/dist/plugins.js.map +1 -1
- package/dist/preact.js +1 -4
- package/dist/preact.js.map +1 -1
- package/dist/react.js +1 -4
- package/dist/react.js.map +1 -1
- package/dist/social.js +1 -4
- package/dist/social.js.map +1 -1
- package/dist/solid.js +1 -4
- package/dist/solid.js.map +1 -1
- package/dist/svelte.js +1 -4
- package/dist/svelte.js.map +1 -1
- package/dist/vue.js +1 -4
- package/dist/vue.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/index.ts","../src/adapters/schema.ts","../src/api/middlewares/csrf.ts","../src/crypto/index.ts","../src/api/call.ts","../src/api/routes/sign-in.ts","../src/social-providers/apple.ts","../src/error/better-auth-error.ts","../src/utils/base-url.ts","../src/social-providers/utils.ts","../src/social-providers/discord.ts","../src/social-providers/facebook.ts","../src/social-providers/github.ts","../src/social-providers/google.ts","../src/social-providers/spotify.ts","../src/social-providers/twitch.ts","../src/social-providers/twitter.ts","../src/types/provider.ts","../src/social-providers/index.ts","../src/utils/state.ts","../src/api/routes/session.ts","../src/api/routes/callback.ts","../src/client/client-utils.ts","../src/utils/id.ts","../src/api/routes/sign-out.ts","../src/api/routes/forget-password.ts","../src/api/routes/verify-email.ts","../src/api/routes/csrf.ts","../src/api/routes/ok.ts","../src/api/routes/sign-up.ts","../src/api/routes/error.ts","../src/adapters/kysely.ts","../src/adapters/get-tables.ts","../src/adapters/utils.ts","../src/adapters/internal-adapter.ts","../src/utils/date.ts","../src/db/field.ts","../src/utils/cookies.ts","../src/utils/logger.ts","../src/init.ts","../src/auth.ts"],"sourcesContent":["import { type Context, type Endpoint, createRouter } from \"better-call\";\nimport { parseAccount, parseSession, parseUser } from \"../adapters/schema\";\nimport type { AuthContext } from \"../init\";\nimport type { BetterAuthOptions, InferSession, InferUser } from \"../types\";\nimport type { Prettify } from \"../types/helper\";\nimport { csrfMiddleware } from \"./middlewares/csrf\";\nimport {\n\tcallbackOAuth,\n\tforgetPassword,\n\tgetSession,\n\tresetPassword,\n\tsendVerificationEmail,\n\tsignInEmail,\n\tsignInOAuth,\n\tsignOut,\n\tverifyEmail,\n} from \"./routes\";\nimport { getCSRFToken } from \"./routes/csrf\";\nimport { ok, welcome } from \"./routes/ok\";\nimport { signUpEmail } from \"./routes/sign-up\";\nimport { error } from \"./routes/error\";\n\nexport const router = <C extends AuthContext, Option extends BetterAuthOptions>(\n\tctx: C,\n) => {\n\tconst pluginEndpoints = ctx.options.plugins?.reduce(\n\t\t(acc, plugin) => {\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t...plugin.endpoints,\n\t\t\t};\n\t\t},\n\t\t{} as Record<string, any>,\n\t);\n\n\tconst middlewares =\n\t\tctx.options.plugins\n\t\t\t?.map((plugin) =>\n\t\t\t\tplugin.middlewares?.map((m) => {\n\t\t\t\t\tconst middleware = (async (context: any) => {\n\t\t\t\t\t\treturn m.middleware({\n\t\t\t\t\t\t\t...context,\n\t\t\t\t\t\t\tcontext: {\n\t\t\t\t\t\t\t\t...ctx,\n\t\t\t\t\t\t\t\t...context.context,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t}) as Endpoint;\n\t\t\t\t\tmiddleware.path = m.path;\n\t\t\t\t\tmiddleware.options = m.middleware.options;\n\t\t\t\t\tmiddleware.headers = m.middleware.headers;\n\t\t\t\t\treturn {\n\t\t\t\t\t\tpath: m.path,\n\t\t\t\t\t\tmiddleware,\n\t\t\t\t\t};\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.filter((plugin) => plugin !== undefined)\n\t\t\t.flat() || [];\n\n\tasync function typedSession(\n\t\tctx: Context<\n\t\t\t\"/session\",\n\t\t\t{\n\t\t\t\tmethod: \"GET\";\n\t\t\t\trequireHeaders: true;\n\t\t\t}\n\t\t>,\n\t) {\n\t\tconst handler = await getSession(ctx);\n\t\treturn handler as {\n\t\t\tsession: Prettify<InferSession<Option>>;\n\t\t\tuser: Prettify<InferUser<Option>>;\n\t\t} | null;\n\t}\n\ttypedSession.path = getSession.path;\n\ttypedSession.method = getSession.method;\n\ttypedSession.options = getSession.options;\n\ttypedSession.headers = getSession.headers;\n\n\tconst baseEndpoints = {\n\t\tsignInOAuth,\n\t\tcallbackOAuth,\n\t\tgetCSRFToken,\n\t\tgetSession: typedSession,\n\t\tsignOut,\n\t\tsignUpEmail,\n\t\tsignInEmail,\n\t\tforgetPassword,\n\t\tresetPassword,\n\t\tverifyEmail,\n\t\tsendVerificationEmail,\n\t};\n\tconst endpoints = {\n\t\t...baseEndpoints,\n\t\t...pluginEndpoints,\n\t\tok,\n\t\twelcome,\n\t\terror,\n\t};\n\tlet api: Record<string, any> = {};\n\tfor (const [key, value] of Object.entries(endpoints)) {\n\t\tapi[key] = async (context: any) => {\n\t\t\tfor (const plugin of ctx.options.plugins || []) {\n\t\t\t\tif (plugin.hooks?.before) {\n\t\t\t\t\tfor (const hook of plugin.hooks.before) {\n\t\t\t\t\t\tconst match = hook.matcher({\n\t\t\t\t\t\t\t...context,\n\t\t\t\t\t\t\t...value,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (match) {\n\t\t\t\t\t\t\tconst hookRes = await hook.handler(context);\n\t\t\t\t\t\t\tif (hookRes && \"context\" in hookRes) {\n\t\t\t\t\t\t\t\tcontext = {\n\t\t\t\t\t\t\t\t\t...context,\n\t\t\t\t\t\t\t\t\t...hookRes.context,\n\t\t\t\t\t\t\t\t\t...value,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t//@ts-ignore\n\t\t\tconst endpointRes = value({\n\t\t\t\t...context,\n\t\t\t\tcontext: {\n\t\t\t\t\t...ctx,\n\t\t\t\t\t...context.context,\n\t\t\t\t},\n\t\t\t});\n\t\t\tlet response = endpointRes;\n\t\t\tfor (const plugin of ctx.options.plugins || []) {\n\t\t\t\tif (plugin.hooks?.after) {\n\t\t\t\t\tfor (const hook of plugin.hooks.after) {\n\t\t\t\t\t\tconst match = hook.matcher(context);\n\t\t\t\t\t\tif (match) {\n\t\t\t\t\t\t\tconst obj = Object.assign(context, {\n\t\t\t\t\t\t\t\treturned: endpointRes,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tconst hookRes = await hook.handler(obj);\n\t\t\t\t\t\t\tif (hookRes && \"response\" in hookRes) {\n\t\t\t\t\t\t\t\tresponse = hookRes.response as any;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn response;\n\t\t};\n\t\tapi[key].path = value.path;\n\t\tapi[key].method = value.method;\n\t\tapi[key].options = value.options;\n\t\tapi[key].headers = value.headers;\n\t}\n\treturn createRouter(api as typeof baseEndpoints, {\n\t\textraContext: ctx,\n\t\tbasePath: ctx.options.basePath,\n\t\trouterMiddleware: [\n\t\t\t{\n\t\t\t\tpath: \"/**\",\n\t\t\t\tmiddleware: csrfMiddleware,\n\t\t\t},\n\t\t\t...middlewares,\n\t\t],\n\t\t/**\n\t\t * this is to remove any sensitive data from the response\n\t\t */\n\t\tasync transformResponse(res) {\n\t\t\tlet body: Record<string, any> = {};\n\t\t\ttry {\n\t\t\t\tbody = await res.json();\n\t\t\t} catch (e) {\n\t\t\t\treturn res;\n\t\t\t}\n\t\t\tif (body?.user) {\n\t\t\t\tbody.user = parseUser(ctx.options, body.user);\n\t\t\t}\n\t\t\tif (body?.session) {\n\t\t\t\tbody.session = parseSession(ctx.options, body.session);\n\t\t\t}\n\t\t\tif (body?.account) {\n\t\t\t\tbody.account = parseAccount(ctx.options, body.account);\n\t\t\t}\n\t\t\treturn new Response(body ? JSON.stringify(body) : null, {\n\t\t\t\theaders: res.headers,\n\t\t\t\tstatus: res.status,\n\t\t\t\tstatusText: res.statusText,\n\t\t\t});\n\t\t},\n\t\tonError(e) {\n\t\t\tconsole.log(e);\n\t\t},\n\t});\n};\n","import { z } from \"zod\";\nimport type { FieldAttribute } from \"../db\";\nimport type { BetterAuthOptions } from \"../types\";\n\nexport const accountSchema = z.object({\n\tid: z.string(),\n\tproviderId: z.string(),\n\taccountId: z.string(),\n\tuserId: z.string(),\n\taccessToken: z.string().nullable().optional(),\n\trefreshToken: z.string().nullable().optional(),\n\tidToken: z.string().nullable().optional(),\n\taccessTokenExpiresAt: z.date().nullable().optional(),\n\trefreshTokenExpiresAt: z.date().nullable().optional(),\n\t/**\n\t * Password is only stored in the credential provider\n\t */\n\tpassword: z.string().optional().nullable(),\n});\n\nexport const userSchema = z.object({\n\tid: z.string(),\n\temail: z.string().transform((val) => val.toLowerCase()),\n\temailVerified: z.boolean().default(false),\n\tname: z.string(),\n\timage: z.string().optional(),\n\tcreatedAt: z.date().default(new Date()),\n\tupdatedAt: z.date().default(new Date()),\n});\n\nexport const sessionSchema = z.object({\n\tid: z.string(),\n\tuserId: z.string(),\n\texpiresAt: z.date(),\n\tipAddress: z.string().optional(),\n\tuserAgent: z.string().optional(),\n});\n\nexport type User = z.infer<typeof userSchema>;\nexport type Account = z.infer<typeof accountSchema>;\nexport type Session = z.infer<typeof sessionSchema>;\nexport interface MigrationTable {\n\tname: string;\n\ttimestamp: string;\n}\n\nexport function parseData<T extends Record<string, any>>(\n\tdata: T,\n\tschema: {\n\t\tfields: Record<string, FieldAttribute>;\n\t},\n) {\n\tconst fields = schema.fields;\n\tconst parsedData: Record<string, any> = {};\n\tfor (const key in data) {\n\t\tconst field = fields[key];\n\t\tif (!field) {\n\t\t\tparsedData[key] = data[key];\n\t\t\tcontinue;\n\t\t}\n\t\tif (field.returned === false) {\n\t\t\tcontinue;\n\t\t}\n\t\tparsedData[key] = data[key];\n\t}\n\treturn parsedData as T;\n}\n\nexport function getAllFields(options: BetterAuthOptions, table: string) {\n\tlet schema: Record<string, FieldAttribute> = {};\n\tfor (const plugin of options.plugins || []) {\n\t\tif (plugin.schema && plugin.schema[table]) {\n\t\t\tschema = {\n\t\t\t\t...schema,\n\t\t\t\t...plugin.schema[table].fields,\n\t\t\t};\n\t\t}\n\t}\n\treturn schema;\n}\n\nexport function parseUser(options: BetterAuthOptions, user: User) {\n\tconst schema = getAllFields(options, \"user\");\n\treturn parseData(user, { fields: schema });\n}\n\nexport function parseAccount(options: BetterAuthOptions, account: Account) {\n\tconst schema = getAllFields(options, \"account\");\n\treturn parseData(account, { fields: schema });\n}\n\nexport function parseSession(options: BetterAuthOptions, session: Session) {\n\tconst schema = getAllFields(options, \"session\");\n\treturn parseData(session, { fields: schema });\n}\n","import { APIError } from \"better-call\";\nimport { z } from \"zod\";\nimport { hs256 } from \"../../crypto\";\nimport { createAuthMiddleware } from \"../call\";\n\nexport const csrfMiddleware = createAuthMiddleware(\n\t{\n\t\tbody: z\n\t\t\t.object({\n\t\t\t\tcsrfToken: z.string().optional(),\n\t\t\t})\n\t\t\t.optional(),\n\t},\n\tasync (ctx) => {\n\t\tif (\n\t\t\tctx.request?.method !== \"POST\" ||\n\t\t\tctx.context.options.advanced?.disableCSRFCheck\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tconst url = new URL(ctx.request.url);\n\t\tconsole.log(url.origin, ctx.context.options.baseURL);\n\t\t/**\n\t\t * If origin is the same as baseURL or if the\n\t\t * origin is in the trustedOrigins then we\n\t\t * don't need to check the CSRF token.\n\t\t */\n\t\tif (\n\t\t\turl.origin === ctx.context.options.baseURL ||\n\t\t\tctx.context.options.trustedOrigins?.includes(url.origin)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst csrfToken = ctx.body?.csrfToken;\n\t\tconst csrfCookie = await ctx.getSignedCookie(\n\t\t\tctx.context.authCookies.csrfToken.name,\n\t\t\tctx.context.secret,\n\t\t);\n\t\tconst [token, hash] = csrfCookie?.split(\"!\") || [null, null];\n\t\tif (\n\t\t\t!csrfToken ||\n\t\t\t!csrfCookie ||\n\t\t\t!token ||\n\t\t\t!hash ||\n\t\t\tcsrfCookie !== csrfToken\n\t\t) {\n\t\t\tctx.setCookie(ctx.context.authCookies.csrfToken.name, \"\", {\n\t\t\t\tmaxAge: 0,\n\t\t\t});\n\t\t\tthrow new APIError(\"UNAUTHORIZED\", {\n\t\t\t\tmessage: \"Invalid CSRF Token\",\n\t\t\t});\n\t\t}\n\t\tconst expectedHash = await hs256(ctx.context.secret, token);\n\t\tif (hash !== expectedHash) {\n\t\t\tctx.setCookie(ctx.context.authCookies.csrfToken.name, \"\", {\n\t\t\t\tmaxAge: 0,\n\t\t\t});\n\t\t\tthrow new APIError(\"UNAUTHORIZED\", {\n\t\t\t\tmessage: \"Invalid CSRF Token\",\n\t\t\t});\n\t\t}\n\t},\n);\n","import { xchacha20poly1305 } from \"@noble/ciphers/chacha\";\nimport { bytesToHex, hexToBytes, utf8ToBytes } from \"@noble/ciphers/utils\";\nimport { managedNonce } from \"@noble/ciphers/webcrypto\";\nimport { sha256 } from \"@noble/hashes/sha256\";\n\nexport async function hs256(secretKey: string, message: string) {\n\tconst enc = new TextEncoder();\n\tconst algorithm = { name: \"HMAC\", hash: \"SHA-256\" };\n\tconst key = await crypto.subtle.importKey(\n\t\t\"raw\",\n\t\tenc.encode(secretKey),\n\t\talgorithm,\n\t\tfalse,\n\t\t[\"sign\", \"verify\"],\n\t);\n\tconst signature = await crypto.subtle.sign(\n\t\talgorithm.name,\n\t\tkey,\n\t\tenc.encode(message),\n\t);\n\treturn btoa(String.fromCharCode(...new Uint8Array(signature)));\n}\n\nexport type SymmetricEncryptOptions = {\n\tkey: string;\n\tdata: string;\n};\n\nexport const symmetricEncrypt = ({ key, data }: SymmetricEncryptOptions) => {\n\tconst keyAsBytes = sha256(key);\n\tconst dataAsBytes = utf8ToBytes(data);\n\tconst chacha = managedNonce(xchacha20poly1305)(keyAsBytes);\n\treturn bytesToHex(chacha.encrypt(dataAsBytes));\n};\n\nexport type SymmetricDecryptOptions = {\n\tkey: string;\n\tdata: string;\n};\n\nexport const symmetricDecrypt = ({ key, data }: SymmetricDecryptOptions) => {\n\tconst keyAsBytes = sha256(key);\n\tconst dataAsBytes = hexToBytes(data);\n\tconst chacha = managedNonce(xchacha20poly1305)(keyAsBytes);\n\treturn chacha.decrypt(dataAsBytes);\n};\n","import {\n\ttype Endpoint,\n\ttype EndpointResponse,\n\tcreateEndpointCreator,\n\tcreateMiddleware,\n\tcreateMiddlewareCreator,\n} from \"better-call\";\nimport type { AuthContext } from \"../init\";\nimport type { BetterAuthOptions } from \"../types/options\";\n\nexport const optionsMiddleware = createMiddleware(async () => {\n\t/**\n\t * This will be passed on the instance of\n\t * the context. Used to infer the type\n\t * here.\n\t */\n\treturn {} as AuthContext;\n});\n\nexport const createAuthMiddleware = createMiddlewareCreator({\n\tuse: [optionsMiddleware],\n});\n\nexport const createAuthEndpoint = createEndpointCreator({\n\tuse: [optionsMiddleware],\n});\n\nexport type AuthEndpoint = Endpoint<\n\t(ctx: {\n\t\toptions: BetterAuthOptions;\n\t\tbody: any;\n\t\tquery: any;\n\t\theaders: Headers;\n\t}) => Promise<EndpointResponse>\n>;\n\nexport type AuthMiddleware = ReturnType<typeof createAuthMiddleware>;\n","import { APIError } from \"better-call\";\nimport { generateCodeVerifier } from \"oslo/oauth2\";\nimport { Argon2id } from \"oslo/password\";\nimport { z } from \"zod\";\nimport { oAuthProviderList } from \"../../social-providers\";\nimport { generateState } from \"../../utils/state\";\nimport { createAuthEndpoint } from \"../call\";\nimport { getSessionFromCtx } from \"./session\";\n\nexport const signInOAuth = createAuthEndpoint(\n\t\"/sign-in/social\",\n\t{\n\t\tmethod: \"POST\",\n\t\trequireHeaders: true,\n\t\tquery: z\n\t\t\t.object({\n\t\t\t\t/**\n\t\t\t\t * Redirect to the current URL after the\n\t\t\t\t * user has signed in.\n\t\t\t\t */\n\t\t\t\tcurrentURL: z.string().optional(),\n\t\t\t})\n\t\t\t.optional(),\n\t\tbody: z.object({\n\t\t\t/**\n\t\t\t * Callback URL to redirect to after the user has signed in.\n\t\t\t */\n\t\t\tcallbackURL: z.string().optional(),\n\t\t\t/**\n\t\t\t * OAuth2 provider to use`\n\t\t\t */\n\t\t\tprovider: z.enum(oAuthProviderList),\n\t\t}),\n\t},\n\tasync (c) => {\n\t\tconst provider = c.context.options.socialProvider?.find(\n\t\t\t(p) => p.id === c.body.provider,\n\t\t);\n\t\tif (!provider) {\n\t\t\tc.context.logger.error(\n\t\t\t\t\"Provider not found. Make sure to add the provider to your auth config\",\n\t\t\t\t{\n\t\t\t\t\tprovider: c.body.provider,\n\t\t\t\t},\n\t\t\t);\n\t\t\tthrow new APIError(\"NOT_FOUND\");\n\t\t}\n\t\tconst cookie = c.context.authCookies;\n\t\tconst currentURL = c.query?.currentURL\n\t\t\t? new URL(c.query?.currentURL)\n\t\t\t: null;\n\t\tconst state = generateState(\n\t\t\tc.body.callbackURL || currentURL?.origin || c.context.baseURL,\n\t\t\tc.query?.currentURL,\n\t\t);\n\t\ttry {\n\t\t\tawait c.setSignedCookie(\n\t\t\t\tcookie.state.name,\n\t\t\t\tstate.code,\n\t\t\t\tc.context.secret,\n\t\t\t\tcookie.state.options,\n\t\t\t);\n\t\t\tconst codeVerifier = generateCodeVerifier();\n\t\t\tawait c.setSignedCookie(\n\t\t\t\tcookie.pkCodeVerifier.name,\n\t\t\t\tcodeVerifier,\n\t\t\t\tc.context.secret,\n\t\t\t\tcookie.pkCodeVerifier.options,\n\t\t\t);\n\t\t\tconst url = provider.createAuthorizationURL({\n\t\t\t\tstate: state.state,\n\t\t\t\tcodeVerifier,\n\t\t\t});\n\t\t\treturn {\n\t\t\t\turl: url.toString(),\n\t\t\t\tstate: state.state,\n\t\t\t\tcodeVerifier,\n\t\t\t\tredirect: true,\n\t\t\t};\n\t\t} catch (e) {\n\t\t\tthrow new APIError(\"INTERNAL_SERVER_ERROR\");\n\t\t}\n\t},\n);\n\nexport const signInEmail = createAuthEndpoint(\n\t\"/sign-in/email\",\n\t{\n\t\tmethod: \"POST\",\n\t\tbody: z.object({\n\t\t\temail: z.string().email(),\n\t\t\tpassword: z.string(),\n\t\t\tcallbackURL: z.string().optional(),\n\t\t\t/**\n\t\t\t * If this is true the session will only be valid for the current browser session\n\t\t\t * @default false\n\t\t\t */\n\t\t\tdontRememberMe: z.boolean().default(false).optional(),\n\t\t}),\n\t},\n\tasync (ctx) => {\n\t\tif (!ctx.context.options?.emailAndPassword?.enabled) {\n\t\t\tctx.context.logger.error(\"Email and password is not enabled\");\n\t\t\tthrow new APIError(\"BAD_REQUEST\", {\n\t\t\t\tmessage: \"Email and password is not enabled\",\n\t\t\t});\n\t\t}\n\t\tconst currentSession = await getSessionFromCtx(ctx);\n\t\tif (currentSession) {\n\t\t\treturn ctx.json({\n\t\t\t\tuser: currentSession.user,\n\t\t\t\tsession: currentSession.session,\n\t\t\t\tredirect: !!ctx.body.callbackURL,\n\t\t\t\turl: ctx.body.callbackURL,\n\t\t\t});\n\t\t}\n\t\tconst { email, password } = ctx.body;\n\t\tconst argon2id = new Argon2id();\n\t\tconst user = await ctx.context.internalAdapter.findUserByEmail(email);\n\t\tif (!user) {\n\t\t\tawait argon2id.hash(password);\n\t\t\tctx.context.logger.error(\"User not found\", { email });\n\t\t\tthrow new APIError(\"UNAUTHORIZED\", {\n\t\t\t\tmessage: \"Invalid email or password\",\n\t\t\t});\n\t\t}\n\t\tconst credentialAccount = user.accounts.find(\n\t\t\t(a) => a.providerId === \"credential\",\n\t\t);\n\t\tif (!credentialAccount) {\n\t\t\tctx.context.logger.error(\"Credential account not found\", { email });\n\t\t\tthrow new APIError(\"UNAUTHORIZED\", {\n\t\t\t\tmessage: \"Invalid email or password\",\n\t\t\t});\n\t\t}\n\t\tconst currentPassword = credentialAccount?.password;\n\t\tif (!currentPassword) {\n\t\t\tctx.context.logger.error(\"Password not found\", { email });\n\t\t\tthrow new APIError(\"UNAUTHORIZED\", {\n\t\t\t\tmessage: \"Unexpected error\",\n\t\t\t});\n\t\t}\n\t\tconst validPassword = await argon2id.verify(currentPassword, password);\n\t\tif (!validPassword) {\n\t\t\tctx.context.logger.error(\"Invalid password\");\n\t\t\tthrow new APIError(\"UNAUTHORIZED\", {\n\t\t\t\tmessage: \"Invalid email or password\",\n\t\t\t});\n\t\t}\n\t\tconst session = await ctx.context.internalAdapter.createSession(\n\t\t\tuser.user.id,\n\t\t\tctx.request,\n\t\t);\n\t\tawait ctx.setSignedCookie(\n\t\t\tctx.context.authCookies.sessionToken.name,\n\t\t\tsession.id,\n\t\t\tctx.context.secret,\n\t\t\tctx.body.dontRememberMe\n\t\t\t\t? {\n\t\t\t\t\t\t...ctx.context.authCookies.sessionToken.options,\n\t\t\t\t\t\tmaxAge: undefined,\n\t\t\t\t\t}\n\t\t\t\t: ctx.context.authCookies.sessionToken.options,\n\t\t);\n\t\treturn ctx.json({\n\t\t\tuser: user.user,\n\t\t\tsession,\n\t\t\tredirect: !!ctx.body.callbackURL,\n\t\t\turl: ctx.body.callbackURL,\n\t\t});\n\t},\n);\n","import { OAuth2Tokens } from \"arctic\";\nimport type { OAuthProvider } from \".\";\nimport { parseJWT } from \"oslo/jwt\";\nimport { betterFetch } from \"@better-fetch/fetch\";\nimport { BetterAuthError } from \"../error/better-auth-error\";\nimport { getRedirectURI } from \"./utils\";\nexport interface AppleProfile {\n\t/**\n\t * The subject registered claim identifies the principal that’s the subject\n\t * of the identity token. Because this token is for your app, the value is\n\t * the unique identifier for the user.\n\t */\n\tsub: string;\n\t/**\n\t * A String value representing the user's email address.\n\t * The email address is either the user's real email address or the proxy\n\t * address, depending on their status private email relay service.\n\t */\n\temail: string;\n\t/**\n\t * A string or Boolean value that indicates whether the service verifies\n\t * the email. The value can either be a string (\"true\" or \"false\") or a\n\t * Boolean (true or false). The system may not verify email addresses for\n\t * Sign in with Apple at Work & School users, and this claim is \"false\" or\n\t * false for those users.\n\t */\n\temail_verified: true | \"true\";\n\t/**\n\t * A string or Boolean value that indicates whether the email that the user\n\t * shares is the proxy address. The value can either be a string (\"true\" or\n\t * \"false\") or a Boolean (true or false).\n\t */\n\tis_private_email: boolean;\n\t/**\n\t * An Integer value that indicates whether the user appears to be a real\n\t * person. Use the value of this claim to mitigate fraud. The possible\n\t * values are: 0 (or Unsupported), 1 (or Unknown), 2 (or LikelyReal). For\n\t * more information, see ASUserDetectionStatus. This claim is present only\n\t * in iOS 14 and later, macOS 11 and later, watchOS 7 and later, tvOS 14\n\t * and later. The claim isn’t present or supported for web-based apps.\n\t */\n\treal_user_status: number;\n\t/**\n\t * The user’s full name in the format provided during the authorization\n\t * process.\n\t */\n\tname: string;\n}\n\nexport interface AppleOptions {\n\tclientId: string;\n\tclientSecret: string;\n\tredirectURI?: string;\n}\n\nexport const apple = ({\n\tclientId,\n\tclientSecret,\n\tredirectURI,\n}: AppleOptions) => {\n\tconst tokenEndpoint = \"https://appleid.apple.com/auth/token\";\n\tredirectURI = getRedirectURI(\"apple\", redirectURI);\n\treturn {\n\t\tid: \"apple\",\n\t\tname: \"Apple\",\n\t\tcreateAuthorizationURL({ state, scopes }) {\n\t\t\tconst _scope = scopes || [\"email\", \"name\", \"openid\"];\n\t\t\treturn new URL(\n\t\t\t\t`https://appleid.apple.com/auth/authorize?client_id=${clientId}&response_type=code&redirect_uri=${redirectURI}&scope=${_scope.join(\n\t\t\t\t\t\" \",\n\t\t\t\t)}&state=${state}`,\n\t\t\t);\n\t\t},\n\t\tvalidateAuthorizationCode: async (code) => {\n\t\t\tconst data = await betterFetch<OAuth2Tokens>(tokenEndpoint, {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tbody: new URLSearchParams({\n\t\t\t\t\tclient_id: clientId,\n\t\t\t\t\tclient_secret: clientSecret,\n\t\t\t\t\tgrant_type: \"authorization_code\",\n\t\t\t\t\tcode,\n\t\t\t\t}),\n\t\t\t\theaders: {\n\t\t\t\t\t\"Content-Type\": \"application/x-www-form-urlencoded\",\n\t\t\t\t},\n\t\t\t});\n\t\t\tif (data.error) {\n\t\t\t\tthrow new BetterAuthError(data.error?.message || \"\");\n\t\t\t}\n\t\t\treturn data.data;\n\t\t},\n\t\tasync getUserInfo(token) {\n\t\t\tconst data = parseJWT(token.idToken())?.payload as AppleProfile | null;\n\t\t\tif (!data) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tuser: {\n\t\t\t\t\tid: data.sub,\n\t\t\t\t\tname: data.name,\n\t\t\t\t\temail: data.email,\n\t\t\t\t\temailVerified: data.email_verified === \"true\",\n\t\t\t\t},\n\t\t\t\tdata,\n\t\t\t};\n\t\t},\n\t} satisfies OAuthProvider<AppleProfile>;\n};\n","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\tconsole.error(\"Invalid URL:\", error);\n\t\treturn false;\n\t}\n}\n\nfunction withPath(url: string, path = \"/api/auth\") {\n\tconst hasPath = checkHasPath(url);\n\tif (hasPath) {\n\t\treturn {\n\t\t\tbaseURL: new URL(url).origin,\n\t\t\twithPath: url,\n\t\t};\n\t}\n\tpath = path.startsWith(\"/\") ? path : `/${path}`;\n\treturn {\n\t\tbaseURL: url,\n\t\twithPath: `${url}${path}`,\n\t};\n}\n\nexport function getBaseURL(url?: string, path?: string) {\n\tif (url) {\n\t\treturn withPath(url, path);\n\t}\n\t//@ts-ignore\n\tconst env: any =\n\t\ttypeof process !== \"undefined\"\n\t\t\t? process.env\n\t\t\t: typeof import.meta !== \"undefined\"\n\t\t\t\t? //@ts-ignore\n\t\t\t\t\timport.meta.env\n\t\t\t\t: {};\n\tconst fromEnv =\n\t\tenv.BETTER_AUTH_URL ||\n\t\tenv.AUTH_URL ||\n\t\tenv.NEXT_PUBLIC_AUTH_URL ||\n\t\tenv.NEXT_PUBLIC_BETTER_AUTH_URL ||\n\t\tenv.PUBLIC_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\tconst isDev =\n\t\t!fromEnv && (env.NODE_ENV === \"development\" || env.NODE_ENV === \"test\");\n\tif (isDev) {\n\t\treturn {\n\t\t\tbaseURL: \"http://localhost:3000\",\n\t\t\twithPath: \"http://localhost:3000/api/auth\",\n\t\t};\n\t}\n\tthrow new BetterAuthError(\n\t\t\"Could not infer baseURL from environment variables\",\n\t);\n}\n","import { getBaseURL } from \"../utils/base-url\";\n\nexport function getRedirectURI(providerId: string, redirectURI?: string) {\n\treturn redirectURI || `${getBaseURL()}/api/auth/callback/${providerId}`;\n}\n","import { betterFetch } from \"@better-fetch/fetch\";\nimport { Discord } from \"arctic\";\nimport type { OAuthProvider } from \".\";\nimport { getRedirectURI } from \"./utils\";\n\nexport interface DiscordProfile extends Record<string, any> {\n\t/** the user's id (i.e. the numerical snowflake) */\n\tid: string;\n\t/** the user's username, not unique across the platform */\n\tusername: string;\n\t/** the user's Discord-tag */\n\tdiscriminator: string;\n\t/** the user's display name, if it is set */\n\tglobal_name: string | null;\n\t/**\n\t * the user's avatar hash:\n\t * https://discord.com/developers/docs/reference#image-formatting\n\t */\n\tavatar: string | null;\n\t/** whether the user belongs to an OAuth2 application */\n\tbot?: boolean;\n\t/**\n\t * whether the user is an Official Discord System user (part of the urgent\n\t * message system)\n\t */\n\tsystem?: boolean;\n\t/** whether the user has two factor enabled on their account */\n\tmfa_enabled: boolean;\n\t/**\n\t * the user's banner hash:\n\t * https://discord.com/developers/docs/reference#image-formatting\n\t */\n\tbanner: string | null;\n\n\t/** the user's banner color encoded as an integer representation of hexadecimal color code */\n\taccent_color: number | null;\n\n\t/**\n\t * the user's chosen language option:\n\t * https://discord.com/developers/docs/reference#locales\n\t */\n\tlocale: string;\n\t/** whether the email on this account has been verified */\n\tverified: boolean;\n\t/** the user's email */\n\temail: string;\n\t/**\n\t * the flags on a user's account:\n\t * https://discord.com/developers/docs/resources/user#user-object-user-flags\n\t */\n\tflags: number;\n\t/**\n\t * the type of Nitro subscription on a user's account:\n\t * https://discord.com/developers/docs/resources/user#user-object-premium-types\n\t */\n\tpremium_type: number;\n\t/**\n\t * the public flags on a user's account:\n\t * https://discord.com/developers/docs/resources/user#user-object-user-flags\n\t */\n\tpublic_flags: number;\n\t/** undocumented field; corresponds to the user's custom nickname */\n\tdisplay_name: string | null;\n\t/**\n\t * undocumented field; corresponds to the Discord feature where you can e.g.\n\t * put your avatar inside of an ice cube\n\t */\n\tavatar_decoration: string | null;\n\t/**\n\t * undocumented field; corresponds to the premium feature where you can\n\t * select a custom banner color\n\t */\n\tbanner_color: string | null;\n\t/** undocumented field; the CDN URL of their profile picture */\n\timage_url: string;\n}\n\nexport interface DiscordOptions {\n\tclientId: string;\n\tclientSecret: string;\n\tredirectURI?: string;\n}\n\nexport const discord = ({\n\tclientId,\n\tclientSecret,\n\tredirectURI,\n}: DiscordOptions) => {\n\tconst discordArctic = new Discord(\n\t\tclientId,\n\t\tclientSecret,\n\t\tgetRedirectURI(\"discord\", redirectURI),\n\t);\n\treturn {\n\t\tid: \"discord\",\n\t\tname: \"Discord\",\n\t\tcreateAuthorizationURL({ state, scopes }) {\n\t\t\tconst _scope = scopes || [\"email\"];\n\t\t\treturn discordArctic.createAuthorizationURL(state, _scope);\n\t\t},\n\t\tvalidateAuthorizationCode: discordArctic.validateAuthorizationCode,\n\t\tasync getUserInfo(token) {\n\t\t\tconst { data: profile, error } = await betterFetch<DiscordProfile>(\n\t\t\t\t\"https://discord.com/api/users/@me\",\n\t\t\t\t{\n\t\t\t\t\tauth: {\n\t\t\t\t\t\ttype: \"Bearer\",\n\t\t\t\t\t\ttoken: token.accessToken,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t\tif (error) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tuser: {\n\t\t\t\t\tid: profile.id,\n\t\t\t\t\tname: profile.display_name || profile.username || \"\",\n\t\t\t\t\temail: profile.email,\n\t\t\t\t\temailVerified: profile.verified,\n\t\t\t\t},\n\t\t\t\tdata: profile,\n\t\t\t};\n\t\t},\n\t} satisfies OAuthProvider<DiscordProfile>;\n};\n","import { betterFetch } from \"@better-fetch/fetch\";\nimport { Facebook } from \"arctic\";\nimport type { OAuthProvider } from \".\";\nimport { getRedirectURI } from \"./utils\";\n\nexport interface FacebookProfile {\n\tid: string;\n\tname: string;\n\temail: string;\n\temail_verified: boolean;\n\tpicture: {\n\t\tdata: {\n\t\t\theight: number;\n\t\t\tis_silhouette: boolean;\n\t\t\turl: string;\n\t\t\twidth: number;\n\t\t};\n\t};\n}\nexport interface FacebookOptions {\n\tclientId: string;\n\tclientSecret: string;\n\tredirectURI?: string;\n}\nexport const facebook = ({\n\tclientId,\n\tclientSecret,\n\tredirectURI,\n}: FacebookOptions) => {\n\tconst facebookArctic = new Facebook(\n\t\tclientId,\n\t\tclientSecret,\n\t\tgetRedirectURI(\"facebook\", redirectURI),\n\t);\n\treturn {\n\t\tid: \"facebook\",\n\t\tname: \"Facebook\",\n\t\tcreateAuthorizationURL({ state, scopes }) {\n\t\t\tconst _scopes = scopes || [\"email\", \"public_profile\"];\n\t\t\treturn facebookArctic.createAuthorizationURL(state, _scopes);\n\t\t},\n\t\tvalidateAuthorizationCode: facebookArctic.validateAuthorizationCode,\n\t\tasync getUserInfo(token) {\n\t\t\tconst { data: profile, error } = await betterFetch<FacebookProfile>(\n\t\t\t\t\"https://graph.facebook.com/me\",\n\t\t\t\t{\n\t\t\t\t\tauth: {\n\t\t\t\t\t\ttype: \"Bearer\",\n\t\t\t\t\t\ttoken: token.accessToken,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t\tif (error) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tuser: {\n\t\t\t\t\tid: profile.id,\n\t\t\t\t\tname: profile.name,\n\t\t\t\t\temail: profile.email,\n\t\t\t\t\temailVerified: profile.email_verified,\n\t\t\t\t},\n\t\t\t\tdata: profile,\n\t\t\t};\n\t\t},\n\t} satisfies OAuthProvider<FacebookProfile>;\n};\n","import { betterFetch } from \"@better-fetch/fetch\";\nimport { GitHub } from \"arctic\";\nimport type { OAuthProvider } from \".\";\nimport { getRedirectURI } from \"./utils\";\n\nexport interface GithubProfile {\n\tlogin: string;\n\tid: string;\n\tnode_id: string;\n\tavatar_url: string;\n\tgravatar_id: string;\n\turl: string;\n\thtml_url: string;\n\tfollowers_url: string;\n\tfollowing_url: string;\n\tgists_url: string;\n\tstarred_url: string;\n\tsubscriptions_url: string;\n\torganizations_url: string;\n\trepos_url: string;\n\tevents_url: string;\n\treceived_events_url: string;\n\ttype: string;\n\tsite_admin: boolean;\n\tname: string;\n\tcompany: string;\n\tblog: string;\n\tlocation: string;\n\temail: string;\n\thireable: boolean;\n\tbio: string;\n\ttwitter_username: string;\n\tpublic_repos: string;\n\tpublic_gists: string;\n\tfollowers: string;\n\tfollowing: string;\n\tcreated_at: string;\n\tupdated_at: string;\n\tprivate_gists: string;\n\ttotal_private_repos: string;\n\towned_private_repos: string;\n\tdisk_usage: string;\n\tcollaborators: string;\n\ttwo_factor_authentication: boolean;\n\tplan: {\n\t\tname: string;\n\t\tspace: string;\n\t\tprivate_repos: string;\n\t\tcollaborators: string;\n\t};\n\tfirst_name: string;\n\tlast_name: string;\n}\n\nexport interface GithubOptions {\n\tclientId: string;\n\tclientSecret: string;\n\tredirectURI?: string;\n}\nexport const github = ({\n\tclientId,\n\tclientSecret,\n\tredirectURI,\n}: GithubOptions) => {\n\tconst githubArctic = new GitHub(\n\t\tclientId,\n\t\tclientSecret,\n\t\tgetRedirectURI(\"github\", redirectURI),\n\t);\n\treturn {\n\t\tid: \"github\",\n\t\tname: \"Github\",\n\t\tcreateAuthorizationURL({ state, scopes }) {\n\t\t\tconst _scopes = scopes || [\"user:email\"];\n\t\t\treturn githubArctic.createAuthorizationURL(state, _scopes);\n\t\t},\n\t\tvalidateAuthorizationCode: githubArctic.validateAuthorizationCode,\n\t\tasync getUserInfo(token) {\n\t\t\tconst { data: profile, error } = await betterFetch<GithubProfile>(\n\t\t\t\t\"https://api.github.com/user\",\n\t\t\t\t{\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\theaders: {\n\t\t\t\t\t\tAuthorization: `Bearer ${token.accessToken}`,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t\tif (error) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tlet emailVerified = false;\n\t\t\tif (!profile.email) {\n\t\t\t\tconst { data, error } = await betterFetch<\n\t\t\t\t\t{\n\t\t\t\t\t\temail: string;\n\t\t\t\t\t\tprimary: boolean;\n\t\t\t\t\t\tverified: boolean;\n\t\t\t\t\t\tvisibility: \"public\" | \"private\";\n\t\t\t\t\t}[]\n\t\t\t\t>(\"https://api.github.com/user/emails\", {\n\t\t\t\t\theaders: {\n\t\t\t\t\t\tAuthorization: `Bearer ${token.accessToken}`,\n\t\t\t\t\t\t\"User-Agent\": \"better-auth\",\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\tif (!error) {\n\t\t\t\t\tprofile.email = (data.find((e) => e.primary) ?? data[0])\n\t\t\t\t\t\t?.email as string;\n\t\t\t\t\temailVerified =\n\t\t\t\t\t\tdata.find((e) => e.email === profile.email)?.verified ?? false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tuser: {\n\t\t\t\t\tid: profile.id,\n\t\t\t\t\tname: profile.name,\n\t\t\t\t\temail: profile.email,\n\t\t\t\t\timage: profile.avatar_url,\n\t\t\t\t\temailVerified,\n\t\t\t\t\tcreatedAt: new Date(),\n\t\t\t\t\tupdatedAt: new Date(),\n\t\t\t\t},\n\t\t\t\tdata: profile,\n\t\t\t};\n\t\t},\n\t} satisfies OAuthProvider<GithubProfile>;\n};\n","import { Google } from \"arctic\";\nimport { parseJWT } from \"oslo/jwt\";\nimport type { OAuthProvider } from \".\";\nimport { getRedirectURI } from \"./utils\";\nimport { BetterAuthError } from \"../error/better-auth-error\";\n\nexport interface GoogleProfile {\n\taud: string;\n\tazp: string;\n\temail: string;\n\temail_verified: boolean;\n\texp: number;\n\t/**\n\t * The family name of the user, or last name in most\n\t * Western languages.\n\t */\n\tfamily_name: string;\n\t/**\n\t * The given name of the user, or first name in most\n\t * Western languages.\n\t */\n\tgiven_name: string;\n\thd?: string;\n\tiat: number;\n\tiss: string;\n\tjti?: string;\n\tlocale?: string;\n\tname: string;\n\tnbf?: number;\n\tpicture: string;\n\tsub: string;\n}\n\nexport interface GoogleOptions {\n\tclientId: string;\n\tclientSecret: string;\n\tredirectURI?: string;\n}\n\nexport const google = ({\n\tclientId,\n\tclientSecret,\n\tredirectURI,\n}: GoogleOptions) => {\n\tconst googleArctic = new Google(\n\t\tclientId,\n\t\tclientSecret,\n\t\tgetRedirectURI(\"google\", redirectURI),\n\t);\n\treturn {\n\t\tid: \"google\",\n\t\tname: \"Google\",\n\t\tcreateAuthorizationURL({ state, scopes, codeVerifier }) {\n\t\t\tif (!codeVerifier) {\n\t\t\t\tthrow new BetterAuthError(\"codeVerifier is required for Google\");\n\t\t\t}\n\t\t\tconst _scopes = scopes || [\"email\", \"profile\"];\n\t\t\treturn googleArctic.createAuthorizationURL(state, codeVerifier, _scopes);\n\t\t},\n\t\tvalidateAuthorizationCode: async (code, codeVerifier) => {\n\t\t\tif (!codeVerifier) {\n\t\t\t\tthrow new BetterAuthError(\"codeVerifier is required for Google\");\n\t\t\t}\n\t\t\treturn googleArctic.validateAuthorizationCode(code, codeVerifier);\n\t\t},\n\t\tasync getUserInfo(token) {\n\t\t\tif (!token.idToken) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst user = parseJWT(token.idToken())?.payload as GoogleProfile;\n\t\t\treturn {\n\t\t\t\tuser: {\n\t\t\t\t\tid: user.sub,\n\t\t\t\t\tname: user.name,\n\t\t\t\t\temail: user.email,\n\t\t\t\t\timage: user.picture,\n\t\t\t\t\temailVerified: user.email_verified,\n\t\t\t\t},\n\t\t\t\tdata: user,\n\t\t\t};\n\t\t},\n\t} satisfies OAuthProvider<GoogleProfile>;\n};\n","import { betterFetch } from \"@better-fetch/fetch\";\nimport { Spotify } from \"arctic\";\nimport type { OAuthProvider } from \".\";\nimport { getRedirectURI } from \"./utils\";\n\nexport interface SpotifyProfile {\n\tid: string;\n\tdisplay_name: string;\n\temail: string;\n\timages: {\n\t\turl: string;\n\t}[];\n}\n\nexport interface SpotifyOptions {\n\tclientId: string;\n\tclientSecret: string;\n\tredirectURI?: string;\n}\n\nexport const spotify = ({\n\tclientId,\n\tclientSecret,\n\tredirectURI,\n}: SpotifyOptions) => {\n\tconst spotifyArctic = new Spotify(\n\t\tclientId,\n\t\tclientSecret,\n\t\tgetRedirectURI(\"spotify\", redirectURI),\n\t);\n\treturn {\n\t\tid: \"spotify\",\n\t\tname: \"Spotify\",\n\t\tcreateAuthorizationURL({ state, scopes }) {\n\t\t\tconst _scopes = scopes || [\"user-read-email\"];\n\t\t\treturn spotifyArctic.createAuthorizationURL(state, _scopes);\n\t\t},\n\t\tvalidateAuthorizationCode: spotifyArctic.validateAuthorizationCode,\n\t\tasync getUserInfo(token) {\n\t\t\tconst { data: profile, error } = await betterFetch<SpotifyProfile>(\n\t\t\t\t\"https://api.spotify.com/v1/me\",\n\t\t\t\t{\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\theaders: {\n\t\t\t\t\t\tAuthorization: `Bearer ${token.accessToken}`,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t\tif (error) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tuser: {\n\t\t\t\t\tid: profile.id,\n\t\t\t\t\tname: profile.display_name,\n\t\t\t\t\temail: profile.email,\n\t\t\t\t\timage: profile.images[0]?.url,\n\t\t\t\t\temailVerified: false,\n\t\t\t\t},\n\t\t\t\tdata: profile,\n\t\t\t};\n\t\t},\n\t} satisfies OAuthProvider<SpotifyProfile>;\n};\n","import { betterFetch } from \"@better-fetch/fetch\";\nimport { Twitch } from \"arctic\";\nimport type { OAuthProvider } from \".\";\nimport { getRedirectURI } from \"./utils\";\n\nexport interface TwitchProfile {\n\t/**\n\t * The sub of the user\n\t */\n\tsub: string;\n\t/**\n\t * The preferred username of the user\n\t */\n\tpreferred_username: string;\n\t/**\n\t * The email of the user\n\t */\n\temail: string;\n\t/**\n\t * The picture of the user\n\t */\n\tpicture: string;\n}\n\nexport interface TwitchOptions {\n\tclientId: string;\n\tclientSecret: string;\n\tredirectURI?: string;\n}\n\nexport const twitch = ({\n\tclientId,\n\tclientSecret,\n\tredirectURI,\n}: TwitchOptions) => {\n\tconst twitchArctic = new Twitch(\n\t\tclientId,\n\t\tclientSecret,\n\t\tgetRedirectURI(\"twitch\", redirectURI),\n\t);\n\treturn {\n\t\tid: \"twitch\",\n\t\tname: \"Twitch\",\n\t\tcreateAuthorizationURL({ state, scopes }) {\n\t\t\tconst _scopes = scopes || [\"activity:write\", \"read\"];\n\t\t\treturn twitchArctic.createAuthorizationURL(state, _scopes);\n\t\t},\n\t\tvalidateAuthorizationCode: twitchArctic.validateAuthorizationCode,\n\t\tasync getUserInfo(token) {\n\t\t\tconst { data: profile, error } = await betterFetch<TwitchProfile>(\n\t\t\t\t\"https://api.twitch.tv/helix/users\",\n\t\t\t\t{\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\theaders: {\n\t\t\t\t\t\tAuthorization: `Bearer ${token.accessToken}`,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t\tif (error) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tuser: {\n\t\t\t\t\tid: profile.sub,\n\t\t\t\t\tname: profile.preferred_username,\n\t\t\t\t\temail: profile.email,\n\t\t\t\t\timage: profile.picture,\n\t\t\t\t\temailVerified: false,\n\t\t\t\t},\n\t\t\t\tdata: profile,\n\t\t\t};\n\t\t},\n\t} satisfies OAuthProvider<TwitchProfile>;\n};\n","import { betterFetch } from \"@better-fetch/fetch\";\nimport { Twitter } from \"arctic\";\nimport type { OAuthProvider } from \".\";\nimport { getRedirectURI } from \"./utils\";\nimport { BetterAuthError } from \"../error/better-auth-error\";\n\nexport interface TwitterProfile {\n\tdata: {\n\t\t/**\n\t\t * Unique identifier of this user. This is returned as a string in order to avoid complications with languages and tools\n\t\t * that cannot handle large integers.\n\t\t */\n\t\tid: string;\n\t\t/** The friendly name of this user, as shown on their profile. */\n\t\tname: string;\n\t\t/** @note Email is currently unsupported by Twitter. */\n\t\temail?: string;\n\t\t/** The Twitter handle (screen name) of this user. */\n\t\tusername: string;\n\t\t/**\n\t\t * The location specified in the user's profile, if the user provided one.\n\t\t * As this is a freeform value, it may not indicate a valid location, but it may be fuzzily evaluated when performing searches with location queries.\n\t\t *\n\t\t * To return this field, add `user.fields=location` in the authorization request's query parameter.\n\t\t */\n\t\tlocation?: string;\n\t\t/**\n\t\t * This object and its children fields contain details about text that has a special meaning in the user's description.\n\t\t *\n\t\t *To return this field, add `user.fields=entities` in the authorization request's query parameter.\n\t\t */\n\t\tentities?: {\n\t\t\t/** Contains details about the user's profile website. */\n\t\t\turl: {\n\t\t\t\t/** Contains details about the user's profile website. */\n\t\t\t\turls: Array<{\n\t\t\t\t\t/** The start position (zero-based) of the recognized user's profile website. All start indices are inclusive. */\n\t\t\t\t\tstart: number;\n\t\t\t\t\t/** The end position (zero-based) of the recognized user's profile website. This end index is exclusive. */\n\t\t\t\t\tend: number;\n\t\t\t\t\t/** The URL in the format entered by the user. */\n\t\t\t\t\turl: string;\n\t\t\t\t\t/** The fully resolved URL. */\n\t\t\t\t\texpanded_url: string;\n\t\t\t\t\t/** The URL as displayed in the user's profile. */\n\t\t\t\t\tdisplay_url: string;\n\t\t\t\t}>;\n\t\t\t};\n\t\t\t/** Contains details about URLs, Hashtags, Cashtags, or mentions located within a user's description. */\n\t\t\tdescription: {\n\t\t\t\thashtags: Array<{\n\t\t\t\t\tstart: number;\n\t\t\t\t\tend: number;\n\t\t\t\t\ttag: string;\n\t\t\t\t}>;\n\t\t\t};\n\t\t};\n\t\t/**\n\t\t * Indicate if this user is a verified Twitter user.\n\t\t *\n\t\t * To return this field, add `user.fields=verified` in the authorization request's query parameter.\n\t\t */\n\t\tverified?: boolean;\n\t\t/**\n\t\t * The text of this user's profile description (also known as bio), if the user provided one.\n\t\t *\n\t\t * To return this field, add `user.fields=description` in the authorization request's query parameter.\n\t\t */\n\t\tdescription?: string;\n\t\t/**\n\t\t * The URL specified in the user's profile, if present.\n\t\t *\n\t\t * To return this field, add `user.fields=url` in the authorization request's query parameter.\n\t\t */\n\t\turl?: string;\n\t\t/** The URL to the profile image for this user, as shown on the user's profile. */\n\t\tprofile_image_url?: string;\n\t\tprotected?: boolean;\n\t\t/**\n\t\t * Unique identifier of this user's pinned Tweet.\n\t\t *\n\t\t * You can obtain the expanded object in `includes.tweets` by adding `expansions=pinned_tweet_id` in the authorization request's query parameter.\n\t\t */\n\t\tpinned_tweet_id?: string;\n\t\tcreated_at?: string;\n\t};\n\tincludes?: {\n\t\ttweets?: Array<{\n\t\t\tid: string;\n\t\t\ttext: string;\n\t\t}>;\n\t};\n\t[claims: string]: unknown;\n}\n\nexport interface TwitterOption {\n\tclientId: string;\n\tclientSecret: string;\n\tredirectURI?: string;\n}\n\nexport const twitter = ({\n\tclientId,\n\tclientSecret,\n\tredirectURI,\n}: TwitterOption) => {\n\tconst twitterArctic = new Twitter(\n\t\tclientId,\n\t\tclientSecret,\n\t\tgetRedirectURI(\"twitter\", redirectURI),\n\t);\n\treturn {\n\t\tid: \"twitter\",\n\t\tname: \"Twitter\",\n\t\tcreateAuthorizationURL(data) {\n\t\t\tconst _scopes = data.scopes || [\"account_info.read\"];\n\t\t\treturn twitterArctic.createAuthorizationURL(\n\t\t\t\tdata.state,\n\t\t\t\tdata.codeVerifier,\n\t\t\t\t_scopes,\n\t\t\t);\n\t\t},\n\t\tvalidateAuthorizationCode: async (code, codeVerifier) => {\n\t\t\tif (!codeVerifier) {\n\t\t\t\tthrow new BetterAuthError(\"codeVerifier is required for Twitter\");\n\t\t\t}\n\t\t\treturn twitterArctic.validateAuthorizationCode(code, codeVerifier);\n\t\t},\n\t\tasync getUserInfo(token) {\n\t\t\tconst { data: profile, error } = await betterFetch<TwitterProfile>(\n\t\t\t\t\"https://api.x.com/2/users/me?user.fields=profile_image_url\",\n\t\t\t\t{\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\theaders: {\n\t\t\t\t\t\tAuthorization: `Bearer ${token.accessToken}`,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t\tif (error) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tif (!profile.data.email) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tuser: {\n\t\t\t\t\tid: profile.data.id,\n\t\t\t\t\tname: profile.data.name,\n\t\t\t\t\temail: profile.data.email,\n\t\t\t\t\timage: profile.data.profile_image_url,\n\t\t\t\t\temailVerified: profile.data.verified || false,\n\t\t\t\t},\n\t\t\t\tdata: profile,\n\t\t\t};\n\t\t},\n\t} satisfies OAuthProvider<TwitterProfile>;\n};\n","import type { User } from \"../adapters/schema\";\nimport type { oAuthProviderList } from \"../social-providers\";\nimport type { LiteralString } from \"./helper\";\nimport { OAuth2Tokens } from \"arctic\";\n\nexport interface OAuthProvider<\n\tT extends Record<string, any> = Record<string, any>,\n> {\n\tid: LiteralString;\n\tcreateAuthorizationURL: (data: {\n\t\tstate: string;\n\t\tcodeVerifier: string;\n\t\tscopes?: string[];\n\t}) => URL;\n\tname: string;\n\tvalidateAuthorizationCode: (\n\t\tcode: string,\n\t\tcodeVerifier?: string,\n\t) => Promise<OAuth2Tokens>;\n\tgetUserInfo: (token: OAuth2Tokens) => Promise<{\n\t\tuser: Omit<User, \"createdAt\" | \"updatedAt\">;\n\t\tdata: T;\n\t} | null>;\n\trefreshAccessToken?: (refreshToken: string) => Promise<OAuth2Tokens>;\n\trevokeToken?: (token: string) => Promise<void>;\n}\n\nexport type OAuthProviderList = typeof oAuthProviderList;\n","import { apple } from \"./apple\";\nimport { discord } from \"./discord\";\nimport { facebook } from \"./facebook\";\nimport { github } from \"./github\";\nimport { google } from \"./google\";\nimport { spotify } from \"./spotify\";\nimport { twitch } from \"./twitch\";\nimport { twitter } from \"./twitter\";\n\nexport const oAuthProviders = {\n\tapple,\n\tdiscord,\n\tfacebook,\n\tgithub,\n\tgoogle,\n\tspotify,\n\ttwitch,\n\ttwitter,\n};\n\nexport const oAuthProviderList = Object.keys(oAuthProviders) as [\n\t\"github\",\n\t...(keyof typeof oAuthProviders)[],\n];\n\nexport * from \"./github\";\nexport * from \"./google\";\nexport * from \"./apple\";\nexport * from \"./discord\";\nexport * from \"./spotify\";\nexport * from \"./twitch\";\nexport * from \"./facebook\";\nexport * from \"./twitter\";\nexport * from \"../types/provider\";\n","import { generateState as generateStateOAuth } from \"oslo/oauth2\";\n\nexport function generateState(callbackURL?: string, currentURL?: string) {\n\tconst code = generateStateOAuth();\n\tconst state = `${code}!${callbackURL}!${currentURL}`;\n\treturn { state, code };\n}\n\nexport function parseState(state: string) {\n\tconst [code, callbackURL, currentURL] = state.split(\"!\");\n\treturn { code, callbackURL, currentURL };\n}\n","import type { Context } from \"better-call\";\nimport { createAuthEndpoint } from \"../call\";\n\nexport const getSession = createAuthEndpoint(\n\t\"/session\",\n\t{\n\t\tmethod: \"GET\",\n\t\trequireHeaders: true,\n\t},\n\tasync (ctx) => {\n\t\tconst sessionCookieToken = await ctx.getSignedCookie(\n\t\t\tctx.context.authCookies.sessionToken.name,\n\t\t\tctx.context.secret,\n\t\t);\n\t\tif (!sessionCookieToken) {\n\t\t\treturn ctx.json(null, {\n\t\t\t\tstatus: 401,\n\t\t\t});\n\t\t}\n\t\tconst session =\n\t\t\tawait ctx.context.internalAdapter.findSession(sessionCookieToken);\n\t\tif (!session || session.session.expiresAt < new Date()) {\n\t\t\tctx.setSignedCookie(\n\t\t\t\tctx.context.authCookies.sessionToken.name,\n\t\t\t\t\"\",\n\t\t\t\tctx.context.secret,\n\t\t\t\t{\n\t\t\t\t\tmaxAge: 0,\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn ctx.json(null, {\n\t\t\t\tstatus: 401,\n\t\t\t});\n\t\t}\n\t\tconst updatedSession = await ctx.context.internalAdapter.updateSession(\n\t\t\tsession.session,\n\t\t);\n\n\t\tawait ctx.setSignedCookie(\n\t\t\tctx.context.authCookies.sessionToken.name,\n\t\t\tupdatedSession.id,\n\t\t\tctx.context.secret,\n\t\t\t{\n\t\t\t\t...ctx.context.authCookies.sessionToken.options,\n\t\t\t\tmaxAge: updatedSession.expiresAt.valueOf() - Date.now(),\n\t\t\t},\n\t\t);\n\t\treturn ctx.json({\n\t\t\tsession: updatedSession,\n\t\t\tuser: session.user,\n\t\t});\n\t},\n);\n\nexport const getSessionFromCtx = async (ctx: Context<any, any>) => {\n\tconst session = await getSession({\n\t\t...ctx,\n\t\t//@ts-expect-error: By default since this request context comes from a router it'll have a `router` flag which force it to be a request object\n\t\t_flag: undefined,\n\t});\n\treturn session;\n};\n","import { APIError } from \"better-call\";\nimport { z } from \"zod\";\nimport { userSchema } from \"../../adapters/schema\";\nimport { HIDE_ON_CLIENT_METADATA } from \"../../client/client-utils\";\nimport { generateId } from \"../../utils/id\";\nimport { parseState } from \"../../utils/state\";\nimport { createAuthEndpoint } from \"../call\";\n\nexport const callbackOAuth = createAuthEndpoint(\n\t\"/callback/:id\",\n\t{\n\t\tmethod: \"GET\",\n\t\tquery: z.object({\n\t\t\tstate: z.string(),\n\t\t\tcode: z.string(),\n\t\t\tcode_verifier: z.string().optional(),\n\t\t}),\n\t\tmetadata: HIDE_ON_CLIENT_METADATA,\n\t},\n\tasync (c) => {\n\t\tconst provider = c.context.options.socialProvider?.find(\n\t\t\t(p) => p.id === c.params.id,\n\t\t);\n\t\tif (!provider) {\n\t\t\tc.context.logger.error(\n\t\t\t\t\"Oauth provider with id\",\n\t\t\t\tc.params.id,\n\t\t\t\t\"not found\",\n\t\t\t);\n\t\t\tthrow new APIError(\"NOT_FOUND\");\n\t\t}\n\t\tconst tokens = await provider.validateAuthorizationCode(\n\t\t\tc.query.code,\n\t\t\tc.query.code_verifier || \"\",\n\t\t);\n\t\tif (!tokens) {\n\t\t\tc.context.logger.error(\"Code verification failed\");\n\t\t\tthrow new APIError(\"UNAUTHORIZED\");\n\t\t}\n\t\tconst user = await provider.getUserInfo(tokens).then((res) => res?.user);\n\t\tconst id = generateId();\n\t\tconst data = userSchema.safeParse({\n\t\t\t...user,\n\t\t\tid,\n\t\t});\n\t\tconst { callbackURL, currentURL } = parseState(c.query.state);\n\t\tif (!user || data.success === false) {\n\t\t\tif (currentURL) {\n\t\t\t\tthrow c.redirect(`${currentURL}?error=oauth_validation_failed`);\n\t\t\t} else {\n\t\t\t\tthrow new APIError(\"BAD_REQUEST\");\n\t\t\t}\n\t\t}\n\t\tif (!callbackURL) {\n\t\t\tc.context.logger.error(\"Callback URL not found\");\n\t\t\tthrow new APIError(\"FORBIDDEN\");\n\t\t}\n\t\t//find user in db\n\t\tconst dbUser = await c.context.internalAdapter.findUserByEmail(user.email);\n\t\tconst userId = dbUser?.user.id;\n\t\tif (dbUser) {\n\t\t\t//check if user has already linked this provider\n\t\t\tconst hasBeenLinked = dbUser.accounts.find(\n\t\t\t\t(a) => a.providerId === provider.id,\n\t\t\t);\n\t\t\tif (!hasBeenLinked && !user.emailVerified) {\n\t\t\t\tc.context.logger.error(\"User already exists\");\n\t\t\t\tconst url = new URL(currentURL || callbackURL);\n\t\t\t\turl.searchParams.set(\"error\", \"user_already_exists\");\n\t\t\t\tthrow c.redirect(url.toString());\n\t\t\t}\n\n\t\t\tif (!hasBeenLinked && user.emailVerified) {\n\t\t\t\tawait c.context.internalAdapter.linkAccount({\n\t\t\t\t\tproviderId: provider.id,\n\t\t\t\t\taccountId: user.id,\n\t\t\t\t\tid: `${provider.id}:${user.id}`,\n\t\t\t\t\tuserId: dbUser.user.id,\n\t\t\t\t\t...tokens,\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tawait c.context.internalAdapter.createOAuthUser(data.data, {\n\t\t\t\t\t...tokens,\n\t\t\t\t\tid: `${provider.id}:${user.id}`,\n\t\t\t\t\tproviderId: provider.id,\n\t\t\t\t\taccountId: user.id,\n\t\t\t\t\tuserId: id,\n\t\t\t\t});\n\t\t\t} catch (e) {\n\t\t\t\tconst url = new URL(currentURL || callbackURL);\n\t\t\t\turl.searchParams.set(\"error\", \"unable_to_create_user\");\n\t\t\t\tc.setHeader(\"Location\", url.toString());\n\t\t\t\tthrow c.redirect(url.toString());\n\t\t\t}\n\t\t}\n\t\t//this should never happen\n\t\tif (!userId && !id)\n\t\t\tthrow new APIError(\"INTERNAL_SERVER_ERROR\", {\n\t\t\t\tmessage: \"Unable to create user\",\n\t\t\t});\n\t\t//create session\n\t\tconst session = await c.context.internalAdapter.createSession(\n\t\t\tuserId || id,\n\t\t\tc.request,\n\t\t);\n\t\ttry {\n\t\t\tawait c.setSignedCookie(\n\t\t\t\tc.context.authCookies.sessionToken.name,\n\t\t\t\tsession.id,\n\t\t\t\tc.context.secret,\n\t\t\t\tc.context.authCookies.sessionToken.options,\n\t\t\t);\n\t\t} catch (e) {\n\t\t\tc.context.logger.error(\"Unable to set session cookie\", e);\n\t\t\tconst url = new URL(currentURL || callbackURL);\n\t\t\turl.searchParams.set(\"error\", \"unable_to_create_session\");\n\t\t\tthrow c.redirect(url.toString());\n\t\t}\n\t\tthrow c.redirect(callbackURL);\n\t},\n);\n","export const HIDE_ON_CLIENT_METADATA = {\n\tonClient: \"hide\" as const,\n};\n","import { alphabet, generateRandomString } from \"oslo/crypto\";\nexport const generateId = () => {\n\treturn generateRandomString(36, alphabet(\"a-z\", \"0-9\"));\n};\n","import { z } from \"zod\";\nimport { createAuthEndpoint } from \"../call\";\n\nexport const signOut = createAuthEndpoint(\n\t\"/sign-out\",\n\t{\n\t\tmethod: \"POST\",\n\t\tbody: z\n\t\t\t.object({\n\t\t\t\tcallbackURL: z.string().optional(),\n\t\t\t})\n\t\t\t.optional(),\n\t},\n\tasync (ctx) => {\n\t\tconst sessionCookieToken = await ctx.getSignedCookie(\n\t\t\tctx.context.authCookies.sessionToken.name,\n\t\t\tctx.context.secret,\n\t\t);\n\t\tif (!sessionCookieToken) {\n\t\t\treturn ctx.json(null);\n\t\t}\n\t\tawait ctx.context.internalAdapter.deleteSession(sessionCookieToken);\n\t\tctx.setCookie(ctx.context.authCookies.sessionToken.name, \"\", {\n\t\t\tmaxAge: 0,\n\t\t});\n\t\treturn ctx.json(null, {\n\t\t\tbody: {\n\t\t\t\tredirect: !!ctx.body?.callbackURL,\n\t\t\t\turl: ctx.body?.callbackURL,\n\t\t\t},\n\t\t});\n\t},\n);\n","import { TimeSpan } from \"oslo\";\nimport { createJWT } from \"oslo/jwt\";\nimport { validateJWT } from \"oslo/jwt\";\nimport { Argon2id } from \"oslo/password\";\nimport { z } from \"zod\";\nimport { createAuthEndpoint } from \"../call\";\n\nexport const forgetPassword = createAuthEndpoint(\n\t\"/forget-password\",\n\t{\n\t\tmethod: \"POST\",\n\t\tbody: z.object({\n\t\t\t/**\n\t\t\t * The email address of the user to send a password reset email to.\n\t\t\t */\n\t\t\temail: z.string().email(),\n\t\t}),\n\t},\n\tasync (ctx) => {\n\t\tif (!ctx.context.options.emailAndPassword?.sendResetPasswordToken) {\n\t\t\tctx.context.logger.error(\n\t\t\t\t\"Reset password isn't enabled.Please pass an emailAndPassword.sendResetPasswordToken function to your auth config!\",\n\t\t\t);\n\t\t\treturn ctx.json(null, {\n\t\t\t\tstatus: 400,\n\t\t\t\tstatusText: \"RESET_PASSWORD_EMAIL_NOT_SENT\",\n\t\t\t\tbody: {\n\t\t\t\t\tmessage: \"Reset password isn't enabled\",\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t\tconst { email } = ctx.body;\n\t\tconst user = await ctx.context.internalAdapter.findUserByEmail(email);\n\t\tif (!user) {\n\t\t\treturn ctx.json(\n\t\t\t\t{\n\t\t\t\t\terror: \"User not found\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tstatus: 400,\n\t\t\t\t\tstatusText: \"USER_NOT_FOUND\",\n\t\t\t\t\tbody: {\n\t\t\t\t\t\tmessage: \"User not found\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t\tconst token = await createJWT(\n\t\t\t\"HS256\",\n\t\t\tBuffer.from(ctx.context.secret),\n\t\t\t{\n\t\t\t\temail: user.user.email,\n\t\t\t},\n\t\t\t{\n\t\t\t\texpiresIn: new TimeSpan(1, \"h\"),\n\t\t\t\tissuer: \"better-auth\",\n\t\t\t\tsubject: \"forget-password\",\n\t\t\t\taudiences: [user.user.email],\n\t\t\t\tincludeIssuedTimestamp: true,\n\t\t\t},\n\t\t);\n\t\tawait ctx.context.options.emailAndPassword.sendResetPasswordToken(\n\t\t\ttoken,\n\t\t\tuser.user,\n\t\t);\n\t\treturn ctx.json({\n\t\t\tstatus: true,\n\t\t});\n\t},\n);\n\nexport const resetPassword = createAuthEndpoint(\n\t\"/reset-password\",\n\t{\n\t\tmethod: \"POST\",\n\t\tbody: z.object({\n\t\t\ttoken: z.string(),\n\t\t\tnewPassword: z.string(),\n\t\t\tcallbackURL: z.string().optional(),\n\t\t}),\n\t},\n\tasync (ctx) => {\n\t\tconst { token, newPassword } = ctx.body;\n\t\ttry {\n\t\t\tconst jwt = await validateJWT(\n\t\t\t\t\"HS256\",\n\t\t\t\tBuffer.from(ctx.context.secret),\n\t\t\t\ttoken,\n\t\t\t);\n\t\t\tconst email = z\n\t\t\t\t.string()\n\t\t\t\t.email()\n\t\t\t\t.parse((jwt.payload as { email: string }).email);\n\t\t\tconst user = await ctx.context.internalAdapter.findUserByEmail(email);\n\t\t\tif (!user) {\n\t\t\t\treturn ctx.json(null, {\n\t\t\t\t\tstatus: 400,\n\t\t\t\t\tstatusText: \"USER_NOT_FOUND\",\n\t\t\t\t\tbody: {\n\t\t\t\t\t\tmessage: \"User not found\",\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (\n\t\t\t\tnewPassword.length <\n\t\t\t\t\t(ctx.context.options.emailAndPassword?.minPasswordLength || 8) ||\n\t\t\t\tnewPassword.length >\n\t\t\t\t\t(ctx.context.options.emailAndPassword?.maxPasswordLength || 32)\n\t\t\t) {\n\t\t\t\treturn ctx.json(null, {\n\t\t\t\t\tstatus: 400,\n\t\t\t\t\tstatusText: \"INVALID_PASSWORD_LENGTH\",\n\t\t\t\t\tbody: {\n\t\t\t\t\t\tmessage: \"Password length must be between 8 and 32\",\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst argon2id = new Argon2id();\n\t\t\tconst hashedPassword = await argon2id.hash(newPassword);\n\t\t\tconst updatedUser = await ctx.context.internalAdapter.updatePassword(\n\t\t\t\tuser.user.id,\n\t\t\t\thashedPassword,\n\t\t\t);\n\t\t\tif (!updatedUser) {\n\t\t\t\treturn ctx.json(null, {\n\t\t\t\t\tstatus: 500,\n\t\t\t\t\tstatusText: \"INTERNAL_SERVER_ERROR\",\n\t\t\t\t\tbody: {\n\t\t\t\t\t\tmessage: \"Internal server error\",\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn ctx.json({\n\t\t\t\tstatus: true,\n\t\t\t\turl: ctx.body.callbackURL,\n\t\t\t\tredirect: !!ctx.body.callbackURL,\n\t\t\t});\n\t\t} catch (e) {\n\t\t\tconsole.log(e);\n\t\t\treturn ctx.json(null, {\n\t\t\t\tstatus: 400,\n\t\t\t\tstatusText: \"INVALID_TOKEN\",\n\t\t\t\tbody: {\n\t\t\t\t\tmessage: \"Invalid token\",\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t},\n);\n","import { TimeSpan } from \"oslo\";\nimport { createJWT, validateJWT } from \"oslo/jwt\";\nimport { z } from \"zod\";\nimport { createAuthEndpoint } from \"../call\";\n\nexport const sendVerificationEmail = createAuthEndpoint(\n\t\"/send-verification-email\",\n\t{\n\t\tmethod: \"POST\",\n\t\tbody: z.object({\n\t\t\temail: z.string().email(),\n\t\t\tcallbackURL: z.string().optional(),\n\t\t}),\n\t},\n\tasync (ctx) => {\n\t\tif (!ctx.context.options.emailAndPassword?.sendVerificationEmail) {\n\t\t\treturn ctx.json(null, {\n\t\t\t\tstatus: 400,\n\t\t\t\tstatusText: \"VERIFICATION_EMAIL_NOT_SENT\",\n\t\t\t\tbody: {\n\t\t\t\t\tmessage: \"Verification email isn't enabled\",\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t\tconst { email } = ctx.body;\n\t\tconst token = await createJWT(\n\t\t\t\"HS256\",\n\t\t\tBuffer.from(ctx.context.secret),\n\t\t\t{\n\t\t\t\temail: email.toLowerCase(),\n\t\t\t},\n\t\t\t{\n\t\t\t\texpiresIn: new TimeSpan(1, \"h\"),\n\t\t\t\tissuer: \"better-auth\",\n\t\t\t\tsubject: \"verify-email\",\n\t\t\t\taudiences: [email],\n\t\t\t\tincludeIssuedTimestamp: true,\n\t\t\t},\n\t\t);\n\t\tconst url = `${ctx.context.baseURL}/verify-email?token=${token}?callbackURL=${ctx.body.callbackURL}`;\n\t\tawait ctx.context.options.emailAndPassword.sendVerificationEmail(\n\t\t\temail,\n\t\t\turl,\n\t\t);\n\t\treturn ctx.json({\n\t\t\tstatus: true,\n\t\t});\n\t},\n);\n\nexport const verifyEmail = createAuthEndpoint(\n\t\"/verify-email\",\n\t{\n\t\tmethod: \"GET\",\n\t\tquery: z.object({\n\t\t\ttoken: z.string(),\n\t\t\tcallbackURL: z.string(),\n\t\t}),\n\t},\n\tasync (ctx) => {\n\t\tconst { token } = ctx.query;\n\t\ttry {\n\t\t\tconst jwt = await validateJWT(\n\t\t\t\t\"HS256\",\n\t\t\t\tBuffer.from(ctx.context.secret),\n\t\t\t\ttoken,\n\t\t\t);\n\t\t\tconst schema = z.object({\n\t\t\t\temail: z.string().email(),\n\t\t\t});\n\t\t\tconst parsed = schema.parse(jwt.payload);\n\t\t\tconst user = await ctx.context.internalAdapter.findUserByEmail(\n\t\t\t\tparsed.email,\n\t\t\t);\n\t\t\tif (!user) {\n\t\t\t\treturn ctx.json(null, {\n\t\t\t\t\tstatus: 400,\n\t\t\t\t\tstatusText: \"USER_NOT_FOUND\",\n\t\t\t\t\tbody: {\n\t\t\t\t\t\tmessage: \"User not found\",\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst account = user.accounts.find((a) => a.providerId === \"credential\");\n\t\t\tif (!account) {\n\t\t\t\treturn ctx.json(null, {\n\t\t\t\t\tstatus: 400,\n\t\t\t\t\tstatusText: \"ACCOUNT_NOT_FOUND\",\n\t\t\t\t\tbody: {\n\t\t\t\t\t\tmessage: \"Account not found\",\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t\tawait ctx.context.internalAdapter.updateUserByEmail(parsed.email, {\n\t\t\t\temailVerified: true,\n\t\t\t});\n\t\t\tif (ctx.query.callbackURL) {\n\t\t\t\tthrow ctx.redirect(ctx.query.callbackURL);\n\t\t\t}\n\t\t\treturn ctx.json({\n\t\t\t\tstatus: true,\n\t\t\t});\n\t\t} catch (e) {\n\t\t\treturn ctx.json(null, {\n\t\t\t\tstatus: 400,\n\t\t\t\tstatusText: \"INVALID_TOKEN\",\n\t\t\t\tbody: {\n\t\t\t\t\tmessage: \"Invalid token\",\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t},\n);\n","import { alphabet, generateRandomString } from \"oslo/crypto\";\nimport { HIDE_ON_CLIENT_METADATA } from \"../../client/client-utils\";\nimport { hs256 } from \"../../crypto\";\nimport { createAuthEndpoint } from \"../call\";\n\nexport const getCSRFToken = createAuthEndpoint(\n\t\"/csrf\",\n\t{\n\t\tmethod: \"GET\",\n\t\tmetadata: HIDE_ON_CLIENT_METADATA,\n\t},\n\tasync (ctx) => {\n\t\tconst csrfToken = await ctx.getSignedCookie(\n\t\t\tctx.context.authCookies.csrfToken.name,\n\t\t\tctx.context.secret,\n\t\t);\n\t\tif (csrfToken) {\n\t\t\treturn {\n\t\t\t\tcsrfToken,\n\t\t\t};\n\t\t}\n\t\tconst token = generateRandomString(32, alphabet(\"a-z\", \"0-9\", \"A-Z\"));\n\t\tconst hash = await hs256(ctx.context.secret, token);\n\t\tconst cookie = `${token}!${hash}`;\n\t\tawait ctx.setSignedCookie(\n\t\t\tctx.context.authCookies.csrfToken.name,\n\t\t\tcookie,\n\t\t\tctx.context.secret,\n\t\t\tctx.context.authCookies.csrfToken.options,\n\t\t);\n\t\treturn {\n\t\t\tcsrfToken: token,\n\t\t};\n\t},\n);\n","import { createAuthEndpoint } from \"../call\";\n\nexport const ok = createAuthEndpoint(\n\t\"/ok\",\n\t{\n\t\tmethod: \"GET\",\n\t},\n\tasync (ctx) => {\n\t\treturn ctx.json({\n\t\t\tok: true,\n\t\t});\n\t},\n);\n\nexport const welcome = createAuthEndpoint(\n\t\"/welcome/ok\",\n\t{\n\t\tmethod: \"GET\",\n\t},\n\tasync () => {\n\t\treturn new Response(\"Welcome to Better Auth\");\n\t},\n);\n","import { alphabet, generateRandomString } from \"oslo/crypto\";\nimport { Argon2id } from \"oslo/password\";\nimport { z } from \"zod\";\nimport { createAuthEndpoint } from \"../call\";\n\nexport const signUpEmail = createAuthEndpoint(\n\t\"/sign-up/email\",\n\t{\n\t\tmethod: \"POST\",\n\t\tbody: z.object({\n\t\t\tname: z.string(),\n\t\t\temail: z.string().email(),\n\t\t\tpassword: z.string(),\n\t\t\timage: z.string().optional(),\n\t\t\tcallbackURL: z.string().optional(),\n\t\t}),\n\t},\n\tasync (ctx) => {\n\t\tif (!ctx.context.options.emailAndPassword?.enabled) {\n\t\t\treturn ctx.json(null, {\n\t\t\t\tstatus: 400,\n\t\t\t\tbody: {\n\t\t\t\t\tmessage: \"Email and password is not enabled\",\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t\tconst { name, email, password, image } = ctx.body;\n\t\tconst minPasswordLength =\n\t\t\tctx.context.options?.emailAndPassword?.minPasswordLength || 8;\n\t\tif (password.length < minPasswordLength) {\n\t\t\tctx.context.logger.error(\"Password is too short\");\n\t\t\treturn ctx.json(null, {\n\t\t\t\tstatus: 400,\n\t\t\t\tbody: { message: \"Password is too short\" },\n\t\t\t});\n\t\t}\n\t\tconst argon2id = new Argon2id();\n\t\tconst dbUser = await ctx.context.internalAdapter.findUserByEmail(email);\n\t\t/**\n\t\t * hash first to avoid timing attacks\n\t\t */\n\t\tconst hash = await argon2id.hash(password);\n\t\tif (dbUser?.user) {\n\t\t\treturn ctx.json(null, {\n\t\t\t\tstatus: 400,\n\t\t\t\tbody: {\n\t\t\t\t\tmessage: \"User already exists\",\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t\tconst createdUser = await ctx.context.internalAdapter.createUser({\n\t\t\tid: generateRandomString(32, alphabet(\"a-z\", \"0-9\", \"A-Z\")),\n\t\t\temail: email.toLowerCase(),\n\t\t\tname,\n\t\t\timage,\n\t\t\temailVerified: false,\n\t\t\tcreatedAt: new Date(),\n\t\t\tupdatedAt: new Date(),\n\t\t});\n\t\t/**\n\t\t * Link the account to the user\n\t\t */\n\t\tawait ctx.context.internalAdapter.linkAccount({\n\t\t\tid: generateRandomString(32, alphabet(\"a-z\", \"0-9\", \"A-Z\")),\n\t\t\tuserId: createdUser.id,\n\t\t\tproviderId: \"credential\",\n\t\t\taccountId: createdUser.id,\n\t\t\tpassword: hash,\n\t\t});\n\t\tconst session = await ctx.context.internalAdapter.createSession(\n\t\t\tcreatedUser.id,\n\t\t\tctx.request,\n\t\t);\n\t\tawait ctx.setSignedCookie(\n\t\t\tctx.context.authCookies.sessionToken.name,\n\t\t\tsession.id,\n\t\t\tctx.context.secret,\n\t\t\tctx.context.authCookies.sessionToken.options,\n\t\t);\n\t\treturn ctx.json(\n\t\t\t{\n\t\t\t\tuser: createdUser,\n\t\t\t\tsession,\n\t\t\t},\n\t\t\t{\n\t\t\t\tbody: ctx.body.callbackURL\n\t\t\t\t\t? {\n\t\t\t\t\t\t\turl: ctx.body.callbackURL,\n\t\t\t\t\t\t\tredirect: true,\n\t\t\t\t\t\t}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tuser: createdUser,\n\t\t\t\t\t\t\tsession,\n\t\t\t\t\t\t},\n\t\t\t},\n\t\t);\n\t},\n);\n","import { createAuthEndpoint } from \"../call\";\n\nconst html = (errorCode: string = \"Unknown\") => `<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>Authentication Error</title>\n <style>\n :root {\n --bg-color: #f8f9fa;\n --text-color: #212529;\n --accent-color: #000000;\n --error-color: #dc3545;\n --border-color: #e9ecef;\n }\n body {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n background-color: var(--bg-color);\n color: var(--text-color);\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100vh;\n margin: 0;\n line-height: 1.5;\n }\n .error-container {\n background-color: #ffffff;\n border-radius: 12px;\n box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);\n padding: 2.5rem;\n text-align: center;\n max-width: 90%;\n width: 400px;\n }\n h1 {\n color: var(--error-color);\n font-size: 1.75rem;\n margin-bottom: 1rem;\n font-weight: 600;\n }\n p {\n margin-bottom: 1.5rem;\n color: #495057;\n }\n .btn {\n background-color: var(--accent-color);\n color: #ffffff;\n text-decoration: none;\n padding: 0.75rem 1.5rem;\n border-radius: 6px;\n transition: all 0.3s ease;\n display: inline-block;\n font-weight: 500;\n border: 2px solid var(--accent-color);\n }\n .btn:hover {\n background-color: #131721;\n }\n .error-code {\n font-size: 0.875rem;\n color: #6c757d;\n margin-top: 1.5rem;\n padding-top: 1.5rem;\n border-top: 1px solid var(--border-color);\n }\n .icon {\n font-size: 3rem;\n margin-bottom: 1rem;\n }\n </style>\n</head>\n<body>\n <div class=\"error-container\">\n <div class=\"icon\">⚠️</div>\n <h1>Better Auth Error</h1>\n <p>We encountered an issue while processing your request. Please try again or contact the application owner if the problem persists.</p>\n <a href=\"#\" id=\"returnLink\" class=\"btn\">Return to Application</a>\n <div class=\"error-code\">Error Code: <span id=\"errorCode\">${errorCode}</span></div>\n </div>\n</body>\n</html>`;\n\nexport const error = createAuthEndpoint(\n\t\"/error\",\n\t{\n\t\tmethod: \"GET\",\n\t},\n\tasync (c) => {\n\t\tconst query =\n\t\t\tnew URL(c.request?.url || \"\").searchParams.get(\"error\") || \"Unknown\";\n\t\treturn new Response(html(query), {\n\t\t\theaders: {\n\t\t\t\t\"Content-Type\": \"text/html\",\n\t\t\t},\n\t\t});\n\t},\n);\n","import Database from \"better-sqlite3\";\nimport { Kysely } from \"kysely\";\nimport {\n\ttype Dialect,\n\tMysqlDialect,\n\tPostgresDialect,\n\tSqliteDialect,\n} from \"kysely\";\nimport { createPool } from \"mysql2\";\nimport pg from \"pg\";\nimport type { FieldAttribute } from \"../db\";\nimport type { BetterAuthOptions } from \"../types\";\nimport type { Adapter, Where } from \"../types/adapter\";\n\nconst { Pool } = pg;\n\nfunction convertWhere(w?: Where[]) {\n\tif (!w)\n\t\treturn {\n\t\t\tand: null,\n\t\t\tor: null,\n\t\t};\n\tconst and = w\n\t\t?.filter((w) => w.connector === \"AND\" || !w.connector)\n\t\t.reduce(\n\t\t\t(acc, w) =>\n\t\t\t\t({\n\t\t\t\t\t...acc,\n\t\t\t\t\t[w.field]: w.value,\n\t\t\t\t}) as any,\n\t\t\t{},\n\t\t);\n\tconst or = w\n\t\t?.filter((w) => w.connector === \"OR\")\n\t\t.reduce(\n\t\t\t(acc, w) =>\n\t\t\t\t({\n\t\t\t\t\t...acc,\n\t\t\t\t\t[w.field]: w.value,\n\t\t\t\t}) as any,\n\t\t\t{},\n\t\t);\n\treturn {\n\t\tand: Object.keys(and).length ? and : null,\n\t\tor: Object.keys(or).length ? or : null,\n\t};\n}\n\nfunction transformTo(\n\tval: any,\n\tfields: Record<string, FieldAttribute>,\n\ttransform: KyselyAdapterConfig[\"transform\"],\n) {\n\tfor (const key in val) {\n\t\tif (\n\t\t\tval[key] === 0 &&\n\t\t\tfields[key]?.type === \"boolean\" &&\n\t\t\ttransform?.boolean\n\t\t) {\n\t\t\tval[key] = false;\n\t\t}\n\t\tif (\n\t\t\tval[key] === 1 &&\n\t\t\tfields[key]?.type === \"boolean\" &&\n\t\t\ttransform?.boolean\n\t\t) {\n\t\t\tval[key] = true;\n\t\t}\n\t\tif (fields[key]?.type === \"date\") {\n\t\t\tif (!(val[key] instanceof Date)) {\n\t\t\t\tval[key] = new Date(val[key]);\n\t\t\t}\n\t\t}\n\t}\n\treturn val;\n}\n\nfunction transformFrom(val: any, transform: KyselyAdapterConfig[\"transform\"]) {\n\tfor (const key in val) {\n\t\tif (typeof val[key] === \"boolean\" && transform?.boolean) {\n\t\t\tval[key] = val[key] ? 1 : 0;\n\t\t}\n\t\tif (val[key] instanceof Date) {\n\t\t\tval[key] = val[key].toISOString();\n\t\t}\n\t}\n\treturn val;\n}\n\nexport interface KyselyAdapterConfig {\n\t/**\n\t * Transform dates and booleans for sqlite.\n\t */\n\ttransform?: {\n\t\tschema: {\n\t\t\t[table: string]: Record<string, FieldAttribute>;\n\t\t};\n\t\tboolean: boolean;\n\t\tdate: boolean;\n\t};\n}\n\nexport const kyselyAdapter = (\n\tdb: Kysely<any>,\n\tconfig?: KyselyAdapterConfig,\n): Adapter => {\n\treturn {\n\t\tasync create(data) {\n\t\t\tlet { model, data: val, select } = data;\n\t\t\tif (config?.transform) {\n\t\t\t\tval = transformFrom(val, config.transform);\n\t\t\t}\n\t\t\tlet res = await db\n\t\t\t\t.insertInto(model)\n\t\t\t\t.values(val as any)\n\t\t\t\t.returningAll()\n\t\t\t\t.executeTakeFirst();\n\n\t\t\tif (config?.transform) {\n\t\t\t\tconst schema = config.transform.schema[model];\n\t\t\t\tres = schema ? transformTo(val, schema, config.transform) : res;\n\t\t\t}\n\n\t\t\tif (select?.length) {\n\t\t\t\tconst data = res\n\t\t\t\t\t? select.reduce((acc, cur) => {\n\t\t\t\t\t\t\tif (res?.[cur]) {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t\t\t\t[cur]: res[cur],\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t}, {} as any)\n\t\t\t\t\t: null;\n\t\t\t\tres = data;\n\t\t\t}\n\n\t\t\treturn res as any;\n\t\t},\n\t\tasync findOne(data) {\n\t\t\tconst { model, where, select } = data;\n\t\t\tconst { and, or } = convertWhere(where);\n\t\t\tlet query = db.selectFrom(model).selectAll();\n\t\t\tif (or) {\n\t\t\t\tquery = query.where((eb) => eb.or(or));\n\t\t\t}\n\t\t\tif (and) {\n\t\t\t\tquery = query.where((eb) => eb.and(and));\n\t\t\t}\n\t\t\tlet res = await query.executeTakeFirst();\n\t\t\tif (select?.length) {\n\t\t\t\tconst data = res\n\t\t\t\t\t? select.reduce((acc, cur) => {\n\t\t\t\t\t\t\tif (res?.[cur]) {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t\t\t\t[cur]: res[cur],\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t}, {} as any)\n\t\t\t\t\t: null;\n\t\t\t\tres = data;\n\t\t\t}\n\n\t\t\tif (config?.transform) {\n\t\t\t\tconst schema = config.transform.schema[model];\n\t\t\t\tres = res && schema ? transformTo(res, schema, config.transform) : res;\n\n\t\t\t\treturn res || null;\n\t\t\t}\n\t\t\treturn (res || null) as any;\n\t\t},\n\t\tasync findMany(data) {\n\t\t\tconst { model, where } = data;\n\t\t\tlet query = db.selectFrom(model);\n\t\t\tconst { and, or } = convertWhere(where);\n\t\t\tif (and) {\n\t\t\t\tquery = query.where((eb) => eb.and(and));\n\t\t\t}\n\t\t\tif (or) {\n\t\t\t\tquery = query.where((eb) => eb.or(or));\n\t\t\t}\n\t\t\tconst res = await query.selectAll().execute();\n\t\t\tif (config?.transform) {\n\t\t\t\tconst schema = config.transform.schema[model];\n\t\t\t\treturn schema\n\t\t\t\t\t? res.map((v) => transformTo(v, schema, config.transform))\n\t\t\t\t\t: res;\n\t\t\t}\n\t\t\treturn res as any;\n\t\t},\n\t\tasync update(data) {\n\t\t\tlet { model, where, update: val } = data;\n\t\t\tconst { and, or } = convertWhere(where);\n\n\t\t\tif (config?.transform) {\n\t\t\t\tval = transformFrom(val, config.transform);\n\t\t\t}\n\n\t\t\tlet query = db.updateTable(model).set(val);\n\t\t\tif (and) {\n\t\t\t\tquery = query.where((eb) => eb.and(and));\n\t\t\t}\n\t\t\tif (or) {\n\t\t\t\tquery = query.where((eb) => eb.or(or));\n\t\t\t}\n\t\t\tconst res = await query.returningAll().executeTakeFirst();\n\t\t\tif (config?.transform) {\n\t\t\t\tconst schema = config.transform.schema[model];\n\t\t\t\treturn schema ? transformTo(res, schema, config.transform) : res;\n\t\t\t}\n\t\t\treturn res as any;\n\t\t},\n\t\tasync delete(data) {\n\t\t\tconst { model, where } = data;\n\t\t\tconst { and, or } = convertWhere(where);\n\t\t\tlet query = db.deleteFrom(model);\n\n\t\t\tif (and) {\n\t\t\t\tquery = query.where((eb) => eb.and(and));\n\t\t\t}\n\t\t\tif (or) {\n\t\t\t\tquery = query.where((eb) => eb.or(or));\n\t\t\t}\n\n\t\t\tawait query.execute();\n\t\t},\n\t};\n};\n\nexport const getDialect = (config: BetterAuthOptions) => {\n\tif (!config.database) {\n\t\treturn null;\n\t}\n\tlet dialect: Dialect | null = null;\n\tif (\"provider\" in config.database) {\n\t\tconst provider = config.database.provider;\n\t\tconst connectionString = config.database.url.trim();\n\t\tif (provider === \"postgres\") {\n\t\t\tconst pool = new Pool({\n\t\t\t\tconnectionString,\n\t\t\t});\n\t\t\tdialect = new PostgresDialect({\n\t\t\t\tpool,\n\t\t\t});\n\t\t}\n\t\tif (provider === \"mysql\") {\n\t\t\tconst params = new URL(connectionString);\n\t\t\tconst pool = createPool({\n\t\t\t\thost: params.hostname,\n\t\t\t\tuser: params.username,\n\t\t\t\tpassword: params.password,\n\t\t\t\tdatabase: params.pathname.split(\"/\")[1],\n\t\t\t\tport: Number(params.port),\n\t\t\t});\n\t\t\tdialect = new MysqlDialect({ pool });\n\t\t}\n\n\t\tif (provider === \"sqlite\") {\n\t\t\tconst db = new Database(connectionString);\n\t\t\tdialect = new SqliteDialect({\n\t\t\t\tdatabase: db,\n\t\t\t});\n\t\t}\n\t}\n\treturn dialect;\n};\n\nexport const createKyselyAdapter = (config: BetterAuthOptions) => {\n\tconst dialect = getDialect(config);\n\tif (!dialect) {\n\t\treturn null;\n\t}\n\tconst db = new Kysely<any>({\n\t\tdialect,\n\t});\n\treturn db;\n};\n\nexport const getDatabaseType = (config: BetterAuthOptions) => {\n\tif (\"provider\" in config.database) {\n\t\treturn config.database.provider;\n\t}\n\tif (\"dialect\" in config.database) {\n\t\tif (config.database.dialect instanceof PostgresDialect) {\n\t\t\treturn \"postgres\";\n\t\t}\n\t\tif (config.database.dialect instanceof MysqlDialect) {\n\t\t\treturn \"mysql\";\n\t\t}\n\t\tif (config.database.dialect instanceof SqliteDialect) {\n\t\t\treturn \"sqlite\";\n\t\t}\n\t}\n\treturn \"sqlite\";\n};\n","import type { FieldAttribute } from \"../db\";\nimport type { BetterAuthOptions } from \"../types\";\n\nexport type BetterAuthDbSchema = Record<\n\tstring,\n\t{\n\t\ttableName: string;\n\t\tfields: Record<string, FieldAttribute>;\n\t\tdisableMigrations?: boolean;\n\t}\n>;\n\nexport const getAuthTables = (options: BetterAuthOptions) => {\n\tconst pluginSchema = options.plugins?.reduce((acc, plugin) => {\n\t\tconst schema = plugin.schema;\n\t\treturn {\n\t\t\t...acc,\n\t\t\t...schema,\n\t\t};\n\t}, {});\n\n\treturn {\n\t\t...pluginSchema,\n\t\tuser: {\n\t\t\ttableName: options.user?.modelName || \"user\",\n\t\t\tfields: {\n\t\t\t\tname: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t},\n\t\t\t\temail: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t},\n\t\t\t\temailVerified: {\n\t\t\t\t\ttype: \"boolean\",\n\t\t\t\t\tdefaultValue: () => false,\n\t\t\t\t},\n\t\t\t\timage: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t},\n\t\t\t\tcreatedAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\tdefaultValue: () => new Date(),\n\t\t\t\t},\n\t\t\t\tupdatedAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\tdefaultValue: () => new Date(),\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tsession: {\n\t\t\ttableName: options.session?.modelName || \"session\",\n\t\t\tfields: {\n\t\t\t\texpiresAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t},\n\t\t\t\tipAddress: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t},\n\t\t\t\tuserAgent: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t},\n\t\t\t\tuserId: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\treferences: {\n\t\t\t\t\t\tmodel: \"user\",\n\t\t\t\t\t\tfield: \"id\",\n\t\t\t\t\t\tonDelete: \"cascade\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\taccount: {\n\t\t\ttableName: options.account?.modelName || \"account\",\n\t\t\tfields: {\n\t\t\t\taccountId: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t},\n\t\t\t\tproviderId: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t},\n\t\t\t\tuserId: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\treferences: {\n\t\t\t\t\t\tmodel: \"user\",\n\t\t\t\t\t\tfield: \"id\",\n\t\t\t\t\t\tonDelete: \"cascade\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\taccessToken: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t},\n\t\t\t\trefreshToken: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t},\n\t\t\t\tidToken: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t},\n\t\t\t\taccessTokenExpiresAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: false,\n\t\t\t\t},\n\t\t\t\trefreshTokenExpiresAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: false,\n\t\t\t\t},\n\t\t\t\tpassword: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t} satisfies BetterAuthDbSchema;\n};\n","import { BetterAuthError } from \"../error/better-auth-error\";\nimport type { BetterAuthOptions } from \"../types\";\nimport type { Adapter } from \"../types/adapter\";\nimport { getAuthTables } from \"./get-tables\";\nimport { createKyselyAdapter, getDatabaseType, kyselyAdapter } from \"./kysely\";\n\nexport function getAdapter(options: BetterAuthOptions): Adapter {\n\tif (!options.database) {\n\t\tthrow new BetterAuthError(\"Database configuration is required\");\n\t}\n\tif (\"provider\" in options.database) {\n\t\tconst db = createKyselyAdapter(options);\n\t\tif (!db) {\n\t\t\tthrow new BetterAuthError(\"Failed to initialize database adapter\");\n\t\t}\n\t\tconst tables = getAuthTables(options);\n\t\treturn kyselyAdapter(db, {\n\t\t\ttransform: {\n\t\t\t\tschema: {\n\t\t\t\t\t[tables.user.tableName]: tables.user.fields,\n\t\t\t\t\t[tables.session.tableName]: tables.session.fields,\n\t\t\t\t\t[tables.account.tableName]: tables.account.fields,\n\t\t\t\t},\n\t\t\t\tdate: true,\n\t\t\t\tboolean: getDatabaseType(options) === \"sqlite\",\n\t\t\t},\n\t\t});\n\t}\n\treturn options.database;\n}\n","import { alphabet, generateRandomString } from \"oslo/crypto\";\nimport type { BetterAuthOptions } from \"../types\";\nimport type { Adapter } from \"../types/adapter\";\nimport { getDate } from \"../utils/date\";\nimport { getAuthTables } from \"./get-tables\";\nimport type { Account, Session, User } from \"./schema\";\n\nexport const createInternalAdapter = (\n\tadapter: Adapter,\n\toptions: BetterAuthOptions,\n) => {\n\tconst sessionExpiration = options.session?.expiresIn || 60 * 60 * 24 * 7; // 7 days\n\tconst tables = getAuthTables(options);\n\treturn {\n\t\tcreateOAuthUser: async (user: User, account: Account) => {\n\t\t\ttry {\n\t\t\t\tconst createdUser = await adapter.create({\n\t\t\t\t\tmodel: tables.user.tableName,\n\t\t\t\t\tdata: user,\n\t\t\t\t});\n\t\t\t\tconst createdAccount = await adapter.create({\n\t\t\t\t\tmodel: tables.account.tableName,\n\t\t\t\t\tdata: account,\n\t\t\t\t});\n\t\t\t\treturn {\n\t\t\t\t\tuser: createdUser,\n\t\t\t\t\taccount: createdAccount,\n\t\t\t\t};\n\t\t\t} catch (e) {\n\t\t\t\tconsole.log(e);\n\t\t\t\treturn null;\n\t\t\t}\n\t\t},\n\t\tcreateUser: async (user: User) => {\n\t\t\tconst createdUser = await adapter.create<User>({\n\t\t\t\tmodel: tables.user.tableName,\n\t\t\t\tdata: user,\n\t\t\t});\n\t\t\treturn createdUser;\n\t\t},\n\t\tcreateSession: async (userId: string, request?: Request) => {\n\t\t\tconst data: Session = {\n\t\t\t\tid: generateRandomString(32, alphabet(\"a-z\", \"0-9\", \"A-Z\")),\n\t\t\t\tuserId,\n\t\t\t\texpiresAt: getDate(sessionExpiration),\n\t\t\t\tipAddress: request?.headers.get(\"x-forwarded-for\") || \"\",\n\t\t\t\tuserAgent: request?.headers.get(\"user-agent\") || \"\",\n\t\t\t};\n\t\t\tconst session = adapter.create<Session>({\n\t\t\t\tmodel: tables.session.tableName,\n\t\t\t\tdata,\n\t\t\t});\n\t\t\treturn session;\n\t\t},\n\t\tfindSession: async (sessionId: string) => {\n\t\t\tconst session = await adapter.findOne<Session>({\n\t\t\t\tmodel: tables.session.tableName,\n\t\t\t\twhere: [\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: sessionId,\n\t\t\t\t\t\tfield: \"id\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t});\n\t\t\tif (!session) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst user = await adapter.findOne<User>({\n\t\t\t\tmodel: tables.user.tableName,\n\t\t\t\twhere: [\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: session.userId,\n\t\t\t\t\t\tfield: \"id\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t});\n\t\t\tif (!user) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tsession,\n\t\t\t\tuser,\n\t\t\t};\n\t\t},\n\t\tupdateSession: async (session: Session) => {\n\t\t\tconst updateAge =\n\t\t\t\toptions.session?.updateAge === undefined\n\t\t\t\t\t? 1000 // 1 hour update age\n\t\t\t\t\t: options.session?.updateAge;\n\t\t\tconst updateDate = updateAge === 0 ? 0 : getDate(updateAge).valueOf();\n\t\t\tconst maxAge = getDate(sessionExpiration);\n\t\t\tconst shouldBeUpdated =\n\t\t\t\tsession.expiresAt.valueOf() - maxAge.valueOf() + updateDate <=\n\t\t\t\tDate.now();\n\t\t\tif (shouldBeUpdated) {\n\t\t\t\tconst updatedSession = await adapter.create<Session>({\n\t\t\t\t\tmodel: tables.session.tableName,\n\t\t\t\t\tdata: {\n\t\t\t\t\t\t...session,\n\t\t\t\t\t\tid: generateRandomString(32, alphabet(\"a-z\", \"0-9\", \"A-Z\")),\n\t\t\t\t\t\texpiresAt: new Date(Date.now() + sessionExpiration),\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\tawait adapter.update<Session>({\n\t\t\t\t\tmodel: tables.session.tableName,\n\t\t\t\t\twhere: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfield: \"id\",\n\t\t\t\t\t\t\tvalue: session.id,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tupdate: {\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * update the session to expire in 2 minute. This is to prevent\n\t\t\t\t\t\t * the session from expiring too quickly and logging the user out.\n\t\t\t\t\t\t */\n\t\t\t\t\t\texpiresAt: new Date(Date.now() + 1000 * 60 * 2),\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\treturn updatedSession;\n\t\t\t}\n\n\t\t\treturn session;\n\t\t},\n\t\tdeleteSession: async (id: string) => {\n\t\t\tconst session = await adapter.delete<Session>({\n\t\t\t\tmodel: tables.session.tableName,\n\t\t\t\twhere: [\n\t\t\t\t\t{\n\t\t\t\t\t\tfield: \"id\",\n\t\t\t\t\t\tvalue: id,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn session;\n\t\t},\n\t\tfindUserByEmail: async (email: string) => {\n\t\t\tconst user = await adapter.findOne<User>({\n\t\t\t\tmodel: tables.user.tableName,\n\t\t\t\twhere: [\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: email.toLowerCase(),\n\t\t\t\t\t\tfield: \"email\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t});\n\t\t\tif (!user) return null;\n\t\t\tconst accounts = await adapter.findMany<Account>({\n\t\t\t\tmodel: tables.account.tableName,\n\t\t\t\twhere: [\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: user.id,\n\t\t\t\t\t\tfield: \"userId\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn {\n\t\t\t\tuser,\n\t\t\t\taccounts,\n\t\t\t};\n\t\t},\n\t\tfindUserById: async (userId: string) => {\n\t\t\tconst user = await adapter.findOne<User>({\n\t\t\t\tmodel: tables.user.tableName,\n\t\t\t\twhere: [\n\t\t\t\t\t{\n\t\t\t\t\t\tfield: \"id\",\n\t\t\t\t\t\tvalue: userId,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn user;\n\t\t},\n\t\tlinkAccount: async (account: Account) => {\n\t\t\tconst _account = await adapter.create<Account>({\n\t\t\t\tmodel: tables.account.tableName,\n\t\t\t\tdata: account,\n\t\t\t});\n\t\t\treturn _account;\n\t\t},\n\t\tupdateUserByEmail: async (\n\t\t\temail: string,\n\t\t\tdata: Partial<User & Record<string, any>>,\n\t\t) => {\n\t\t\tconst user = await adapter.update<User>({\n\t\t\t\tmodel: tables.user.tableName,\n\t\t\t\twhere: [\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: email,\n\t\t\t\t\t\tfield: \"email\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tupdate: data,\n\t\t\t});\n\t\t\treturn user;\n\t\t},\n\t\tupdatePassword: async (userId: string, password: string) => {\n\t\t\tconst account = await adapter.update<Account>({\n\t\t\t\tmodel: tables.account.tableName,\n\t\t\t\twhere: [\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: userId,\n\t\t\t\t\t\tfield: \"userId\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tfield: \"providerId\",\n\t\t\t\t\t\tvalue: \"credential\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tupdate: {\n\t\t\t\t\tpassword,\n\t\t\t\t},\n\t\t\t});\n\t\t\treturn account;\n\t\t},\n\t};\n};\n\nexport type InternalAdapter = ReturnType<typeof createInternalAdapter>;\n","export const getDate = (span: number) => {\n\tconst date = new Date();\n\treturn new Date(date.getTime() + span);\n};\n","import type { ZodSchema } from \"zod\";\n\nexport const createFieldAttribute = <\n\tT extends FieldType,\n\tC extends Omit<FieldAttributeConfig<T>, \"type\">,\n>(\n\ttype: T,\n\tconfig?: C,\n) => {\n\treturn {\n\t\ttype,\n\t\t...config,\n\t} satisfies FieldAttribute<T>;\n};\n\nexport type FieldAttribute<T extends FieldType = FieldType> = {\n\ttype: T;\n} & FieldAttributeConfig<T>;\n\nexport type FieldType = \"string\" | \"number\" | \"boolean\" | \"date\";\n\nexport type InferValueType<T extends FieldType> = T extends \"string\"\n\t? string\n\t: T extends \"number\"\n\t\t? number\n\t\t: T extends \"boolean\"\n\t\t\t? boolean\n\t\t\t: T extends \"date\"\n\t\t\t\t? Date\n\t\t\t\t: never;\n\nexport type InferFieldOutput<T extends FieldAttribute> =\n\tT[\"returned\"] extends false\n\t\t? never\n\t\t: T[\"required\"] extends false\n\t\t\t? InferValueType<T[\"type\"]> | undefined\n\t\t\t: InferValueType<T[\"type\"]>;\n\nexport type FieldAttributeConfig<T extends FieldType = FieldType> = {\n\t/**\n\t * if the field should be required on a new record.\n\t * @default false\n\t */\n\trequired?: boolean;\n\t/**\n\t * If the value should be returned on a response body.\n\t * @default true\n\t */\n\treturned?: boolean;\n\t/**\n\t * If the value should be hashed when it's stored.\n\t * @default false\n\t */\n\thashValue?: boolean;\n\t/**\n\t * Default value for the field\n\t *\n\t * Note: This will not create a default value on the database level. It will only\n\t * be used when creating a new record.\n\t */\n\tdefaultValue?: InferValueType<T> | (() => InferValueType<T>);\n\t/**\n\t * transform the value before storing it.\n\t */\n\ttransform?: (value: InferValueType<T>) => InferValueType<T>;\n\t/**\n\t * Reference to another model.\n\t */\n\treferences?: {\n\t\t/**\n\t\t * The model to reference.\n\t\t */\n\t\tmodel: string;\n\t\t/**\n\t\t * The field on the referenced model.\n\t\t */\n\t\tfield: string;\n\t\t/**\n\t\t * The action to perform when the reference is deleted.\n\t\t * @default \"cascade\"\n\t\t */\n\t\tonDelete?:\n\t\t\t| \"no action\"\n\t\t\t| \"restrict\"\n\t\t\t| \"cascade\"\n\t\t\t| \"set null\"\n\t\t\t| \"set default\";\n\t};\n\tunique?: boolean;\n\t/**\n\t * A zod schema to validate the value.\n\t */\n\tvalidator?: ZodSchema;\n};\n","import type { CookieOptions } from \"better-call\";\nimport { TimeSpan } from \"oslo\";\nimport type { BetterAuthOptions } from \"../types/options\";\n\nexport function getCookies(options: BetterAuthOptions) {\n\tconst secure =\n\t\t!!options.advanced?.useSecureCookies ||\n\t\tprocess.env.NODE_ENV === \"production\";\n\tconst secureCookiePrefix = secure ? \"__Secure-\" : \"\";\n\tconst cookiePrefix = \"better-auth\";\n\tconst sessionMaxAge = new TimeSpan(7, \"d\").seconds();\n\treturn {\n\t\tsessionToken: {\n\t\t\tname: `${secureCookiePrefix}${cookiePrefix}.session_token`,\n\t\t\toptions: {\n\t\t\t\thttpOnly: true,\n\t\t\t\tsameSite: \"lax\",\n\t\t\t\tpath: \"/\",\n\t\t\t\tsecure,\n\t\t\t\tmaxAge: sessionMaxAge,\n\t\t\t} satisfies CookieOptions,\n\t\t},\n\t\tcsrfToken: {\n\t\t\tname: `${secureCookiePrefix ? \"__Host-\" : \"\"}${cookiePrefix}.csrf_token`,\n\t\t\toptions: {\n\t\t\t\thttpOnly: true,\n\t\t\t\tsameSite: \"lax\",\n\t\t\t\tpath: \"/\",\n\t\t\t\tsecure,\n\t\t\t\tmaxAge: 60 * 60 * 24 * 7,\n\t\t\t} satisfies CookieOptions,\n\t\t},\n\t\tstate: {\n\t\t\tname: `${secureCookiePrefix}${cookiePrefix}.state`,\n\t\t\toptions: {\n\t\t\t\thttpOnly: true,\n\t\t\t\tsameSite: \"lax\",\n\t\t\t\tpath: \"/\",\n\t\t\t\tsecure,\n\t\t\t\tmaxAge: 60 * 15, // 15 minutes in seconds\n\t\t\t} satisfies CookieOptions,\n\t\t},\n\t\tpkCodeVerifier: {\n\t\t\tname: `${secureCookiePrefix}${cookiePrefix}.pk_code_verifier`,\n\t\t\toptions: {\n\t\t\t\thttpOnly: true,\n\t\t\t\tsameSite: \"lax\",\n\t\t\t\tpath: \"/\",\n\t\t\t\tsecure,\n\t\t\t\tmaxAge: 60 * 15, // 15 minutes in seconds\n\t\t\t} as CookieOptions,\n\t\t},\n\t\tnonce: {\n\t\t\tname: `${secureCookiePrefix}${cookiePrefix}.nonce`,\n\t\t\toptions: {\n\t\t\t\thttpOnly: true,\n\t\t\t\tsameSite: \"lax\",\n\t\t\t\tpath: \"/\",\n\t\t\t\tsecure,\n\t\t\t\tmaxAge: 60 * 15, // 15 minutes in seconds\n\t\t\t} as CookieOptions,\n\t\t},\n\t};\n}\n\nexport function createCookieGetter(options: BetterAuthOptions) {\n\tconst secure =\n\t\t!!options.advanced?.useSecureCookies ||\n\t\tprocess.env.NODE_ENV === \"production\";\n\tconst secureCookiePrefix = secure ? \"__Secure-\" : \"\";\n\tconst cookiePrefix = \"better-auth\";\n\tfunction getCookie(cookieName: string, options?: CookieOptions) {\n\t\treturn {\n\t\t\tname:\n\t\t\t\tprocess.env.NODE_ENV === \"production\"\n\t\t\t\t\t? `${secureCookiePrefix}${cookiePrefix}.${cookieName}`\n\t\t\t\t\t: `${cookiePrefix}.${cookieName}`,\n\t\t\toptions: {\n\t\t\t\tsecure,\n\t\t\t\tsameSite: \"lax\",\n\t\t\t\tpath: \"/\",\n\t\t\t\tmaxAge: 60 * 15, // 15 minutes in seconds\n\t\t\t\t...options,\n\t\t\t} as CookieOptions,\n\t\t};\n\t}\n\treturn getCookie;\n}\nexport type BetterAuthCookies = ReturnType<typeof getCookies>;\n","import { createConsola } from \"consola\";\n\nconst consola = createConsola({\n\tformatOptions: {\n\t\tdate: false,\n\t},\n});\n\nexport const createLogger = (options?: {\n\tdisabled?: boolean;\n}) => {\n\treturn {\n\t\tlog: (...args: any[]) => {\n\t\t\t!options?.disabled && consola.log(\"\", ...args);\n\t\t},\n\t\terror: (...args: any[]) => {\n\t\t\t!options?.disabled && consola.error(\"\", ...args);\n\t\t},\n\t\twarn: (...args: any[]) => {\n\t\t\t!options?.disabled && consola.warn(\"\", ...args);\n\t\t},\n\t\tinfo: (...args: any[]) => {\n\t\t\t!options?.disabled && consola.info(\"\", ...args);\n\t\t},\n\t\tdebug: (...args: any[]) => {\n\t\t\t!options?.disabled && consola.debug(\"\", ...args);\n\t\t},\n\t\tbox: (...args: any[]) => {\n\t\t\t!options?.disabled && consola.box(\"\", ...args);\n\t\t},\n\t\tsuccess: (...args: any[]) => {\n\t\t\t!options?.disabled && consola.success(\"\", ...args);\n\t\t},\n\t\tbreak: (...args: any[]) => {\n\t\t\t!options?.disabled && console.log(\"\\n\");\n\t\t},\n\t};\n};\n\nexport const logger = createLogger();\n","import { createKyselyAdapter } from \"./adapters/kysely\";\nimport { getAdapter } from \"./adapters/utils\";\nimport { createInternalAdapter } from \"./db\";\nimport type { BetterAuthOptions } from \"./types\";\nimport { getBaseURL } from \"./utils/base-url\";\nimport {\n\ttype BetterAuthCookies,\n\tcreateCookieGetter,\n\tgetCookies,\n} from \"./utils/cookies\";\nimport { createLogger } from \"./utils/logger\";\n\nexport const init = (options: BetterAuthOptions) => {\n\tconst adapter = getAdapter(options);\n\tconst db = createKyselyAdapter(options);\n\tconst { baseURL, withPath } = getBaseURL(options.baseURL, options.basePath);\n\n\treturn {\n\t\toptions: {\n\t\t\t...options,\n\t\t\tbaseURL: baseURL,\n\t\t\tbasePath: options.basePath || \"/api/auth\",\n\t\t},\n\t\tbaseURL: withPath,\n\t\tsecret:\n\t\t\toptions.secret ||\n\t\t\tprocess.env.BETTER_AUTH_SECRET ||\n\t\t\tprocess.env.AUTH_SECRET ||\n\t\t\t\"better-auth-secret-123456789\",\n\t\tauthCookies: getCookies(options),\n\t\tlogger: createLogger({\n\t\t\tdisabled: options.disableLog,\n\t\t}),\n\t\tdb,\n\t\tadapter: adapter,\n\t\tinternalAdapter: createInternalAdapter(adapter, options),\n\t\tcreateAuthCookie: createCookieGetter(options),\n\t};\n};\n\nexport type AuthContext = {\n\toptions: BetterAuthOptions;\n\tbaseURL: string;\n\tauthCookies: BetterAuthCookies;\n\tlogger: ReturnType<typeof createLogger>;\n\tdb: ReturnType<typeof createKyselyAdapter>;\n\tadapter: ReturnType<typeof getAdapter>;\n\tinternalAdapter: ReturnType<typeof createInternalAdapter>;\n\tcreateAuthCookie: ReturnType<typeof createCookieGetter>;\n\tsecret: string;\n};\n","import type { UnionToIntersection } from \"./types/helper\";\nimport { router } from \"./api\";\nimport { init } from \"./init\";\nimport type { BetterAuthOptions } from \"./types/options\";\nimport type { BetterAuthPlugin } from \"./types/plugins\";\n\nexport const betterAuth = <O extends BetterAuthOptions>(options: O) => {\n\tconst authContext = init(options);\n\ttype PluginEndpoint = UnionToIntersection<\n\t\tO[\"plugins\"] extends Array<infer T>\n\t\t\t? T extends BetterAuthPlugin\n\t\t\t\t? {\n\t\t\t\t\t\t[key in T[\"id\"]]: T[\"endpoints\"];\n\t\t\t\t\t}\n\t\t\t\t: {}\n\t\t\t: {}\n\t>;\n\tconst { handler, endpoints } = router(authContext);\n\ttype Endpoint = typeof endpoints;\n\n\treturn {\n\t\thandler,\n\t\tapi: endpoints as Endpoint & PluginEndpoint,\n\t\toptions,\n\t};\n};\n\nexport type Auth = {\n\thandler: (request: Request) => Promise<Response>;\n\tapi: ReturnType<typeof router>[\"endpoints\"];\n\toptions: BetterAuthOptions;\n};\n"],"mappings":";AAAA,SAAsC,oBAAoB;;;ACA1D,SAAS,SAAS;AAIX,IAAM,gBAAgB,EAAE,OAAO;AAAA,EACrC,IAAI,EAAE,OAAO;AAAA,EACb,YAAY,EAAE,OAAO;AAAA,EACrB,WAAW,EAAE,OAAO;AAAA,EACpB,QAAQ,EAAE,OAAO;AAAA,EACjB,aAAa,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AAAA,EAC5C,cA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AgB;AACxB,OAAC,SAAS,YAAY,QAAQ,IAAI,IAAI,GAAG,IAAI;AAAA,IAC9C;AAAA,IACA,SAAS,IAAI,SAAgB;AAC5B,OAAC,SAAS,YAAY,QAAQ,QAAQ,IAAI,GAAG,IAAI;AAAA,IAClD;AAAA,IACA,OAAO,IAAI,SAAgB;AAC1B,OAAC,SAAS,YAAY,QAAQ,IAAI,IAAI;AAAA,IACvC;AAAA,EACD;AACD;AAEO,IAAM,SAAS,aAAa;;;AC3B5B,IAAM,OAAO,CAAC,YAA+B;AACnD,QAAM,UAAU,WAAW,OAAO;AAClC,QAAM,KAAK,oBAAoB,OAAO;AACtC,QAAM,EAAE,SAAS,UAAAC,UAAS,IAAI,WAAW,QAAQ,SAAS,QAAQ,QAAQ;AAE1E,SAAO;AAAA,IACN,SAAS;AAAA,MACR,GAAG;AAAA,MACH;AAAA,MACA,UAAU,QAAQ,YAAY;AAAA,IAC/B;AAAA,IACA,SAASA;AAAA,IACT,QACC,QAAQ,UACR,QAAQ,IAAI,sBACZ,QAAQ,IAAI,eACZ;AAAA,IACD,aAAa,WAAW,OAAO;AAAA,IAC/B,QAAQ,aAAa;AAAA,MACpB,UAAU,QAAQ;AAAA,IACnB,CAAC;AAAA,IACD;AAAA,IACA;AAAA,IACA,iBAAiB,sBAAsB,SAAS,OAAO;AAAA,IACvD,kBAAkB,mBAAmB,OAAO;AAAA,EAC7C;AACD;;;AChCO,IAAM,aAAa,CAA8B,YAAe;AACtE,QAAM,cAAc,KAAK,OAAO;AAUhC,QAAM,EAAE,SAAS,UAAU,IAAI,OAAO,WAAW;AAGjD,SAAO;AAAA,IACN;AAAA,IACA,KAAK;AAAA,IACL;AAAA,EACD;AACD;","names":["z","z","APIError","z","error","betterFetch","error","betterFetch","betterFetch","error","betterFetch","betterFetch","error","betterFetch","parseJWT","parseJWT","betterFetch","error","betterFetch","betterFetch","error","betterFetch","betterFetch","error","betterFetch","z","APIError","APIError","z","z","APIError","z","z","Argon2id","z","z","Argon2id","TimeSpan","createJWT","validateJWT","z","z","createJWT","TimeSpan","validateJWT","alphabet","generateRandomString","generateRandomString","alphabet","alphabet","generateRandomString","Argon2id","z","z","Argon2id","generateRandomString","alphabet","ctx","w","data","alphabet","generateRandomString","generateRandomString","alphabet","TimeSpan","options","withPath"]}
|
|
1
|
+
{"version":3,"sources":["../../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/util.js","../../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/sqlite-error.js","../../../node_modules/.pnpm/file-uri-to-path@1.0.0/node_modules/file-uri-to-path/index.js","../../../node_modules/.pnpm/bindings@1.5.0/node_modules/bindings/bindings.js","../../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/methods/wrappers.js","../../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/methods/transaction.js","../../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/methods/pragma.js","../../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/methods/backup.js","../../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/methods/serialize.js","../../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/methods/function.js","../../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/methods/aggregate.js","../../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/methods/table.js","../../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/methods/inspect.js","../../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/database.js","../../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/index.js","../src/api/index.ts","../src/adapters/schema.ts","../src/api/middlewares/csrf.ts","../src/crypto/index.ts","../src/api/call.ts","../src/api/routes/sign-in.ts","../src/social-providers/apple.ts","../src/error/better-auth-error.ts","../src/utils/base-url.ts","../src/social-providers/utils.ts","../src/social-providers/discord.ts","../src/social-providers/facebook.ts","../src/social-providers/github.ts","../src/social-providers/google.ts","../src/social-providers/spotify.ts","../src/social-providers/twitch.ts","../src/social-providers/twitter.ts","../src/types/provider.ts","../src/social-providers/index.ts","../src/utils/state.ts","../src/api/routes/session.ts","../src/api/routes/callback.ts","../src/client/client-utils.ts","../src/utils/id.ts","../src/api/routes/sign-out.ts","../src/api/routes/forget-password.ts","../src/api/routes/verify-email.ts","../src/api/routes/csrf.ts","../src/api/routes/ok.ts","../src/api/routes/sign-up.ts","../src/api/routes/error.ts","../src/adapters/kysely.ts","../src/adapters/get-tables.ts","../src/adapters/utils.ts","../src/adapters/internal-adapter.ts","../src/utils/date.ts","../src/db/field.ts","../src/utils/cookies.ts","../src/utils/logger.ts","../src/init.ts","../src/auth.ts"],"sourcesContent":["'use strict';\n\nexports.getBooleanOption = (options, key) => {\n\tlet value = false;\n\tif (key in options && typeof (value = options[key]) !== 'boolean') {\n\t\tthrow new TypeError(`Expected the \"${key}\" option to be a boolean`);\n\t}\n\treturn value;\n};\n\nexports.cppdb = Symbol();\nexports.inspect = Symbol.for('nodejs.util.inspect.custom');\n","'use strict';\nconst descriptor = { value: 'SqliteError', writable: true, enumerable: false, configurable: true };\n\nfunction SqliteError(message, code) {\n\tif (new.target !== SqliteError) {\n\t\treturn new SqliteError(message, code);\n\t}\n\tif (typeof code !== 'string') {\n\t\tthrow new TypeError('Expected second argument to be a string');\n\t}\n\tError.call(this, message);\n\tdescriptor.value = '' + message;\n\tObject.defineProperty(this, 'message', descriptor);\n\tError.captureStackTrace(this, SqliteError);\n\tthis.code = code;\n}\nObject.setPrototypeOf(SqliteError, Error);\nObject.setPrototypeOf(SqliteError.prototype, Error.prototype);\nObject.defineProperty(SqliteError.prototype, 'name', descriptor);\nmodule.exports = SqliteError;\n","\n/**\n * Module dependencies.\n */\n\nvar sep = require('path').sep || '/';\n\n/**\n * Module exports.\n */\n\nmodule.exports = fileUriToPath;\n\n/**\n * File URI to Path function.\n *\n * @param {String} uri\n * @return {String} path\n * @api public\n */\n\nfunction fileUriToPath (uri) {\n if ('string' != typeof uri ||\n uri.length <= 7 ||\n 'file://' != uri.substring(0, 7)) {\n throw new TypeError('must pass in a file:// URI to convert to a file path');\n }\n\n var rest = decodeURI(uri.substring(7));\n var firstSlash = rest.indexOf('/');\n var host = rest.substring(0, firstSlash);\n var path = rest.substring(firstSlash + 1);\n\n // 2. Scheme Definition\n // As a special case, <host> can be the string \"localhost\" or the empty\n // string; this is interpreted as \"the machine from which the URL is\n // being interpreted\".\n if ('localhost' == host) host = '';\n\n if (host) {\n host = sep + sep + host;\n }\n\n // 3.2 Drives, drive letters, mount points, file system root\n // Drive letters are mapped into the top of a file URI in various ways,\n // depending on the implementation; some applications substitute\n // vertical bar (\"|\") for the colon after the drive letter, yielding\n // \"file:///c|/tmp/test.txt\". In some cases, the colon is left\n // unchanged, as in \"file:///c:/tmp/test.txt\". In other cases, the\n // colon is simply omitted, as in \"file:///c/tmp/test.txt\".\n path = path.replace(/^(.+)\\|/, '$1:');\n\n // for Windows, we need to invert the path separators from what a URI uses\n if (sep == '\\\\') {\n path = path.replace(/\\//g, '\\\\');\n }\n\n if (/^.+\\:/.test(path)) {\n // has Windows drive at beginning of path\n } else {\n // unix path…\n path = sep + path;\n }\n\n return host + path;\n}\n","/**\n * Module dependencies.\n */\n\nvar fs = require('fs'),\n path = require('path'),\n fileURLToPath = require('file-uri-to-path'),\n join = path.join,\n dirname = path.dirname,\n exists =\n (fs.accessSync &&\n function(path) {\n try {\n fs.accessSync(path);\n } catch (e) {\n return false;\n }\n return true;\n }) ||\n fs.existsSync ||\n path.existsSync,\n defaults = {\n arrow: process.env.NODE_BINDINGS_ARROW || ' → ',\n compiled: process.env.NODE_BINDINGS_COMPILED_DIR || 'compiled',\n platform: process.platform,\n arch: process.arch,\n nodePreGyp:\n 'node-v' +\n process.versions.modules +\n '-' +\n process.platform +\n '-' +\n process.arch,\n version: process.versions.node,\n bindings: 'bindings.node',\n try: [\n // node-gyp's linked version in the \"build\" dir\n ['module_root', 'build', 'bindings'],\n // node-waf and gyp_addon (a.k.a node-gyp)\n ['module_root', 'build', 'Debug', 'bindings'],\n ['module_root', 'build', 'Release', 'bindings'],\n // Debug files, for development (legacy behavior, remove for node v0.9)\n ['module_root', 'out', 'Debug', 'bindings'],\n ['module_root', 'Debug', 'bindings'],\n // Release files, but manually compiled (legacy behavior, remove for node v0.9)\n ['module_root', 'out', 'Release', 'bindings'],\n ['module_root', 'Release', 'bindings'],\n // Legacy from node-waf, node <= 0.4.x\n ['module_root', 'build', 'default', 'bindings'],\n // Production \"Release\" buildtype binary (meh...)\n ['module_root', 'compiled', 'version', 'platform', 'arch', 'bindings'],\n // node-qbs builds\n ['module_root', 'addon-build', 'release', 'install-root', 'bindings'],\n ['module_root', 'addon-build', 'debug', 'install-root', 'bindings'],\n ['module_root', 'addon-build', 'default', 'install-root', 'bindings'],\n // node-pre-gyp path ./lib/binding/{node_abi}-{platform}-{arch}\n ['module_root', 'lib', 'binding', 'nodePreGyp', 'bindings']\n ]\n };\n\n/**\n * The main `bindings()` function loads the compiled bindings for a given module.\n * It uses V8's Error API to determine the parent filename that this function is\n * being invoked from, which is then used to find the root directory.\n */\n\nfunction bindings(opts) {\n // Argument surgery\n if (typeof opts == 'string') {\n opts = { bindings: opts };\n } else if (!opts) {\n opts = {};\n }\n\n // maps `defaults` onto `opts` object\n Object.keys(defaults).map(function(i) {\n if (!(i in opts)) opts[i] = defaults[i];\n });\n\n // Get the module root\n if (!opts.module_root) {\n opts.module_root = exports.getRoot(exports.getFileName());\n }\n\n // Ensure the given bindings name ends with .node\n if (path.extname(opts.bindings) != '.node') {\n opts.bindings += '.node';\n }\n\n // https://github.com/webpack/webpack/issues/4175#issuecomment-342931035\n var requireFunc =\n typeof __webpack_require__ === 'function'\n ? __non_webpack_require__\n : require;\n\n var tries = [],\n i = 0,\n l = opts.try.length,\n n,\n b,\n err;\n\n for (; i < l; i++) {\n n = join.apply(\n null,\n opts.try[i].map(function(p) {\n return opts[p] || p;\n })\n );\n tries.push(n);\n try {\n b = opts.path ? requireFunc.resolve(n) : requireFunc(n);\n if (!opts.path) {\n b.path = n;\n }\n return b;\n } catch (e) {\n if (e.code !== 'MODULE_NOT_FOUND' &&\n e.code !== 'QUALIFIED_PATH_RESOLUTION_FAILED' &&\n !/not find/i.test(e.message)) {\n throw e;\n }\n }\n }\n\n err = new Error(\n 'Could not locate the bindings file. Tried:\\n' +\n tries\n .map(function(a) {\n return opts.arrow + a;\n })\n .join('\\n')\n );\n err.tries = tries;\n throw err;\n}\nmodule.exports = exports = bindings;\n\n/**\n * Gets the filename of the JavaScript file that invokes this function.\n * Used to help find the root directory of a module.\n * Optionally accepts an filename argument to skip when searching for the invoking filename\n */\n\nexports.getFileName = function getFileName(calling_file) {\n var origPST = Error.prepareStackTrace,\n origSTL = Error.stackTraceLimit,\n dummy = {},\n fileName;\n\n Error.stackTraceLimit = 10;\n\n Error.prepareStackTrace = function(e, st) {\n for (var i = 0, l = st.length; i < l; i++) {\n fileName = st[i].getFileName();\n if (fileName !== __filename) {\n if (calling_file) {\n if (fileName !== calling_file) {\n return;\n }\n } else {\n return;\n }\n }\n }\n };\n\n // run the 'prepareStackTrace' function above\n Error.captureStackTrace(dummy);\n dummy.stack;\n\n // cleanup\n Error.prepareStackTrace = origPST;\n Error.stackTraceLimit = origSTL;\n\n // handle filename that starts with \"file://\"\n var fileSchema = 'file://';\n if (fileName.indexOf(fileSchema) === 0) {\n fileName = fileURLToPath(fileName);\n }\n\n return fileName;\n};\n\n/**\n * Gets the root directory of a module, given an arbitrary filename\n * somewhere in the module tree. The \"root directory\" is the directory\n * containing the `package.json` file.\n *\n * In: /home/nate/node-native-module/lib/index.js\n * Out: /home/nate/node-native-module\n */\n\nexports.getRoot = function getRoot(file) {\n var dir = dirname(file),\n prev;\n while (true) {\n if (dir === '.') {\n // Avoids an infinite loop in rare cases, like the REPL\n dir = process.cwd();\n }\n if (\n exists(join(dir, 'package.json')) ||\n exists(join(dir, 'node_modules'))\n ) {\n // Found the 'package.json' file or 'node_modules' dir; we're done\n return dir;\n }\n if (prev === dir) {\n // Got to the top\n throw new Error(\n 'Could not find module root given file: \"' +\n file +\n '\". Do you have a `package.json` file? '\n );\n }\n // Try the parent dir next\n prev = dir;\n dir = join(dir, '..');\n }\n};\n","'use strict';\nconst { cppdb } = require('../util');\n\nexports.prepare = function prepare(sql) {\n\treturn this[cppdb].prepare(sql, this, false);\n};\n\nexports.exec = function exec(sql) {\n\tthis[cppdb].exec(sql);\n\treturn this;\n};\n\nexports.close = function close() {\n\tthis[cppdb].close();\n\treturn this;\n};\n\nexports.loadExtension = function loadExtension(...args) {\n\tthis[cppdb].loadExtension(...args);\n\treturn this;\n};\n\nexports.defaultSafeIntegers = function defaultSafeIntegers(...args) {\n\tthis[cppdb].defaultSafeIntegers(...args);\n\treturn this;\n};\n\nexports.unsafeMode = function unsafeMode(...args) {\n\tthis[cppdb].unsafeMode(...args);\n\treturn this;\n};\n\nexports.getters = {\n\tname: {\n\t\tget: function name() { return this[cppdb].name; },\n\t\tenumerable: true,\n\t},\n\topen: {\n\t\tget: function open() { return this[cppdb].open; },\n\t\tenumerable: true,\n\t},\n\tinTransaction: {\n\t\tget: function inTransaction() { return this[cppdb].inTransaction; },\n\t\tenumerable: true,\n\t},\n\treadonly: {\n\t\tget: function readonly() { return this[cppdb].readonly; },\n\t\tenumerable: true,\n\t},\n\tmemory: {\n\t\tget: function memory() { return this[cppdb].memory; },\n\t\tenumerable: true,\n\t},\n};\n","'use strict';\nconst { cppdb } = require('../util');\nconst controllers = new WeakMap();\n\nmodule.exports = function transaction(fn) {\n\tif (typeof fn !== 'function') throw new TypeError('Expected first argument to be a function');\n\n\tconst db = this[cppdb];\n\tconst controller = getController(db, this);\n\tconst { apply } = Function.prototype;\n\n\t// Each version of the transaction function has these same properties\n\tconst properties = {\n\t\tdefault: { value: wrapTransaction(apply, fn, db, controller.default) },\n\t\tdeferred: { value: wrapTransaction(apply, fn, db, controller.deferred) },\n\t\timmediate: { value: wrapTransaction(apply, fn, db, controller.immediate) },\n\t\texclusive: { value: wrapTransaction(apply, fn, db, controller.exclusive) },\n\t\tdatabase: { value: this, enumerable: true },\n\t};\n\n\tObject.defineProperties(properties.default.value, properties);\n\tObject.defineProperties(properties.deferred.value, properties);\n\tObject.defineProperties(properties.immediate.value, properties);\n\tObject.defineProperties(properties.exclusive.value, properties);\n\n\t// Return the default version of the transaction function\n\treturn properties.default.value;\n};\n\n// Return the database's cached transaction controller, or create a new one\nconst getController = (db, self) => {\n\tlet controller = controllers.get(db);\n\tif (!controller) {\n\t\tconst shared = {\n\t\t\tcommit: db.prepare('COMMIT', self, false),\n\t\t\trollback: db.prepare('ROLLBACK', self, false),\n\t\t\tsavepoint: db.prepare('SAVEPOINT `\\t_bs3.\\t`', self, false),\n\t\t\trelease: db.prepare('RELEASE `\\t_bs3.\\t`', self, false),\n\t\t\trollbackTo: db.prepare('ROLLBACK TO `\\t_bs3.\\t`', self, false),\n\t\t};\n\t\tcontrollers.set(db, controller = {\n\t\t\tdefault: Object.assign({ begin: db.prepare('BEGIN', self, false) }, shared),\n\t\t\tdeferred: Object.assign({ begin: db.prepare('BEGIN DEFERRED', self, false) }, shared),\n\t\t\timmediate: Object.assign({ begin: db.prepare('BEGIN IMMEDIATE', self, false) }, shared),\n\t\t\texclusive: Object.assign({ begin: db.prepare('BEGIN EXCLUSIVE', self, false) }, shared),\n\t\t});\n\t}\n\treturn controller;\n};\n\n// Return a new transaction function by wrapping the given function\nconst wrapTransaction = (apply, fn, db, { begin, commit, rollback, savepoint, release, rollbackTo }) => function sqliteTransaction() {\n\tlet before, after, undo;\n\tif (db.inTransaction) {\n\t\tbefore = savepoint;\n\t\tafter = release;\n\t\tundo = rollbackTo;\n\t} else {\n\t\tbefore = begin;\n\t\tafter = commit;\n\t\tundo = rollback;\n\t}\n\tbefore.run();\n\ttry {\n\t\tconst result = apply.call(fn, this, arguments);\n\t\tafter.run();\n\t\treturn result;\n\t} catch (ex) {\n\t\tif (db.inTransaction) {\n\t\t\tundo.run();\n\t\t\tif (undo !== rollback) after.run();\n\t\t}\n\t\tthrow ex;\n\t}\n};\n","'use strict';\nconst { getBooleanOption, cppdb } = require('../util');\n\nmodule.exports = function pragma(source, options) {\n\tif (options == null) options = {};\n\tif (typeof source !== 'string') throw new TypeError('Expected first argument to be a string');\n\tif (typeof options !== 'object') throw new TypeError('Expected second argument to be an options object');\n\tconst simple = getBooleanOption(options, 'simple');\n\n\tconst stmt = this[cppdb].prepare(`PRAGMA ${source}`, this, true);\n\treturn simple ? stmt.pluck().get() : stmt.all();\n};\n","'use strict';\nconst fs = require('fs');\nconst path = require('path');\nconst { promisify } = require('util');\nconst { cppdb } = require('../util');\nconst fsAccess = promisify(fs.access);\n\nmodule.exports = async function backup(filename, options) {\n\tif (options == null) options = {};\n\n\t// Validate arguments\n\tif (typeof filename !== 'string') throw new TypeError('Expected first argument to be a string');\n\tif (typeof options !== 'object') throw new TypeError('Expected second argument to be an options object');\n\n\t// Interpret options\n\tfilename = filename.trim();\n\tconst attachedName = 'attached' in options ? options.attached : 'main';\n\tconst handler = 'progress' in options ? options.progress : null;\n\n\t// Validate interpreted options\n\tif (!filename) throw new TypeError('Backup filename cannot be an empty string');\n\tif (filename === ':memory:') throw new TypeError('Invalid backup filename \":memory:\"');\n\tif (typeof attachedName !== 'string') throw new TypeError('Expected the \"attached\" option to be a string');\n\tif (!attachedName) throw new TypeError('The \"attached\" option cannot be an empty string');\n\tif (handler != null && typeof handler !== 'function') throw new TypeError('Expected the \"progress\" option to be a function');\n\n\t// Make sure the specified directory exists\n\tawait fsAccess(path.dirname(filename)).catch(() => {\n\t\tthrow new TypeError('Cannot save backup because the directory does not exist');\n\t});\n\n\tconst isNewFile = await fsAccess(filename).then(() => false, () => true);\n\treturn runBackup(this[cppdb].backup(this, attachedName, filename, isNewFile), handler || null);\n};\n\nconst runBackup = (backup, handler) => {\n\tlet rate = 0;\n\tlet useDefault = true;\n\n\treturn new Promise((resolve, reject) => {\n\t\tsetImmediate(function step() {\n\t\t\ttry {\n\t\t\t\tconst progress = backup.transfer(rate);\n\t\t\t\tif (!progress.remainingPages) {\n\t\t\t\t\tbackup.close();\n\t\t\t\t\tresolve(progress);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (useDefault) {\n\t\t\t\t\tuseDefault = false;\n\t\t\t\t\trate = 100;\n\t\t\t\t}\n\t\t\t\tif (handler) {\n\t\t\t\t\tconst ret = handler(progress);\n\t\t\t\t\tif (ret !== undefined) {\n\t\t\t\t\t\tif (typeof ret === 'number' && ret === ret) rate = Math.max(0, Math.min(0x7fffffff, Math.round(ret)));\n\t\t\t\t\t\telse throw new TypeError('Expected progress callback to return a number or undefined');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tsetImmediate(step);\n\t\t\t} catch (err) {\n\t\t\t\tbackup.close();\n\t\t\t\treject(err);\n\t\t\t}\n\t\t});\n\t});\n};\n","'use strict';\nconst { cppdb } = require('../util');\n\nmodule.exports = function serialize(options) {\n\tif (options == null) options = {};\n\n\t// Validate arguments\n\tif (typeof options !== 'object') throw new TypeError('Expected first argument to be an options object');\n\n\t// Interpret and validate options\n\tconst attachedName = 'attached' in options ? options.attached : 'main';\n\tif (typeof attachedName !== 'string') throw new TypeError('Expected the \"attached\" option to be a string');\n\tif (!attachedName) throw new TypeError('The \"attached\" option cannot be an empty string');\n\n\treturn this[cppdb].serialize(attachedName);\n};\n","'use strict';\nconst { getBooleanOption, cppdb } = require('../util');\n\nmodule.exports = function defineFunction(name, options, fn) {\n\t// Apply defaults\n\tif (options == null) options = {};\n\tif (typeof options === 'function') { fn = options; options = {}; }\n\n\t// Validate arguments\n\tif (typeof name !== 'string') throw new TypeError('Expected first argument to be a string');\n\tif (typeof fn !== 'function') throw new TypeError('Expected last argument to be a function');\n\tif (typeof options !== 'object') throw new TypeError('Expected second argument to be an options object');\n\tif (!name) throw new TypeError('User-defined function name cannot be an empty string');\n\n\t// Interpret options\n\tconst safeIntegers = 'safeIntegers' in options ? +getBooleanOption(options, 'safeIntegers') : 2;\n\tconst deterministic = getBooleanOption(options, 'deterministic');\n\tconst directOnly = getBooleanOption(options, 'directOnly');\n\tconst varargs = getBooleanOption(options, 'varargs');\n\tlet argCount = -1;\n\n\t// Determine argument count\n\tif (!varargs) {\n\t\targCount = fn.length;\n\t\tif (!Number.isInteger(argCount) || argCount < 0) throw new TypeError('Expected function.length to be a positive integer');\n\t\tif (argCount > 100) throw new RangeError('User-defined functions cannot have more than 100 arguments');\n\t}\n\n\tthis[cppdb].function(fn, name, argCount, safeIntegers, deterministic, directOnly);\n\treturn this;\n};\n","'use strict';\nconst { getBooleanOption, cppdb } = require('../util');\n\nmodule.exports = function defineAggregate(name, options) {\n\t// Validate arguments\n\tif (typeof name !== 'string') throw new TypeError('Expected first argument to be a string');\n\tif (typeof options !== 'object' || options === null) throw new TypeError('Expected second argument to be an options object');\n\tif (!name) throw new TypeError('User-defined function name cannot be an empty string');\n\n\t// Interpret options\n\tconst start = 'start' in options ? options.start : null;\n\tconst step = getFunctionOption(options, 'step', true);\n\tconst inverse = getFunctionOption(options, 'inverse', false);\n\tconst result = getFunctionOption(options, 'result', false);\n\tconst safeIntegers = 'safeIntegers' in options ? +getBooleanOption(options, 'safeIntegers') : 2;\n\tconst deterministic = getBooleanOption(options, 'deterministic');\n\tconst directOnly = getBooleanOption(options, 'directOnly');\n\tconst varargs = getBooleanOption(options, 'varargs');\n\tlet argCount = -1;\n\n\t// Determine argument count\n\tif (!varargs) {\n\t\targCount = Math.max(getLength(step), inverse ? getLength(inverse) : 0);\n\t\tif (argCount > 0) argCount -= 1;\n\t\tif (argCount > 100) throw new RangeError('User-defined functions cannot have more than 100 arguments');\n\t}\n\n\tthis[cppdb].aggregate(start, step, inverse, result, name, argCount, safeIntegers, deterministic, directOnly);\n\treturn this;\n};\n\nconst getFunctionOption = (options, key, required) => {\n\tconst value = key in options ? options[key] : null;\n\tif (typeof value === 'function') return value;\n\tif (value != null) throw new TypeError(`Expected the \"${key}\" option to be a function`);\n\tif (required) throw new TypeError(`Missing required option \"${key}\"`);\n\treturn null;\n};\n\nconst getLength = ({ length }) => {\n\tif (Number.isInteger(length) && length >= 0) return length;\n\tthrow new TypeError('Expected function.length to be a positive integer');\n};\n","'use strict';\nconst { cppdb } = require('../util');\n\nmodule.exports = function defineTable(name, factory) {\n\t// Validate arguments\n\tif (typeof name !== 'string') throw new TypeError('Expected first argument to be a string');\n\tif (!name) throw new TypeError('Virtual table module name cannot be an empty string');\n\n\t// Determine whether the module is eponymous-only or not\n\tlet eponymous = false;\n\tif (typeof factory === 'object' && factory !== null) {\n\t\teponymous = true;\n\t\tfactory = defer(parseTableDefinition(factory, 'used', name));\n\t} else {\n\t\tif (typeof factory !== 'function') throw new TypeError('Expected second argument to be a function or a table definition object');\n\t\tfactory = wrapFactory(factory);\n\t}\n\n\tthis[cppdb].table(factory, name, eponymous);\n\treturn this;\n};\n\nfunction wrapFactory(factory) {\n\treturn function virtualTableFactory(moduleName, databaseName, tableName, ...args) {\n\t\tconst thisObject = {\n\t\t\tmodule: moduleName,\n\t\t\tdatabase: databaseName,\n\t\t\ttable: tableName,\n\t\t};\n\n\t\t// Generate a new table definition by invoking the factory\n\t\tconst def = apply.call(factory, thisObject, args);\n\t\tif (typeof def !== 'object' || def === null) {\n\t\t\tthrow new TypeError(`Virtual table module \"${moduleName}\" did not return a table definition object`);\n\t\t}\n\n\t\treturn parseTableDefinition(def, 'returned', moduleName);\n\t};\n}\n\nfunction parseTableDefinition(def, verb, moduleName) {\n\t// Validate required properties\n\tif (!hasOwnProperty.call(def, 'rows')) {\n\t\tthrow new TypeError(`Virtual table module \"${moduleName}\" ${verb} a table definition without a \"rows\" property`);\n\t}\n\tif (!hasOwnProperty.call(def, 'columns')) {\n\t\tthrow new TypeError(`Virtual table module \"${moduleName}\" ${verb} a table definition without a \"columns\" property`);\n\t}\n\n\t// Validate \"rows\" property\n\tconst rows = def.rows;\n\tif (typeof rows !== 'function' || Object.getPrototypeOf(rows) !== GeneratorFunctionPrototype) {\n\t\tthrow new TypeError(`Virtual table module \"${moduleName}\" ${verb} a table definition with an invalid \"rows\" property (should be a generator function)`);\n\t}\n\n\t// Validate \"columns\" property\n\tlet columns = def.columns;\n\tif (!Array.isArray(columns) || !(columns = [...columns]).every(x => typeof x === 'string')) {\n\t\tthrow new TypeError(`Virtual table module \"${moduleName}\" ${verb} a table definition with an invalid \"columns\" property (should be an array of strings)`);\n\t}\n\tif (columns.length !== new Set(columns).size) {\n\t\tthrow new TypeError(`Virtual table module \"${moduleName}\" ${verb} a table definition with duplicate column names`);\n\t}\n\tif (!columns.length) {\n\t\tthrow new RangeError(`Virtual table module \"${moduleName}\" ${verb} a table definition with zero columns`);\n\t}\n\n\t// Validate \"parameters\" property\n\tlet parameters;\n\tif (hasOwnProperty.call(def, 'parameters')) {\n\t\tparameters = def.parameters;\n\t\tif (!Array.isArray(parameters) || !(parameters = [...parameters]).every(x => typeof x === 'string')) {\n\t\t\tthrow new TypeError(`Virtual table module \"${moduleName}\" ${verb} a table definition with an invalid \"parameters\" property (should be an array of strings)`);\n\t\t}\n\t} else {\n\t\tparameters = inferParameters(rows);\n\t}\n\tif (parameters.length !== new Set(parameters).size) {\n\t\tthrow new TypeError(`Virtual table module \"${moduleName}\" ${verb} a table definition with duplicate parameter names`);\n\t}\n\tif (parameters.length > 32) {\n\t\tthrow new RangeError(`Virtual table module \"${moduleName}\" ${verb} a table definition with more than the maximum number of 32 parameters`);\n\t}\n\tfor (const parameter of parameters) {\n\t\tif (columns.includes(parameter)) {\n\t\t\tthrow new TypeError(`Virtual table module \"${moduleName}\" ${verb} a table definition with column \"${parameter}\" which was ambiguously defined as both a column and parameter`);\n\t\t}\n\t}\n\n\t// Validate \"safeIntegers\" option\n\tlet safeIntegers = 2;\n\tif (hasOwnProperty.call(def, 'safeIntegers')) {\n\t\tconst bool = def.safeIntegers;\n\t\tif (typeof bool !== 'boolean') {\n\t\t\tthrow new TypeError(`Virtual table module \"${moduleName}\" ${verb} a table definition with an invalid \"safeIntegers\" property (should be a boolean)`);\n\t\t}\n\t\tsafeIntegers = +bool;\n\t}\n\n\t// Validate \"directOnly\" option\n\tlet directOnly = false;\n\tif (hasOwnProperty.call(def, 'directOnly')) {\n\t\tdirectOnly = def.directOnly;\n\t\tif (typeof directOnly !== 'boolean') {\n\t\t\tthrow new TypeError(`Virtual table module \"${moduleName}\" ${verb} a table definition with an invalid \"directOnly\" property (should be a boolean)`);\n\t\t}\n\t}\n\n\t// Generate SQL for the virtual table definition\n\tconst columnDefinitions = [\n\t\t...parameters.map(identifier).map(str => `${str} HIDDEN`),\n\t\t...columns.map(identifier),\n\t];\n\treturn [\n\t\t`CREATE TABLE x(${columnDefinitions.join(', ')});`,\n\t\twrapGenerator(rows, new Map(columns.map((x, i) => [x, parameters.length + i])), moduleName),\n\t\tparameters,\n\t\tsafeIntegers,\n\t\tdirectOnly,\n\t];\n}\n\nfunction wrapGenerator(generator, columnMap, moduleName) {\n\treturn function* virtualTable(...args) {\n\t\t/*\n\t\t\tWe must defensively clone any buffers in the arguments, because\n\t\t\totherwise the generator could mutate one of them, which would cause\n\t\t\tus to return incorrect values for hidden columns, potentially\n\t\t\tcorrupting the database.\n\t\t */\n\t\tconst output = args.map(x => Buffer.isBuffer(x) ? Buffer.from(x) : x);\n\t\tfor (let i = 0; i < columnMap.size; ++i) {\n\t\t\toutput.push(null); // Fill with nulls to prevent gaps in array (v8 optimization)\n\t\t}\n\t\tfor (const row of generator(...args)) {\n\t\t\tif (Array.isArray(row)) {\n\t\t\t\textractRowArray(row, output, columnMap.size, moduleName);\n\t\t\t\tyield output;\n\t\t\t} else if (typeof row === 'object' && row !== null) {\n\t\t\t\textractRowObject(row, output, columnMap, moduleName);\n\t\t\t\tyield output;\n\t\t\t} else {\n\t\t\t\tthrow new TypeError(`Virtual table module \"${moduleName}\" yielded something that isn't a valid row object`);\n\t\t\t}\n\t\t}\n\t};\n}\n\nfunction extractRowArray(row, output, columnCount, moduleName) {\n\tif (row.length !== columnCount) {\n\t\tthrow new TypeError(`Virtual table module \"${moduleName}\" yielded a row with an incorrect number of columns`);\n\t}\n\tconst offset = output.length - columnCount;\n\tfor (let i = 0; i < columnCount; ++i) {\n\t\toutput[i + offset] = row[i];\n\t}\n}\n\nfunction extractRowObject(row, output, columnMap, moduleName) {\n\tlet count = 0;\n\tfor (const key of Object.keys(row)) {\n\t\tconst index = columnMap.get(key);\n\t\tif (index === undefined) {\n\t\t\tthrow new TypeError(`Virtual table module \"${moduleName}\" yielded a row with an undeclared column \"${key}\"`);\n\t\t}\n\t\toutput[index] = row[key];\n\t\tcount += 1;\n\t}\n\tif (count !== columnMap.size) {\n\t\tthrow new TypeError(`Virtual table module \"${moduleName}\" yielded a row with missing columns`);\n\t}\n}\n\nfunction inferParameters({ length }) {\n\tif (!Number.isInteger(length) || length < 0) {\n\t\tthrow new TypeError('Expected function.length to be a positive integer');\n\t}\n\tconst params = [];\n\tfor (let i = 0; i < length; ++i) {\n\t\tparams.push(`$${i + 1}`);\n\t}\n\treturn params;\n}\n\nconst { hasOwnProperty } = Object.prototype;\nconst { apply } = Function.prototype;\nconst GeneratorFunctionPrototype = Object.getPrototypeOf(function*(){});\nconst identifier = str => `\"${str.replace(/\"/g, '\"\"')}\"`;\nconst defer = x => () => x;\n","'use strict';\nconst DatabaseInspection = function Database() {};\n\nmodule.exports = function inspect(depth, opts) {\n\treturn Object.assign(new DatabaseInspection(), this);\n};\n\n","'use strict';\nconst fs = require('fs');\nconst path = require('path');\nconst util = require('./util');\nconst SqliteError = require('./sqlite-error');\n\nlet DEFAULT_ADDON;\n\nfunction Database(filenameGiven, options) {\n\tif (new.target == null) {\n\t\treturn new Database(filenameGiven, options);\n\t}\n\n\t// Apply defaults\n\tlet buffer;\n\tif (Buffer.isBuffer(filenameGiven)) {\n\t\tbuffer = filenameGiven;\n\t\tfilenameGiven = ':memory:';\n\t}\n\tif (filenameGiven == null) filenameGiven = '';\n\tif (options == null) options = {};\n\n\t// Validate arguments\n\tif (typeof filenameGiven !== 'string') throw new TypeError('Expected first argument to be a string');\n\tif (typeof options !== 'object') throw new TypeError('Expected second argument to be an options object');\n\tif ('readOnly' in options) throw new TypeError('Misspelled option \"readOnly\" should be \"readonly\"');\n\tif ('memory' in options) throw new TypeError('Option \"memory\" was removed in v7.0.0 (use \":memory:\" filename instead)');\n\n\t// Interpret options\n\tconst filename = filenameGiven.trim();\n\tconst anonymous = filename === '' || filename === ':memory:';\n\tconst readonly = util.getBooleanOption(options, 'readonly');\n\tconst fileMustExist = util.getBooleanOption(options, 'fileMustExist');\n\tconst timeout = 'timeout' in options ? options.timeout : 5000;\n\tconst verbose = 'verbose' in options ? options.verbose : null;\n\tconst nativeBinding = 'nativeBinding' in options ? options.nativeBinding : null;\n\n\t// Validate interpreted options\n\tif (readonly && anonymous && !buffer) throw new TypeError('In-memory/temporary databases cannot be readonly');\n\tif (!Number.isInteger(timeout) || timeout < 0) throw new TypeError('Expected the \"timeout\" option to be a positive integer');\n\tif (timeout > 0x7fffffff) throw new RangeError('Option \"timeout\" cannot be greater than 2147483647');\n\tif (verbose != null && typeof verbose !== 'function') throw new TypeError('Expected the \"verbose\" option to be a function');\n\tif (nativeBinding != null && typeof nativeBinding !== 'string' && typeof nativeBinding !== 'object') throw new TypeError('Expected the \"nativeBinding\" option to be a string or addon object');\n\n\t// Load the native addon\n\tlet addon;\n\tif (nativeBinding == null) {\n\t\taddon = DEFAULT_ADDON || (DEFAULT_ADDON = require('bindings')('better_sqlite3.node'));\n\t} else if (typeof nativeBinding === 'string') {\n\t\t// See <https://webpack.js.org/api/module-variables/#__non_webpack_require__-webpack-specific>\n\t\tconst requireFunc = typeof __non_webpack_require__ === 'function' ? __non_webpack_require__ : require;\n\t\taddon = requireFunc(path.resolve(nativeBinding).replace(/(\\.node)?$/, '.node'));\n\t} else {\n\t\t// See <https://github.com/WiseLibs/better-sqlite3/issues/972>\n\t\taddon = nativeBinding;\n\t}\n\n\tif (!addon.isInitialized) {\n\t\taddon.setErrorConstructor(SqliteError);\n\t\taddon.isInitialized = true;\n\t}\n\n\t// Make sure the specified directory exists\n\tif (!anonymous && !fs.existsSync(path.dirname(filename))) {\n\t\tthrow new TypeError('Cannot open database because the directory does not exist');\n\t}\n\n\tObject.defineProperties(this, {\n\t\t[util.cppdb]: { value: new addon.Database(filename, filenameGiven, anonymous, readonly, fileMustExist, timeout, verbose || null, buffer || null) },\n\t\t...wrappers.getters,\n\t});\n}\n\nconst wrappers = require('./methods/wrappers');\nDatabase.prototype.prepare = wrappers.prepare;\nDatabase.prototype.transaction = require('./methods/transaction');\nDatabase.prototype.pragma = require('./methods/pragma');\nDatabase.prototype.backup = require('./methods/backup');\nDatabase.prototype.serialize = require('./methods/serialize');\nDatabase.prototype.function = require('./methods/function');\nDatabase.prototype.aggregate = require('./methods/aggregate');\nDatabase.prototype.table = require('./methods/table');\nDatabase.prototype.loadExtension = wrappers.loadExtension;\nDatabase.prototype.exec = wrappers.exec;\nDatabase.prototype.close = wrappers.close;\nDatabase.prototype.defaultSafeIntegers = wrappers.defaultSafeIntegers;\nDatabase.prototype.unsafeMode = wrappers.unsafeMode;\nDatabase.prototype[util.inspect] = require('./methods/inspect');\n\nmodule.exports = Database;\n","'use strict';\nmodule.exports = require('./database');\nmodule.exports.SqliteError = require('./sqlite-error');\n","import { type Context, type Endpoint, createRouter } from \"better-call\";\nimport { parseAccount, parseSession, parseUser } from \"../adapters/schema\";\nimport type { AuthContext } from \"../init\";\nimport type { BetterAuthOptions, InferSession, InferUser } from \"../types\";\nimport type { Prettify } from \"../types/helper\";\nimport { csrfMiddleware } from \"./middlewares/csrf\";\nimport {\n\tcallbackOAuth,\n\tforgetPassword,\n\tgetSession,\n\tresetPassword,\n\tsendVerificationEmail,\n\tsignInEmail,\n\tsignInOAuth,\n\tsignOut,\n\tverifyEmail,\n} from \"./routes\";\nimport { getCSRFToken } from \"./routes/csrf\";\nimport { ok, welcome } from \"./routes/ok\";\nimport { signUpEmail } from \"./routes/sign-up\";\nimport { error } from \"./routes/error\";\n\nexport const router = <C extends AuthContext, Option extends BetterAuthOptions>(\n\tctx: C,\n) => {\n\tconst pluginEndpoints = ctx.options.plugins?.reduce(\n\t\t(acc, plugin) => {\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t...plugin.endpoints,\n\t\t\t};\n\t\t},\n\t\t{} as Record<string, any>,\n\t);\n\n\tconst middlewares =\n\t\tctx.options.plugins\n\t\t\t?.map((plugin) =>\n\t\t\t\tplugin.middlewares?.map((m) => {\n\t\t\t\t\tconst middleware = (async (context: any) => {\n\t\t\t\t\t\treturn m.middleware({\n\t\t\t\t\t\t\t...context,\n\t\t\t\t\t\t\tcontext: {\n\t\t\t\t\t\t\t\t...ctx,\n\t\t\t\t\t\t\t\t...context.context,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t}) as Endpoint;\n\t\t\t\t\tmiddleware.path = m.path;\n\t\t\t\t\tmiddleware.options = m.middleware.options;\n\t\t\t\t\tmiddleware.headers = m.middleware.headers;\n\t\t\t\t\treturn {\n\t\t\t\t\t\tpath: m.path,\n\t\t\t\t\t\tmiddleware,\n\t\t\t\t\t};\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.filter((plugin) => plugin !== undefined)\n\t\t\t.flat() || [];\n\n\tasync function typedSession(\n\t\tctx: Context<\n\t\t\t\"/session\",\n\t\t\t{\n\t\t\t\tmethod: \"GET\";\n\t\t\t\trequireHeaders: true;\n\t\t\t}\n\t\t>,\n\t) {\n\t\tconst handler = await getSession(ctx);\n\t\treturn handler as {\n\t\t\tsession: Prettify<InferSession<Option>>;\n\t\t\tuser: Prettify<InferUser<Option>>;\n\t\t} | null;\n\t}\n\ttypedSession.path = getSession.path;\n\ttypedSession.method = getSession.method;\n\ttypedSession.options = getSession.options;\n\ttypedSession.headers = getSession.headers;\n\n\tconst baseEndpoints = {\n\t\tsignInOAuth,\n\t\tcallbackOAuth,\n\t\tgetCSRFToken,\n\t\tgetSession: typedSession,\n\t\tsignOut,\n\t\tsignUpEmail,\n\t\tsignInEmail,\n\t\tforgetPassword,\n\t\tresetPassword,\n\t\tverifyEmail,\n\t\tsendVerificationEmail,\n\t};\n\tconst endpoints = {\n\t\t...baseEndpoints,\n\t\t...pluginEndpoints,\n\t\tok,\n\t\twelcome,\n\t\terror,\n\t};\n\tlet api: Record<string, any> = {};\n\tfor (const [key, value] of Object.entries(endpoints)) {\n\t\tapi[key] = async (context: any) => {\n\t\t\tfor (const plugin of ctx.options.plugins || []) {\n\t\t\t\tif (plugin.hooks?.before) {\n\t\t\t\t\tfor (const hook of plugin.hooks.before) {\n\t\t\t\t\t\tconst match = hook.matcher({\n\t\t\t\t\t\t\t...context,\n\t\t\t\t\t\t\t...value,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (match) {\n\t\t\t\t\t\t\tconst hookRes = await hook.handler(context);\n\t\t\t\t\t\t\tif (hookRes && \"context\" in hookRes) {\n\t\t\t\t\t\t\t\tcontext = {\n\t\t\t\t\t\t\t\t\t...context,\n\t\t\t\t\t\t\t\t\t...hookRes.context,\n\t\t\t\t\t\t\t\t\t...value,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t//@ts-ignore\n\t\t\tconst endpointRes = value({\n\t\t\t\t...context,\n\t\t\t\tcontext: {\n\t\t\t\t\t...ctx,\n\t\t\t\t\t...context.context,\n\t\t\t\t},\n\t\t\t});\n\t\t\tlet response = endpointRes;\n\t\t\tfor (const plugin of ctx.options.plugins || []) {\n\t\t\t\tif (plugin.hooks?.after) {\n\t\t\t\t\tfor (const hook of plugin.hooks.after) {\n\t\t\t\t\t\tconst match = hook.matcher(context);\n\t\t\t\t\t\tif (match) {\n\t\t\t\t\t\t\tconst obj = Object.assign(context, {\n\t\t\t\t\t\t\t\treturned: endpointRes,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tconst hookRes = await hook.handler(obj);\n\t\t\t\t\t\t\tif (hookRes && \"response\" in hookRes) {\n\t\t\t\t\t\t\t\tresponse = hookRes.response as any;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn response;\n\t\t};\n\t\tapi[key].path = value.path;\n\t\tapi[key].method = value.method;\n\t\tapi[key].options = value.options;\n\t\tapi[key].headers = value.headers;\n\t}\n\treturn createRouter(api as typeof baseEndpoints, {\n\t\textraContext: ctx,\n\t\tbasePath: ctx.options.basePath,\n\t\trouterMiddleware: [\n\t\t\t{\n\t\t\t\tpath: \"/**\",\n\t\t\t\tmiddleware: csrfMiddleware,\n\t\t\t},\n\t\t\t...middlewares,\n\t\t],\n\t\t/**\n\t\t * this is to remove any sensitive data from the response\n\t\t */\n\t\tasync transformResponse(res) {\n\t\t\tlet body: Record<string, any> = {};\n\t\t\ttry {\n\t\t\t\tbody = await res.json();\n\t\t\t} catch (e) {\n\t\t\t\treturn res;\n\t\t\t}\n\t\t\tif (body?.user) {\n\t\t\t\tbody.user = parseUser(ctx.options, body.user);\n\t\t\t}\n\t\t\tif (body?.session) {\n\t\t\t\tbody.session = parseSession(ctx.options, body.session);\n\t\t\t}\n\t\t\tif (body?.account) {\n\t\t\t\tbody.account = parseAccount(ctx.options, body.account);\n\t\t\t}\n\t\t\treturn new Response(body ? JSON.stringify(body) : null, {\n\t\t\t\theaders: res.headers,\n\t\t\t\tstatus: res.status,\n\t\t\t\tstatusText: res.statusText,\n\t\t\t});\n\t\t},\n\t\tonError(e) {\n\t\t\tconsole.log(e);\n\t\t},\n\t});\n};\n","import { z } from \"zod\";\nimport type { FieldAttribute } from \"../db\";\nimport type { BetterAuthOptions } from \"../types\";\n\nexport const accountSchema = z.object({\n\tid: z.string(),\n\tproviderId: z.string(),\n\taccountId: z.string(),\n\tuserId: z.string(),\n\taccessToken: z.string().nullable().optional(),\n\trefreshToken: z.string().nullable().optional(),\n\tidToken: z.string().nullable().optional(),\n\taccessTokenExpiresAt: z.date().nullable().optional(),\n\trefreshTokenExpiresAt: z.date().nullable().optional(),\n\t/**\n\t * Password is only stored in the credential provider\n\t */\n\tpassword: z.string().optional().nullable(),\n});\n\nexport const userSchema = z.object({\n\tid: z.string(),\n\temail: z.string().transform((val) => val.toLowerCase()),\n\temailVerified: z.boolean().default(false),\n\tname: z.string(),\n\timage: z.string().optional(),\n\tcreatedAt: z.date().default(new Date()),\n\tupdatedAt: z.date().default(new Date()),\n});\n\nexport const sessionSchema = z.object({\n\tid: z.string(),\n\tuserId: z.string(),\n\texpiresAt: z.date(),\n\tipAddress: z.string().optional(),\n\tuserAgent: z.string().optional(),\n});\n\nexport type User = z.infer<typeof userSchema>;\nexport type Account = z.infer<typeof accountSchema>;\nexport type Session = z.infer<typeof sessionSchema>;\nexport interface MigrationTable {\n\tname: string;\n\ttimestamp: string;\n}\n\nexport function parseData<T extends Record<string, any>>(\n\tdata: T,\n\tschema: {\n\t\tfields: Record<string, FieldAttribute>;\n\t},\n) {\n\tconst fields = schema.fields;\n\tconst parsedData: Record<string, any> = {};\n\tfor (const key in data) {\n\t\tconst field = fields[key];\n\t\tif (!field) {\n\t\t\tparsedData[key] = data[key];\n\t\t\tcontinue;\n\t\t}\n\t\tif (field.returned === false) {\n\t\t\tcontinue;\n\t\t}\n\t\tparsedData[key] = data[key];\n\t}\n\treturn parsedData as T;\n}\n\nexport function getAllFields(options: BetterAuthOptions, table: string) {\n\tlet schema: Record<string, FieldAttribute> = {};\n\tfor (const plugin of options.plugins || []) {\n\t\tif (plugin.schema && plugin.schema[table]) {\n\t\t\tschema = {\n\t\t\t\t...schema,\n\t\t\t\t...plugin.schema[table].fields,\n\t\t\t};\n\t\t}\n\t}\n\treturn schema;\n}\n\nexport function parseUser(options: BetterAuthOptions, user: User) {\n\tconst schema = getAllFields(options, \"user\");\n\treturn parseData(user, { fields: schema });\n}\n\nexport function parseAccount(options: BetterAuthOptions, account: Account) {\n\tconst schema = getAllFields(options, \"account\");\n\treturn parseData(account, { fields: schema });\n}\n\nexport function parseSession(options: BetterAuthOptions, session: Session) {\n\tconst schema = getAllFields(options, \"session\");\n\treturn parseData(session, { fields: schema });\n}\n","import { APIError } from \"better-call\";\nimport { z } from \"zod\";\nimport { hs256 } from \"../../crypto\";\nimport { createAuthMiddleware } from \"../call\";\n\nexport const csrfMiddleware = createAuthMiddleware(\n\t{\n\t\tbody: z\n\t\t\t.object({\n\t\t\t\tcsrfToken: z.string().optional(),\n\t\t\t})\n\t\t\t.optional(),\n\t},\n\tasync (ctx) => {\n\t\tif (\n\t\t\tctx.request?.method !== \"POST\" ||\n\t\t\tctx.context.options.advanced?.disableCSRFCheck\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tconst url = new URL(ctx.request.url);\n\t\tconsole.log(url.origin, ctx.context.options.baseURL);\n\t\t/**\n\t\t * If origin is the same as baseURL or if the\n\t\t * origin is in the trustedOrigins then we\n\t\t * don't need to check the CSRF token.\n\t\t */\n\t\tif (\n\t\t\turl.origin === ctx.context.options.baseURL ||\n\t\t\tctx.context.options.trustedOrigins?.includes(url.origin)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst csrfToken = ctx.body?.csrfToken;\n\t\tconst csrfCookie = await ctx.getSignedCookie(\n\t\t\tctx.context.authCookies.csrfToken.name,\n\t\t\tctx.context.secret,\n\t\t);\n\t\tconst [token, hash] = csrfCookie?.split(\"!\") || [null, null];\n\t\tif (\n\t\t\t!csrfToken ||\n\t\t\t!csrfCookie ||\n\t\t\t!token ||\n\t\t\t!hash ||\n\t\t\tcsrfCookie !== csrfToken\n\t\t) {\n\t\t\tctx.setCookie(ctx.context.authCookies.csrfToken.name, \"\", {\n\t\t\t\tmaxAge: 0,\n\t\t\t});\n\t\t\tthrow new APIError(\"UNAUTHORIZED\", {\n\t\t\t\tmessage: \"Invalid CSRF Token\",\n\t\t\t});\n\t\t}\n\t\tconst expectedHash = await hs256(ctx.context.secret, token);\n\t\tif (hash !== expectedHash) {\n\t\t\tctx.setCookie(ctx.context.authCookies.csrfToken.name, \"\", {\n\t\t\t\tmaxAge: 0,\n\t\t\t});\n\t\t\tthrow new APIError(\"UNAUTHORIZED\", {\n\t\t\t\tmessage: \"Invalid CSRF Token\",\n\t\t\t});\n\t\t}\n\t},\n);\n","import { xchacha20poly1305 } from \"@noble/ciphers/chacha\";\nimport { bytesToHex, hexToBytes, utf8ToBytes } from \"@noble/ciphers/utils\";\nimport { managedNonce } from \"@noble/ciphers/webcrypto\";\nimport { sha256 } from \"@noble/hashes/sha256\";\n\nexport async function hs256(secretKey: string, message: string) {\n\tconst enc = new TextEncoder();\n\tconst algorithm = { name: \"HMAC\", hash: \"SHA-256\" };\n\tconst key = await crypto.subtle.importKey(\n\t\t\"raw\",\n\t\tenc.encode(secretKey),\n\t\talgorithm,\n\t\tfalse,\n\t\t[\"sign\", \"verify\"],\n\t);\n\tconst signature = await crypto.subtle.sign(\n\t\talgorithm.name,\n\t\tkey,\n\t\tenc.encode(message),\n\t);\n\treturn btoa(String.fromCharCode(...new Uint8Array(signature)));\n}\n\nexport type SymmetricEncryptOptions = {\n\tkey: string;\n\tdata: string;\n};\n\nexport const symmetricEncrypt = ({ key, data }: SymmetricEncryptOptions) => {\n\tconst keyAsBytes = sha256(key);\n\tconst dataAsBytes = utf8ToBytes(data);\n\tconst chacha = managedNonce(xchacha20poly1305)(keyAsBytes);\n\treturn bytesToHex(chacha.encrypt(dataAsBytes));\n};\n\nexport type SymmetricDecryptOptions = {\n\tkey: string;\n\tdata: string;\n};\n\nexport const symmetricDecrypt = ({ key, data }: SymmetricDecryptOptions) => {\n\tconst keyAsBytes = sha256(key);\n\tconst dataAsBytes = hexToBytes(data);\n\tconst chacha = managedNonce(xchacha20poly1305)(keyAsBytes);\n\treturn chacha.decrypt(dataAsBytes);\n};\n","import {\n\ttype Endpoint,\n\ttype EndpointResponse,\n\tcreateEndpointCreator,\n\tcreateMiddleware,\n\tcreateMiddlewareCreator,\n} from \"better-call\";\nimport type { AuthContext } from \"../init\";\nimport type { BetterAuthOptions } from \"../types/options\";\n\nexport const optionsMiddleware = createMiddleware(async () => {\n\t/**\n\t * This will be passed on the instance of\n\t * the context. Used to infer the type\n\t * here.\n\t */\n\treturn {} as AuthContext;\n});\n\nexport const createAuthMiddleware = createMiddlewareCreator({\n\tuse: [optionsMiddleware],\n});\n\nexport const createAuthEndpoint = createEndpointCreator({\n\tuse: [optionsMiddleware],\n});\n\nexport type AuthEndpoint = Endpoint<\n\t(ctx: {\n\t\toptions: BetterAuthOptions;\n\t\tbody: any;\n\t\tquery: any;\n\t\theaders: Headers;\n\t}) => Promise<EndpointResponse>\n>;\n\nexport type AuthMiddleware = ReturnType<typeof createAuthMiddleware>;\n","import { APIError } from \"better-call\";\nimport { generateCodeVerifier } from \"oslo/oauth2\";\nimport { Argon2id } from \"oslo/password\";\nimport { z } from \"zod\";\nimport { oAuthProviderList } from \"../../social-providers\";\nimport { generateState } from \"../../utils/state\";\nimport { createAuthEndpoint } from \"../call\";\nimport { getSessionFromCtx } from \"./session\";\n\nexport const signInOAuth = createAuthEndpoint(\n\t\"/sign-in/social\",\n\t{\n\t\tmethod: \"POST\",\n\t\trequireHeaders: true,\n\t\tquery: z\n\t\t\t.object({\n\t\t\t\t/**\n\t\t\t\t * Redirect to the current URL after the\n\t\t\t\t * user has signed in.\n\t\t\t\t */\n\t\t\t\tcurrentURL: z.string().optional(),\n\t\t\t})\n\t\t\t.optional(),\n\t\tbody: z.object({\n\t\t\t/**\n\t\t\t * Callback URL to redirect to after the user has signed in.\n\t\t\t */\n\t\t\tcallbackURL: z.string().optional(),\n\t\t\t/**\n\t\t\t * OAuth2 provider to use`\n\t\t\t */\n\t\t\tprovider: z.enum(oAuthProviderList),\n\t\t}),\n\t},\n\tasync (c) => {\n\t\tconst provider = c.context.options.socialProvider?.find(\n\t\t\t(p) => p.id === c.body.provider,\n\t\t);\n\t\tif (!provider) {\n\t\t\tc.context.logger.error(\n\t\t\t\t\"Provider not found. Make sure to add the provider to your auth config\",\n\t\t\t\t{\n\t\t\t\t\tprovider: c.body.provider,\n\t\t\t\t},\n\t\t\t);\n\t\t\tthrow new APIError(\"NOT_FOUND\");\n\t\t}\n\t\tconst cookie = c.context.authCookies;\n\t\tconst currentURL = c.query?.currentURL\n\t\t\t? new URL(c.query?.currentURL)\n\t\t\t: null;\n\t\tconst state = generateState(\n\t\t\tc.body.callbackURL || currentURL?.origin || c.context.baseURL,\n\t\t\tc.query?.currentURL,\n\t\t);\n\t\ttry {\n\t\t\tawait c.setSignedCookie(\n\t\t\t\tcookie.state.name,\n\t\t\t\tstate.code,\n\t\t\t\tc.context.secret,\n\t\t\t\tcookie.state.options,\n\t\t\t);\n\t\t\tconst codeVerifier = generateCodeVerifier();\n\t\t\tawait c.setSignedCookie(\n\t\t\t\tcookie.pkCodeVerifier.name,\n\t\t\t\tcodeVerifier,\n\t\t\t\tc.context.secret,\n\t\t\t\tcookie.pkCodeVerifier.options,\n\t\t\t);\n\t\t\tconst url = provider.createAuthorizationURL({\n\t\t\t\tstate: state.state,\n\t\t\t\tcodeVerifier,\n\t\t\t});\n\t\t\treturn {\n\t\t\t\turl: url.toString(),\n\t\t\t\tstate: state.state,\n\t\t\t\tcodeVerifier,\n\t\t\t\tredirect: true,\n\t\t\t};\n\t\t} catch (e) {\n\t\t\tthrow new APIError(\"INTERNAL_SERVER_ERROR\");\n\t\t}\n\t},\n);\n\nexport const signInEmail = createAuthEndpoint(\n\t\"/sign-in/email\",\n\t{\n\t\tmethod: \"POST\",\n\t\tbody: z.object({\n\t\t\temail: z.string().email(),\n\t\t\tpassword: z.string(),\n\t\t\tcallbackURL: z.string().optional(),\n\t\t\t/**\n\t\t\t * If this is true the session will only be valid for the current browser session\n\t\t\t * @default false\n\t\t\t */\n\t\t\tdontRememberMe: z.boolean().default(false).optional(),\n\t\t}),\n\t},\n\tasync (ctx) => {\n\t\tif (!ctx.context.options?.emailAndPassword?.enabled) {\n\t\t\tctx.context.logger.error(\"Email and password is not enabled\");\n\t\t\tthrow new APIError(\"BAD_REQUEST\", {\n\t\t\t\tmessage: \"Email and password is not enabled\",\n\t\t\t});\n\t\t}\n\t\tconst currentSession = await getSessionFromCtx(ctx);\n\t\tif (currentSession) {\n\t\t\treturn ctx.json({\n\t\t\t\tuser: currentSession.user,\n\t\t\t\tsession: currentSession.session,\n\t\t\t\tredirect: !!ctx.body.callbackURL,\n\t\t\t\turl: ctx.body.callbackURL,\n\t\t\t});\n\t\t}\n\t\tconst { email, password } = ctx.body;\n\t\tconst argon2id = new Argon2id();\n\t\tconst user = await ctx.context.internalAdapter.findUserByEmail(email);\n\t\tif (!user) {\n\t\t\tawait argon2id.hash(password);\n\t\t\tctx.context.logger.error(\"User not found\", { email });\n\t\t\tthrow new APIError(\"UNAUTHORIZED\", {\n\t\t\t\tmessage: \"Invalid email or password\",\n\t\t\t});\n\t\t}\n\t\tconst credentialAccount = user.accounts.find(\n\t\t\t(a) => a.providerId === \"credential\",\n\t\t);\n\t\tif (!credentialAccount) {\n\t\t\tctx.context.logger.error(\"Credential account not found\", { email });\n\t\t\tthrow new APIError(\"UNAUTHORIZED\", {\n\t\t\t\tmessage: \"Invalid email or password\",\n\t\t\t});\n\t\t}\n\t\tconst currentPassword = credentialAccount?.password;\n\t\tif (!currentPassword) {\n\t\t\tctx.context.logger.error(\"Password not found\", { email });\n\t\t\tthrow new APIError(\"UNAUTHORIZED\", {\n\t\t\t\tmessage: \"Unexpected error\",\n\t\t\t});\n\t\t}\n\t\tconst validPassword = await argon2id.verify(currentPassword, password);\n\t\tif (!validPassword) {\n\t\t\tctx.context.logger.error(\"Invalid password\");\n\t\t\tthrow new APIError(\"UNAUTHORIZED\", {\n\t\t\t\tmessage: \"Invalid email or password\",\n\t\t\t});\n\t\t}\n\t\tconst session = await ctx.context.internalAdapter.createSession(\n\t\t\tuser.user.id,\n\t\t\tctx.request,\n\t\t);\n\t\tawait ctx.setSignedCookie(\n\t\t\tctx.context.authCookies.sessionToken.name,\n\t\t\tsession.id,\n\t\t\tctx.context.secret,\n\t\t\tctx.body.dontRememberMe\n\t\t\t\t? {\n\t\t\t\t\t\t...ctx.context.authCookies.sessionToken.options,\n\t\t\t\t\t\tmaxAge: undefined,\n\t\t\t\t\t}\n\t\t\t\t: ctx.context.authCookies.sessionToken.options,\n\t\t);\n\t\treturn ctx.json({\n\t\t\tuser: user.user,\n\t\t\tsession,\n\t\t\tredirect: !!ctx.body.callbackURL,\n\t\t\turl: ctx.body.callbackURL,\n\t\t});\n\t},\n);\n","import { OAuth2Tokens } from \"arctic\";\nimport type { OAuthProvider } from \".\";\nimport { parseJWT } from \"oslo/jwt\";\nimport { betterFetch } from \"@better-fetch/fetch\";\nimport { BetterAuthError } from \"../error/better-auth-error\";\nimport { getRedirectURI } from \"./utils\";\nexport interface AppleProfile {\n\t/**\n\t * The subject registered claim identifies the principal that’s the subject\n\t * of the identity token. Because this token is for your app, the value is\n\t * the unique identifier for the user.\n\t */\n\tsub: string;\n\t/**\n\t * A String value representing the user's email address.\n\t * The email address is either the user's real email address or the proxy\n\t * address, depending on their status private email relay service.\n\t */\n\temail: string;\n\t/**\n\t * A string or Boolean value that indicates whether the service verifies\n\t * the email. The value can either be a string (\"true\" or \"false\") or a\n\t * Boolean (true or false). The system may not verify email addresses for\n\t * Sign in with Apple at Work & School users, and this claim is \"false\" or\n\t * false for those users.\n\t */\n\temail_verified: true | \"true\";\n\t/**\n\t * A string or Boolean value that indicates whether the email that the user\n\t * shares is the proxy address. The value can either be a string (\"true\" or\n\t * \"false\") or a Boolean (true or false).\n\t */\n\tis_private_email: boolean;\n\t/**\n\t * An Integer value that indicates whether the user appears to be a real\n\t * person. Use the value of this claim to mitigate fraud. The possible\n\t * values are: 0 (or Unsupported), 1 (or Unknown), 2 (or LikelyReal). For\n\t * more information, see ASUserDetectionStatus. This claim is present only\n\t * in iOS 14 and later, macOS 11 and later, watchOS 7 and later, tvOS 14\n\t * and later. The claim isn’t present or supported for web-based apps.\n\t */\n\treal_user_status: number;\n\t/**\n\t * The user’s full name in the format provided during the authorization\n\t * process.\n\t */\n\tname: string;\n}\n\nexport interface AppleOptions {\n\tclientId: string;\n\tclientSecret: string;\n\tredirectURI?: string;\n}\n\nexport const apple = ({\n\tclientId,\n\tclientSecret,\n\tredirectURI,\n}: AppleOptions) => {\n\tconst tokenEndpoint = \"https://appleid.apple.com/auth/token\";\n\tredirectURI = getRedirectURI(\"apple\", redirectURI);\n\treturn {\n\t\tid: \"apple\",\n\t\tname: \"Apple\",\n\t\tcreateAuthorizationURL({ state, scopes }) {\n\t\t\tconst _scope = scopes || [\"email\", \"name\", \"openid\"];\n\t\t\treturn new URL(\n\t\t\t\t`https://appleid.apple.com/auth/authorize?client_id=${clientId}&response_type=code&redirect_uri=${redirectURI}&scope=${_scope.join(\n\t\t\t\t\t\" \",\n\t\t\t\t)}&state=${state}`,\n\t\t\t);\n\t\t},\n\t\tvalidateAuthorizationCode: async (code) => {\n\t\t\tconst data = await betterFetch<OAuth2Tokens>(tokenEndpoint, {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tbody: new URLSearchParams({\n\t\t\t\t\tclient_id: clientId,\n\t\t\t\t\tclient_secret: clientSecret,\n\t\t\t\t\tgrant_type: \"authorization_code\",\n\t\t\t\t\tcode,\n\t\t\t\t}),\n\t\t\t\theaders: {\n\t\t\t\t\t\"Content-Type\": \"application/x-www-form-urlencoded\",\n\t\t\t\t},\n\t\t\t});\n\t\t\tif (data.error) {\n\t\t\t\tthrow new BetterAuthError(data.error?.message || \"\");\n\t\t\t}\n\t\t\treturn data.data;\n\t\t},\n\t\tasync getUserInfo(token) {\n\t\t\tconst data = parseJWT(token.idToken())?.payload as AppleProfile | null;\n\t\t\tif (!data) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tuser: {\n\t\t\t\t\tid: data.sub,\n\t\t\t\t\tname: data.name,\n\t\t\t\t\temail: data.email,\n\t\t\t\t\temailVerified: data.email_verified === \"true\",\n\t\t\t\t},\n\t\t\t\tdata,\n\t\t\t};\n\t\t},\n\t} satisfies OAuthProvider<AppleProfile>;\n};\n","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\tconsole.error(\"Invalid URL:\", error);\n\t\treturn false;\n\t}\n}\n\nfunction withPath(url: string, path = \"/api/auth\") {\n\tconst hasPath = checkHasPath(url);\n\tif (hasPath) {\n\t\treturn {\n\t\t\tbaseURL: new URL(url).origin,\n\t\t\twithPath: url,\n\t\t};\n\t}\n\tpath = path.startsWith(\"/\") ? path : `/${path}`;\n\treturn {\n\t\tbaseURL: url,\n\t\twithPath: `${url}${path}`,\n\t};\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.AUTH_URL ||\n\t\tenv.NEXT_PUBLIC_AUTH_URL ||\n\t\tenv.NEXT_PUBLIC_BETTER_AUTH_URL ||\n\t\tenv.PUBLIC_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\tconst isDev =\n\t\t!fromEnv && (env.NODE_ENV === \"development\" || env.NODE_ENV === \"test\");\n\tif (isDev) {\n\t\treturn {\n\t\t\tbaseURL: \"http://localhost:3000\",\n\t\t\twithPath: \"http://localhost:3000/api/auth\",\n\t\t};\n\t}\n\tthrow new BetterAuthError(\n\t\t\"Could not infer baseURL from environment variables\",\n\t);\n}\n","import { getBaseURL } from \"../utils/base-url\";\n\nexport function getRedirectURI(providerId: string, redirectURI?: string) {\n\treturn redirectURI || `${getBaseURL()}/api/auth/callback/${providerId}`;\n}\n","import { betterFetch } from \"@better-fetch/fetch\";\nimport { Discord } from \"arctic\";\nimport type { OAuthProvider } from \".\";\nimport { getRedirectURI } from \"./utils\";\n\nexport interface DiscordProfile extends Record<string, any> {\n\t/** the user's id (i.e. the numerical snowflake) */\n\tid: string;\n\t/** the user's username, not unique across the platform */\n\tusername: string;\n\t/** the user's Discord-tag */\n\tdiscriminator: string;\n\t/** the user's display name, if it is set */\n\tglobal_name: string | null;\n\t/**\n\t * the user's avatar hash:\n\t * https://discord.com/developers/docs/reference#image-formatting\n\t */\n\tavatar: string | null;\n\t/** whether the user belongs to an OAuth2 application */\n\tbot?: boolean;\n\t/**\n\t * whether the user is an Official Discord System user (part of the urgent\n\t * message system)\n\t */\n\tsystem?: boolean;\n\t/** whether the user has two factor enabled on their account */\n\tmfa_enabled: boolean;\n\t/**\n\t * the user's banner hash:\n\t * https://discord.com/developers/docs/reference#image-formatting\n\t */\n\tbanner: string | null;\n\n\t/** the user's banner color encoded as an integer representation of hexadecimal color code */\n\taccent_color: number | null;\n\n\t/**\n\t * the user's chosen language option:\n\t * https://discord.com/developers/docs/reference#locales\n\t */\n\tlocale: string;\n\t/** whether the email on this account has been verified */\n\tverified: boolean;\n\t/** the user's email */\n\temail: string;\n\t/**\n\t * the flags on a user's account:\n\t * https://discord.com/developers/docs/resources/user#user-object-user-flags\n\t */\n\tflags: number;\n\t/**\n\t * the type of Nitro subscription on a user's account:\n\t * https://discord.com/developers/docs/resources/user#user-object-premium-types\n\t */\n\tpremium_type: number;\n\t/**\n\t * the public flags on a user's account:\n\t * https://discord.com/developers/docs/resources/user#user-object-user-flags\n\t */\n\tpublic_flags: number;\n\t/** undocumented field; corresponds to the user's custom nickname */\n\tdisplay_name: string | null;\n\t/**\n\t * undocumented field; corresponds to the Discord feature where you can e.g.\n\t * put your avatar inside of an ice cube\n\t */\n\tavatar_decoration: string | null;\n\t/**\n\t * undocumented field; corresponds to the premium feature where you can\n\t * select a custom banner color\n\t */\n\tbanner_color: string | null;\n\t/** undocumented field; the CDN URL of their profile picture */\n\timage_url: string;\n}\n\nexport interface DiscordOptions {\n\tclientId: string;\n\tclientSecret: string;\n\tredirectURI?: string;\n}\n\nexport const discord = ({\n\tclientId,\n\tclientSecret,\n\tredirectURI,\n}: DiscordOptions) => {\n\tconst discordArctic = new Discord(\n\t\tclientId,\n\t\tclientSecret,\n\t\tgetRedirectURI(\"discord\", redirectURI),\n\t);\n\treturn {\n\t\tid: \"discord\",\n\t\tname: \"Discord\",\n\t\tcreateAuthorizationURL({ state, scopes }) {\n\t\t\tconst _scope = scopes || [\"email\"];\n\t\t\treturn discordArctic.createAuthorizationURL(state, _scope);\n\t\t},\n\t\tvalidateAuthorizationCode: discordArctic.validateAuthorizationCode,\n\t\tasync getUserInfo(token) {\n\t\t\tconst { data: profile, error } = await betterFetch<DiscordProfile>(\n\t\t\t\t\"https://discord.com/api/users/@me\",\n\t\t\t\t{\n\t\t\t\t\tauth: {\n\t\t\t\t\t\ttype: \"Bearer\",\n\t\t\t\t\t\ttoken: token.accessToken,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t\tif (error) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tuser: {\n\t\t\t\t\tid: profile.id,\n\t\t\t\t\tname: profile.display_name || profile.username || \"\",\n\t\t\t\t\temail: profile.email,\n\t\t\t\t\temailVerified: profile.verified,\n\t\t\t\t},\n\t\t\t\tdata: profile,\n\t\t\t};\n\t\t},\n\t} satisfies OAuthProvider<DiscordProfile>;\n};\n","import { betterFetch } from \"@better-fetch/fetch\";\nimport { Facebook } from \"arctic\";\nimport type { OAuthProvider } from \".\";\nimport { getRedirectURI } from \"./utils\";\n\nexport interface FacebookProfile {\n\tid: string;\n\tname: string;\n\temail: string;\n\temail_verified: boolean;\n\tpicture: {\n\t\tdata: {\n\t\t\theight: number;\n\t\t\tis_silhouette: boolean;\n\t\t\turl: string;\n\t\t\twidth: number;\n\t\t};\n\t};\n}\nexport interface FacebookOptions {\n\tclientId: string;\n\tclientSecret: string;\n\tredirectURI?: string;\n}\nexport const facebook = ({\n\tclientId,\n\tclientSecret,\n\tredirectURI,\n}: FacebookOptions) => {\n\tconst facebookArctic = new Facebook(\n\t\tclientId,\n\t\tclientSecret,\n\t\tgetRedirectURI(\"facebook\", redirectURI),\n\t);\n\treturn {\n\t\tid: \"facebook\",\n\t\tname: \"Facebook\",\n\t\tcreateAuthorizationURL({ state, scopes }) {\n\t\t\tconst _scopes = scopes || [\"email\", \"public_profile\"];\n\t\t\treturn facebookArctic.createAuthorizationURL(state, _scopes);\n\t\t},\n\t\tvalidateAuthorizationCode: facebookArctic.validateAuthorizationCode,\n\t\tasync getUserInfo(token) {\n\t\t\tconst { data: profile, error } = await betterFetch<FacebookProfile>(\n\t\t\t\t\"https://graph.facebook.com/me\",\n\t\t\t\t{\n\t\t\t\t\tauth: {\n\t\t\t\t\t\ttype: \"Bearer\",\n\t\t\t\t\t\ttoken: token.accessToken,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t\tif (error) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tuser: {\n\t\t\t\t\tid: profile.id,\n\t\t\t\t\tname: profile.name,\n\t\t\t\t\temail: profile.email,\n\t\t\t\t\temailVerified: profile.email_verified,\n\t\t\t\t},\n\t\t\t\tdata: profile,\n\t\t\t};\n\t\t},\n\t} satisfies OAuthProvider<FacebookProfile>;\n};\n","import { betterFetch } from \"@better-fetch/fetch\";\nimport { GitHub } from \"arctic\";\nimport type { OAuthProvider } from \".\";\nimport { getRedirectURI } from \"./utils\";\n\nexport interface GithubProfile {\n\tlogin: string;\n\tid: string;\n\tnode_id: string;\n\tavatar_url: string;\n\tgravatar_id: string;\n\turl: string;\n\thtml_url: string;\n\tfollowers_url: string;\n\tfollowing_url: string;\n\tgists_url: string;\n\tstarred_url: string;\n\tsubscriptions_url: string;\n\torganizations_url: string;\n\trepos_url: string;\n\tevents_url: string;\n\treceived_events_url: string;\n\ttype: string;\n\tsite_admin: boolean;\n\tname: string;\n\tcompany: string;\n\tblog: string;\n\tlocation: string;\n\temail: string;\n\thireable: boolean;\n\tbio: string;\n\ttwitter_username: string;\n\tpublic_repos: string;\n\tpublic_gists: string;\n\tfollowers: string;\n\tfollowing: string;\n\tcreated_at: string;\n\tupdated_at: string;\n\tprivate_gists: string;\n\ttotal_private_repos: string;\n\towned_private_repos: string;\n\tdisk_usage: string;\n\tcollaborators: string;\n\ttwo_factor_authentication: boolean;\n\tplan: {\n\t\tname: string;\n\t\tspace: string;\n\t\tprivate_repos: string;\n\t\tcollaborators: string;\n\t};\n\tfirst_name: string;\n\tlast_name: string;\n}\n\nexport interface GithubOptions {\n\tclientId: string;\n\tclientSecret: string;\n\tredirectURI?: string;\n}\nexport const github = ({\n\tclientId,\n\tclientSecret,\n\tredirectURI,\n}: GithubOptions) => {\n\tconst githubArctic = new GitHub(\n\t\tclientId,\n\t\tclientSecret,\n\t\tgetRedirectURI(\"github\", redirectURI),\n\t);\n\treturn {\n\t\tid: \"github\",\n\t\tname: \"Github\",\n\t\tcreateAuthorizationURL({ state, scopes }) {\n\t\t\tconst _scopes = scopes || [\"user:email\"];\n\t\t\treturn githubArctic.createAuthorizationURL(state, _scopes);\n\t\t},\n\t\tvalidateAuthorizationCode: githubArctic.validateAuthorizationCode,\n\t\tasync getUserInfo(token) {\n\t\t\tconst { data: profile, error } = await betterFetch<GithubProfile>(\n\t\t\t\t\"https://api.github.com/user\",\n\t\t\t\t{\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\theaders: {\n\t\t\t\t\t\tAuthorization: `Bearer ${token.accessToken}`,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t\tif (error) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tlet emailVerified = false;\n\t\t\tif (!profile.email) {\n\t\t\t\tconst { data, error } = await betterFetch<\n\t\t\t\t\t{\n\t\t\t\t\t\temail: string;\n\t\t\t\t\t\tprimary: boolean;\n\t\t\t\t\t\tverified: boolean;\n\t\t\t\t\t\tvisibility: \"public\" | \"private\";\n\t\t\t\t\t}[]\n\t\t\t\t>(\"https://api.github.com/user/emails\", {\n\t\t\t\t\theaders: {\n\t\t\t\t\t\tAuthorization: `Bearer ${token.accessToken}`,\n\t\t\t\t\t\t\"User-Agent\": \"better-auth\",\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\tif (!error) {\n\t\t\t\t\tprofile.email = (data.find((e) => e.primary) ?? data[0])\n\t\t\t\t\t\t?.email as string;\n\t\t\t\t\temailVerified =\n\t\t\t\t\t\tdata.find((e) => e.email === profile.email)?.verified ?? false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tuser: {\n\t\t\t\t\tid: profile.id,\n\t\t\t\t\tname: profile.name,\n\t\t\t\t\temail: profile.email,\n\t\t\t\t\timage: profile.avatar_url,\n\t\t\t\t\temailVerified,\n\t\t\t\t\tcreatedAt: new Date(),\n\t\t\t\t\tupdatedAt: new Date(),\n\t\t\t\t},\n\t\t\t\tdata: profile,\n\t\t\t};\n\t\t},\n\t} satisfies OAuthProvider<GithubProfile>;\n};\n","import { Google } from \"arctic\";\nimport { parseJWT } from \"oslo/jwt\";\nimport type { OAuthProvider } from \".\";\nimport { getRedirectURI } from \"./utils\";\nimport { BetterAuthError } from \"../error/better-auth-error\";\n\nexport interface GoogleProfile {\n\taud: string;\n\tazp: string;\n\temail: string;\n\temail_verified: boolean;\n\texp: number;\n\t/**\n\t * The family name of the user, or last name in most\n\t * Western languages.\n\t */\n\tfamily_name: string;\n\t/**\n\t * The given name of the user, or first name in most\n\t * Western languages.\n\t */\n\tgiven_name: string;\n\thd?: string;\n\tiat: number;\n\tiss: string;\n\tjti?: string;\n\tlocale?: string;\n\tname: string;\n\tnbf?: number;\n\tpicture: string;\n\tsub: string;\n}\n\nexport interface GoogleOptions {\n\tclientId: string;\n\tclientSecret: string;\n\tredirectURI?: string;\n}\n\nexport const google = ({\n\tclientId,\n\tclientSecret,\n\tredirectURI,\n}: GoogleOptions) => {\n\tconst googleArctic = new Google(\n\t\tclientId,\n\t\tclientSecret,\n\t\tgetRedirectURI(\"google\", redirectURI),\n\t);\n\treturn {\n\t\tid: \"google\",\n\t\tname: \"Google\",\n\t\tcreateAuthorizationURL({ state, scopes, codeVerifier }) {\n\t\t\tif (!codeVerifier) {\n\t\t\t\tthrow new BetterAuthError(\"codeVerifier is required for Google\");\n\t\t\t}\n\t\t\tconst _scopes = scopes || [\"email\", \"profile\"];\n\t\t\treturn googleArctic.createAuthorizationURL(state, codeVerifier, _scopes);\n\t\t},\n\t\tvalidateAuthorizationCode: async (code, codeVerifier) => {\n\t\t\tif (!codeVerifier) {\n\t\t\t\tthrow new BetterAuthError(\"codeVerifier is required for Google\");\n\t\t\t}\n\t\t\treturn googleArctic.validateAuthorizationCode(code, codeVerifier);\n\t\t},\n\t\tasync getUserInfo(token) {\n\t\t\tif (!token.idToken) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst user = parseJWT(token.idToken())?.payload as GoogleProfile;\n\t\t\treturn {\n\t\t\t\tuser: {\n\t\t\t\t\tid: user.sub,\n\t\t\t\t\tname: user.name,\n\t\t\t\t\temail: user.email,\n\t\t\t\t\timage: user.picture,\n\t\t\t\t\temailVerified: user.email_verified,\n\t\t\t\t},\n\t\t\t\tdata: user,\n\t\t\t};\n\t\t},\n\t} satisfies OAuthProvider<GoogleProfile>;\n};\n","import { betterFetch } from \"@better-fetch/fetch\";\nimport { Spotify } from \"arctic\";\nimport type { OAuthProvider } from \".\";\nimport { getRedirectURI } from \"./utils\";\n\nexport interface SpotifyProfile {\n\tid: string;\n\tdisplay_name: string;\n\temail: string;\n\timages: {\n\t\turl: string;\n\t}[];\n}\n\nexport interface SpotifyOptions {\n\tclientId: string;\n\tclientSecret: string;\n\tredirectURI?: string;\n}\n\nexport const spotify = ({\n\tclientId,\n\tclientSecret,\n\tredirectURI,\n}: SpotifyOptions) => {\n\tconst spotifyArctic = new Spotify(\n\t\tclientId,\n\t\tclientSecret,\n\t\tgetRedirectURI(\"spotify\", redirectURI),\n\t);\n\treturn {\n\t\tid: \"spotify\",\n\t\tname: \"Spotify\",\n\t\tcreateAuthorizationURL({ state, scopes }) {\n\t\t\tconst _scopes = scopes || [\"user-read-email\"];\n\t\t\treturn spotifyArctic.createAuthorizationURL(state, _scopes);\n\t\t},\n\t\tvalidateAuthorizationCode: spotifyArctic.validateAuthorizationCode,\n\t\tasync getUserInfo(token) {\n\t\t\tconst { data: profile, error } = await betterFetch<SpotifyProfile>(\n\t\t\t\t\"https://api.spotify.com/v1/me\",\n\t\t\t\t{\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\theaders: {\n\t\t\t\t\t\tAuthorization: `Bearer ${token.accessToken}`,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t\tif (error) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tuser: {\n\t\t\t\t\tid: profile.id,\n\t\t\t\t\tname: profile.display_name,\n\t\t\t\t\temail: profile.email,\n\t\t\t\t\timage: profile.images[0]?.url,\n\t\t\t\t\temailVerified: false,\n\t\t\t\t},\n\t\t\t\tdata: profile,\n\t\t\t};\n\t\t},\n\t} satisfies OAuthProvider<SpotifyProfile>;\n};\n","import { betterFetch } from \"@better-fetch/fetch\";\nimport { Twitch } from \"arctic\";\nimport type { OAuthProvider } from \".\";\nimport { getRedirectURI } from \"./utils\";\n\nexport interface TwitchProfile {\n\t/**\n\t * The sub of the user\n\t */\n\tsub: string;\n\t/**\n\t * The preferred username of the user\n\t */\n\tpreferred_username: string;\n\t/**\n\t * The email of the user\n\t */\n\temail: string;\n\t/**\n\t * The picture of the user\n\t */\n\tpicture: string;\n}\n\nexport interface TwitchOptions {\n\tclientId: string;\n\tclientSecret: string;\n\tredirectURI?: string;\n}\n\nexport const twitch = ({\n\tclientId,\n\tclientSecret,\n\tredirectURI,\n}: TwitchOptions) => {\n\tconst twitchArctic = new Twitch(\n\t\tclientId,\n\t\tclientSecret,\n\t\tgetRedirectURI(\"twitch\", redirectURI),\n\t);\n\treturn {\n\t\tid: \"twitch\",\n\t\tname: \"Twitch\",\n\t\tcreateAuthorizationURL({ state, scopes }) {\n\t\t\tconst _scopes = scopes || [\"activity:write\", \"read\"];\n\t\t\treturn twitchArctic.createAuthorizationURL(state, _scopes);\n\t\t},\n\t\tvalidateAuthorizationCode: twitchArctic.validateAuthorizationCode,\n\t\tasync getUserInfo(token) {\n\t\t\tconst { data: profile, error } = await betterFetch<TwitchProfile>(\n\t\t\t\t\"https://api.twitch.tv/helix/users\",\n\t\t\t\t{\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\theaders: {\n\t\t\t\t\t\tAuthorization: `Bearer ${token.accessToken}`,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t\tif (error) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tuser: {\n\t\t\t\t\tid: profile.sub,\n\t\t\t\t\tname: profile.preferred_username,\n\t\t\t\t\temail: profile.email,\n\t\t\t\t\timage: profile.picture,\n\t\t\t\t\temailVerified: false,\n\t\t\t\t},\n\t\t\t\tdata: profile,\n\t\t\t};\n\t\t},\n\t} satisfies OAuthProvider<TwitchProfile>;\n};\n","import { betterFetch } from \"@better-fetch/fetch\";\nimport { Twitter } from \"arctic\";\nimport type { OAuthProvider } from \".\";\nimport { getRedirectURI } from \"./utils\";\nimport { BetterAuthError } from \"../error/better-auth-error\";\n\nexport interface TwitterProfile {\n\tdata: {\n\t\t/**\n\t\t * Unique identifier of this user. This is returned as a string in order to avoid complications with languages and tools\n\t\t * that cannot handle large integers.\n\t\t */\n\t\tid: string;\n\t\t/** The friendly name of this user, as shown on their profile. */\n\t\tname: string;\n\t\t/** @note Email is currently unsupported by Twitter. */\n\t\temail?: string;\n\t\t/** The Twitter handle (screen name) of this user. */\n\t\tusername: string;\n\t\t/**\n\t\t * The location specified in the user's profile, if the user provided one.\n\t\t * As this is a freeform value, it may not indicate a valid location, but it may be fuzzily evaluated when performing searches with location queries.\n\t\t *\n\t\t * To return this field, add `user.fields=location` in the authorization request's query parameter.\n\t\t */\n\t\tlocation?: string;\n\t\t/**\n\t\t * This object and its children fields contain details about text that has a special meaning in the user's description.\n\t\t *\n\t\t *To return this field, add `user.fields=entities` in the authorization request's query parameter.\n\t\t */\n\t\tentities?: {\n\t\t\t/** Contains details about the user's profile website. */\n\t\t\turl: {\n\t\t\t\t/** Contains details about the user's profile website. */\n\t\t\t\turls: Array<{\n\t\t\t\t\t/** The start position (zero-based) of the recognized user's profile website. All start indices are inclusive. */\n\t\t\t\t\tstart: number;\n\t\t\t\t\t/** The end position (zero-based) of the recognized user's profile website. This end index is exclusive. */\n\t\t\t\t\tend: number;\n\t\t\t\t\t/** The URL in the format entered by the user. */\n\t\t\t\t\turl: string;\n\t\t\t\t\t/** The fully resolved URL. */\n\t\t\t\t\texpanded_url: string;\n\t\t\t\t\t/** The URL as displayed in the user's profile. */\n\t\t\t\t\tdisplay_url: string;\n\t\t\t\t}>;\n\t\t\t};\n\t\t\t/** Contains details about URLs, Hashtags, Cashtags, or mentions located within a user's description. */\n\t\t\tdescription: {\n\t\t\t\thashtags: Array<{\n\t\t\t\t\tstart: number;\n\t\t\t\t\tend: number;\n\t\t\t\t\ttag: string;\n\t\t\t\t}>;\n\t\t\t};\n\t\t};\n\t\t/**\n\t\t * Indicate if this user is a verified Twitter user.\n\t\t *\n\t\t * To return this field, add `user.fields=verified` in the authorization request's query parameter.\n\t\t */\n\t\tverified?: boolean;\n\t\t/**\n\t\t * The text of this user's profile description (also known as bio), if the user provided one.\n\t\t *\n\t\t * To return this field, add `user.fields=description` in the authorization request's query parameter.\n\t\t */\n\t\tdescription?: string;\n\t\t/**\n\t\t * The URL specified in the user's profile, if present.\n\t\t *\n\t\t * To return this field, add `user.fields=url` in the authorization request's query parameter.\n\t\t */\n\t\turl?: string;\n\t\t/** The URL to the profile image for this user, as shown on the user's profile. */\n\t\tprofile_image_url?: string;\n\t\tprotected?: boolean;\n\t\t/**\n\t\t * Unique identifier of this user's pinned Tweet.\n\t\t *\n\t\t * You can obtain the expanded object in `includes.tweets` by adding `expansions=pinned_tweet_id` in the authorization request's query parameter.\n\t\t */\n\t\tpinned_tweet_id?: string;\n\t\tcreated_at?: string;\n\t};\n\tincludes?: {\n\t\ttweets?: Array<{\n\t\t\tid: string;\n\t\t\ttext: string;\n\t\t}>;\n\t};\n\t[claims: string]: unknown;\n}\n\nexport interface TwitterOption {\n\tclientId: string;\n\tclientSecret: string;\n\tredirectURI?: string;\n}\n\nexport const twitter = ({\n\tclientId,\n\tclientSecret,\n\tredirectURI,\n}: TwitterOption) => {\n\tconst twitterArctic = new Twitter(\n\t\tclientId,\n\t\tclientSecret,\n\t\tgetRedirectURI(\"twitter\", redirectURI),\n\t);\n\treturn {\n\t\tid: \"twitter\",\n\t\tname: \"Twitter\",\n\t\tcreateAuthorizationURL(data) {\n\t\t\tconst _scopes = data.scopes || [\"account_info.read\"];\n\t\t\treturn twitterArctic.createAuthorizationURL(\n\t\t\t\tdata.state,\n\t\t\t\tdata.codeVerifier,\n\t\t\t\t_scopes,\n\t\t\t);\n\t\t},\n\t\tvalidateAuthorizationCode: async (code, codeVerifier) => {\n\t\t\tif (!codeVerifier) {\n\t\t\t\tthrow new BetterAuthError(\"codeVerifier is required for Twitter\");\n\t\t\t}\n\t\t\treturn twitterArctic.validateAuthorizationCode(code, codeVerifier);\n\t\t},\n\t\tasync getUserInfo(token) {\n\t\t\tconst { data: profile, error } = await betterFetch<TwitterProfile>(\n\t\t\t\t\"https://api.x.com/2/users/me?user.fields=profile_image_url\",\n\t\t\t\t{\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\theaders: {\n\t\t\t\t\t\tAuthorization: `Bearer ${token.accessToken}`,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t\tif (error) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tif (!profile.data.email) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tuser: {\n\t\t\t\t\tid: profile.data.id,\n\t\t\t\t\tname: profile.data.name,\n\t\t\t\t\temail: profile.data.email,\n\t\t\t\t\timage: profile.data.profile_image_url,\n\t\t\t\t\temailVerified: profile.data.verified || false,\n\t\t\t\t},\n\t\t\t\tdata: profile,\n\t\t\t};\n\t\t},\n\t} satisfies OAuthProvider<TwitterProfile>;\n};\n","import type { User } from \"../adapters/schema\";\nimport type { oAuthProviderList } from \"../social-providers\";\nimport type { LiteralString } from \"./helper\";\nimport { OAuth2Tokens } from \"arctic\";\n\nexport interface OAuthProvider<\n\tT extends Record<string, any> = Record<string, any>,\n> {\n\tid: LiteralString;\n\tcreateAuthorizationURL: (data: {\n\t\tstate: string;\n\t\tcodeVerifier: string;\n\t\tscopes?: string[];\n\t}) => URL;\n\tname: string;\n\tvalidateAuthorizationCode: (\n\t\tcode: string,\n\t\tcodeVerifier?: string,\n\t) => Promise<OAuth2Tokens>;\n\tgetUserInfo: (token: OAuth2Tokens) => Promise<{\n\t\tuser: Omit<User, \"createdAt\" | \"updatedAt\">;\n\t\tdata: T;\n\t} | null>;\n\trefreshAccessToken?: (refreshToken: string) => Promise<OAuth2Tokens>;\n\trevokeToken?: (token: string) => Promise<void>;\n}\n\nexport type OAuthProviderList = typeof oAuthProviderList;\n","import { apple } from \"./apple\";\nimport { discord } from \"./discord\";\nimport { facebook } from \"./facebook\";\nimport { github } from \"./github\";\nimport { google } from \"./google\";\nimport { spotify } from \"./spotify\";\nimport { twitch } from \"./twitch\";\nimport { twitter } from \"./twitter\";\n\nexport const oAuthProviders = {\n\tapple,\n\tdiscord,\n\tfacebook,\n\tgithub,\n\tgoogle,\n\tspotify,\n\ttwitch,\n\ttwitter,\n};\n\nexport const oAuthProviderList = Object.keys(oAuthProviders) as [\n\t\"github\",\n\t...(keyof typeof oAuthProviders)[],\n];\n\nexport * from \"./github\";\nexport * from \"./google\";\nexport * from \"./apple\";\nexport * from \"./discord\";\nexport * from \"./spotify\";\nexport * from \"./twitch\";\nexport * from \"./facebook\";\nexport * from \"./twitter\";\nexport * from \"../types/provider\";\n","import { generateState as generateStateOAuth } from \"oslo/oauth2\";\n\nexport function generateState(callbackURL?: string, currentURL?: string) {\n\tconst code = generateStateOAuth();\n\tconst state = `${code}!${callbackURL}!${currentURL}`;\n\treturn { state, code };\n}\n\nexport function parseState(state: string) {\n\tconst [code, callbackURL, currentURL] = state.split(\"!\");\n\treturn { code, callbackURL, currentURL };\n}\n","import type { Context } from \"better-call\";\nimport { createAuthEndpoint } from \"../call\";\n\nexport const getSession = createAuthEndpoint(\n\t\"/session\",\n\t{\n\t\tmethod: \"GET\",\n\t\trequireHeaders: true,\n\t},\n\tasync (ctx) => {\n\t\tconst sessionCookieToken = await ctx.getSignedCookie(\n\t\t\tctx.context.authCookies.sessionToken.name,\n\t\t\tctx.context.secret,\n\t\t);\n\t\tif (!sessionCookieToken) {\n\t\t\treturn ctx.json(null, {\n\t\t\t\tstatus: 401,\n\t\t\t});\n\t\t}\n\t\tconst session =\n\t\t\tawait ctx.context.internalAdapter.findSession(sessionCookieToken);\n\t\tif (!session || session.session.expiresAt < new Date()) {\n\t\t\tctx.setSignedCookie(\n\t\t\t\tctx.context.authCookies.sessionToken.name,\n\t\t\t\t\"\",\n\t\t\t\tctx.context.secret,\n\t\t\t\t{\n\t\t\t\t\tmaxAge: 0,\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn ctx.json(null, {\n\t\t\t\tstatus: 401,\n\t\t\t});\n\t\t}\n\t\tconst updatedSession = await ctx.context.internalAdapter.updateSession(\n\t\t\tsession.session,\n\t\t);\n\n\t\tawait ctx.setSignedCookie(\n\t\t\tctx.context.authCookies.sessionToken.name,\n\t\t\tupdatedSession.id,\n\t\t\tctx.context.secret,\n\t\t\t{\n\t\t\t\t...ctx.context.authCookies.sessionToken.options,\n\t\t\t\tmaxAge: updatedSession.expiresAt.valueOf() - Date.now(),\n\t\t\t},\n\t\t);\n\t\treturn ctx.json({\n\t\t\tsession: updatedSession,\n\t\t\tuser: session.user,\n\t\t});\n\t},\n);\n\nexport const getSessionFromCtx = async (ctx: Context<any, any>) => {\n\tconst session = await getSession({\n\t\t...ctx,\n\t\t//@ts-expect-error: By default since this request context comes from a router it'll have a `router` flag which force it to be a request object\n\t\t_flag: undefined,\n\t});\n\treturn session;\n};\n","import { APIError } from \"better-call\";\nimport { z } from \"zod\";\nimport { userSchema } from \"../../adapters/schema\";\nimport { HIDE_ON_CLIENT_METADATA } from \"../../client/client-utils\";\nimport { generateId } from \"../../utils/id\";\nimport { parseState } from \"../../utils/state\";\nimport { createAuthEndpoint } from \"../call\";\n\nexport const callbackOAuth = createAuthEndpoint(\n\t\"/callback/:id\",\n\t{\n\t\tmethod: \"GET\",\n\t\tquery: z.object({\n\t\t\tstate: z.string(),\n\t\t\tcode: z.string(),\n\t\t\tcode_verifier: z.string().optional(),\n\t\t}),\n\t\tmetadata: HIDE_ON_CLIENT_METADATA,\n\t},\n\tasync (c) => {\n\t\tconst provider = c.context.options.socialProvider?.find(\n\t\t\t(p) => p.id === c.params.id,\n\t\t);\n\t\tif (!provider) {\n\t\t\tc.context.logger.error(\n\t\t\t\t\"Oauth provider with id\",\n\t\t\t\tc.params.id,\n\t\t\t\t\"not found\",\n\t\t\t);\n\t\t\tthrow new APIError(\"NOT_FOUND\");\n\t\t}\n\t\tconst tokens = await provider.validateAuthorizationCode(\n\t\t\tc.query.code,\n\t\t\tc.query.code_verifier || \"\",\n\t\t);\n\t\tif (!tokens) {\n\t\t\tc.context.logger.error(\"Code verification failed\");\n\t\t\tthrow new APIError(\"UNAUTHORIZED\");\n\t\t}\n\t\tconst user = await provider.getUserInfo(tokens).then((res) => res?.user);\n\t\tconst id = generateId();\n\t\tconst data = userSchema.safeParse({\n\t\t\t...user,\n\t\t\tid,\n\t\t});\n\t\tconst { callbackURL, currentURL } = parseState(c.query.state);\n\t\tif (!user || data.success === false) {\n\t\t\tif (currentURL) {\n\t\t\t\tthrow c.redirect(`${currentURL}?error=oauth_validation_failed`);\n\t\t\t} else {\n\t\t\t\tthrow new APIError(\"BAD_REQUEST\");\n\t\t\t}\n\t\t}\n\t\tif (!callbackURL) {\n\t\t\tc.context.logger.error(\"Callback URL not found\");\n\t\t\tthrow new APIError(\"FORBIDDEN\");\n\t\t}\n\t\t//find user in db\n\t\tconst dbUser = await c.context.internalAdapter.findUserByEmail(user.email);\n\t\tconst userId = dbUser?.user.id;\n\t\tif (dbUser) {\n\t\t\t//check if user has already linked this provider\n\t\t\tconst hasBeenLinked = dbUser.accounts.find(\n\t\t\t\t(a) => a.providerId === provider.id,\n\t\t\t);\n\t\t\tif (!hasBeenLinked && !user.emailVerified) {\n\t\t\t\tc.context.logger.error(\"User already exists\");\n\t\t\t\tconst url = new URL(currentURL || callbackURL);\n\t\t\t\turl.searchParams.set(\"error\", \"user_already_exists\");\n\t\t\t\tthrow c.redirect(url.toString());\n\t\t\t}\n\n\t\t\tif (!hasBeenLinked && user.emailVerified) {\n\t\t\t\tawait c.context.internalAdapter.linkAccount({\n\t\t\t\t\tproviderId: provider.id,\n\t\t\t\t\taccountId: user.id,\n\t\t\t\t\tid: `${provider.id}:${user.id}`,\n\t\t\t\t\tuserId: dbUser.user.id,\n\t\t\t\t\t...tokens,\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tawait c.context.internalAdapter.createOAuthUser(data.data, {\n\t\t\t\t\t...tokens,\n\t\t\t\t\tid: `${provider.id}:${user.id}`,\n\t\t\t\t\tproviderId: provider.id,\n\t\t\t\t\taccountId: user.id,\n\t\t\t\t\tuserId: id,\n\t\t\t\t});\n\t\t\t} catch (e) {\n\t\t\t\tconst url = new URL(currentURL || callbackURL);\n\t\t\t\turl.searchParams.set(\"error\", \"unable_to_create_user\");\n\t\t\t\tc.setHeader(\"Location\", url.toString());\n\t\t\t\tthrow c.redirect(url.toString());\n\t\t\t}\n\t\t}\n\t\t//this should never happen\n\t\tif (!userId && !id)\n\t\t\tthrow new APIError(\"INTERNAL_SERVER_ERROR\", {\n\t\t\t\tmessage: \"Unable to create user\",\n\t\t\t});\n\t\t//create session\n\t\tconst session = await c.context.internalAdapter.createSession(\n\t\t\tuserId || id,\n\t\t\tc.request,\n\t\t);\n\t\ttry {\n\t\t\tawait c.setSignedCookie(\n\t\t\t\tc.context.authCookies.sessionToken.name,\n\t\t\t\tsession.id,\n\t\t\t\tc.context.secret,\n\t\t\t\tc.context.authCookies.sessionToken.options,\n\t\t\t);\n\t\t} catch (e) {\n\t\t\tc.context.logger.error(\"Unable to set session cookie\", e);\n\t\t\tconst url = new URL(currentURL || callbackURL);\n\t\t\turl.searchParams.set(\"error\", \"unable_to_create_session\");\n\t\t\tthrow c.redirect(url.toString());\n\t\t}\n\t\tthrow c.redirect(callbackURL);\n\t},\n);\n","export const HIDE_ON_CLIENT_METADATA = {\n\tonClient: \"hide\" as const,\n};\n","import { alphabet, generateRandomString } from \"oslo/crypto\";\nexport const generateId = () => {\n\treturn generateRandomString(36, alphabet(\"a-z\", \"0-9\"));\n};\n","import { z } from \"zod\";\nimport { createAuthEndpoint } from \"../call\";\n\nexport const signOut = createAuthEndpoint(\n\t\"/sign-out\",\n\t{\n\t\tmethod: \"POST\",\n\t\tbody: z\n\t\t\t.object({\n\t\t\t\tcallbackURL: z.string().optional(),\n\t\t\t})\n\t\t\t.optional(),\n\t},\n\tasync (ctx) => {\n\t\tconst sessionCookieToken = await ctx.getSignedCookie(\n\t\t\tctx.context.authCookies.sessionToken.name,\n\t\t\tctx.context.secret,\n\t\t);\n\t\tif (!sessionCookieToken) {\n\t\t\treturn ctx.json(null);\n\t\t}\n\t\tawait ctx.context.internalAdapter.deleteSession(sessionCookieToken);\n\t\tctx.setCookie(ctx.context.authCookies.sessionToken.name, \"\", {\n\t\t\tmaxAge: 0,\n\t\t});\n\t\treturn ctx.json(null, {\n\t\t\tbody: {\n\t\t\t\tredirect: !!ctx.body?.callbackURL,\n\t\t\t\turl: ctx.body?.callbackURL,\n\t\t\t},\n\t\t});\n\t},\n);\n","import { TimeSpan } from \"oslo\";\nimport { createJWT } from \"oslo/jwt\";\nimport { validateJWT } from \"oslo/jwt\";\nimport { Argon2id } from \"oslo/password\";\nimport { z } from \"zod\";\nimport { createAuthEndpoint } from \"../call\";\n\nexport const forgetPassword = createAuthEndpoint(\n\t\"/forget-password\",\n\t{\n\t\tmethod: \"POST\",\n\t\tbody: z.object({\n\t\t\t/**\n\t\t\t * The email address of the user to send a password reset email to.\n\t\t\t */\n\t\t\temail: z.string().email(),\n\t\t}),\n\t},\n\tasync (ctx) => {\n\t\tif (!ctx.context.options.emailAndPassword?.sendResetPasswordToken) {\n\t\t\tctx.context.logger.error(\n\t\t\t\t\"Reset password isn't enabled.Please pass an emailAndPassword.sendResetPasswordToken function to your auth config!\",\n\t\t\t);\n\t\t\treturn ctx.json(null, {\n\t\t\t\tstatus: 400,\n\t\t\t\tstatusText: \"RESET_PASSWORD_EMAIL_NOT_SENT\",\n\t\t\t\tbody: {\n\t\t\t\t\tmessage: \"Reset password isn't enabled\",\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t\tconst { email } = ctx.body;\n\t\tconst user = await ctx.context.internalAdapter.findUserByEmail(email);\n\t\tif (!user) {\n\t\t\treturn ctx.json(\n\t\t\t\t{\n\t\t\t\t\terror: \"User not found\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tstatus: 400,\n\t\t\t\t\tstatusText: \"USER_NOT_FOUND\",\n\t\t\t\t\tbody: {\n\t\t\t\t\t\tmessage: \"User not found\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t\tconst token = await createJWT(\n\t\t\t\"HS256\",\n\t\t\tBuffer.from(ctx.context.secret),\n\t\t\t{\n\t\t\t\temail: user.user.email,\n\t\t\t},\n\t\t\t{\n\t\t\t\texpiresIn: new TimeSpan(1, \"h\"),\n\t\t\t\tissuer: \"better-auth\",\n\t\t\t\tsubject: \"forget-password\",\n\t\t\t\taudiences: [user.user.email],\n\t\t\t\tincludeIssuedTimestamp: true,\n\t\t\t},\n\t\t);\n\t\tawait ctx.context.options.emailAndPassword.sendResetPasswordToken(\n\t\t\ttoken,\n\t\t\tuser.user,\n\t\t);\n\t\treturn ctx.json({\n\t\t\tstatus: true,\n\t\t});\n\t},\n);\n\nexport const resetPassword = createAuthEndpoint(\n\t\"/reset-password\",\n\t{\n\t\tmethod: \"POST\",\n\t\tbody: z.object({\n\t\t\ttoken: z.string(),\n\t\t\tnewPassword: z.string(),\n\t\t\tcallbackURL: z.string().optional(),\n\t\t}),\n\t},\n\tasync (ctx) => {\n\t\tconst { token, newPassword } = ctx.body;\n\t\ttry {\n\t\t\tconst jwt = await validateJWT(\n\t\t\t\t\"HS256\",\n\t\t\t\tBuffer.from(ctx.context.secret),\n\t\t\t\ttoken,\n\t\t\t);\n\t\t\tconst email = z\n\t\t\t\t.string()\n\t\t\t\t.email()\n\t\t\t\t.parse((jwt.payload as { email: string }).email);\n\t\t\tconst user = await ctx.context.internalAdapter.findUserByEmail(email);\n\t\t\tif (!user) {\n\t\t\t\treturn ctx.json(null, {\n\t\t\t\t\tstatus: 400,\n\t\t\t\t\tstatusText: \"USER_NOT_FOUND\",\n\t\t\t\t\tbody: {\n\t\t\t\t\t\tmessage: \"User not found\",\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (\n\t\t\t\tnewPassword.length <\n\t\t\t\t\t(ctx.context.options.emailAndPassword?.minPasswordLength || 8) ||\n\t\t\t\tnewPassword.length >\n\t\t\t\t\t(ctx.context.options.emailAndPassword?.maxPasswordLength || 32)\n\t\t\t) {\n\t\t\t\treturn ctx.json(null, {\n\t\t\t\t\tstatus: 400,\n\t\t\t\t\tstatusText: \"INVALID_PASSWORD_LENGTH\",\n\t\t\t\t\tbody: {\n\t\t\t\t\t\tmessage: \"Password length must be between 8 and 32\",\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst argon2id = new Argon2id();\n\t\t\tconst hashedPassword = await argon2id.hash(newPassword);\n\t\t\tconst updatedUser = await ctx.context.internalAdapter.updatePassword(\n\t\t\t\tuser.user.id,\n\t\t\t\thashedPassword,\n\t\t\t);\n\t\t\tif (!updatedUser) {\n\t\t\t\treturn ctx.json(null, {\n\t\t\t\t\tstatus: 500,\n\t\t\t\t\tstatusText: \"INTERNAL_SERVER_ERROR\",\n\t\t\t\t\tbody: {\n\t\t\t\t\t\tmessage: \"Internal server error\",\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn ctx.json({\n\t\t\t\tstatus: true,\n\t\t\t\turl: ctx.body.callbackURL,\n\t\t\t\tredirect: !!ctx.body.callbackURL,\n\t\t\t});\n\t\t} catch (e) {\n\t\t\tconsole.log(e);\n\t\t\treturn ctx.json(null, {\n\t\t\t\tstatus: 400,\n\t\t\t\tstatusText: \"INVALID_TOKEN\",\n\t\t\t\tbody: {\n\t\t\t\t\tmessage: \"Invalid token\",\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t},\n);\n","import { TimeSpan } from \"oslo\";\nimport { createJWT, validateJWT } from \"oslo/jwt\";\nimport { z } from \"zod\";\nimport { createAuthEndpoint } from \"../call\";\n\nexport const sendVerificationEmail = createAuthEndpoint(\n\t\"/send-verification-email\",\n\t{\n\t\tmethod: \"POST\",\n\t\tbody: z.object({\n\t\t\temail: z.string().email(),\n\t\t\tcallbackURL: z.string().optional(),\n\t\t}),\n\t},\n\tasync (ctx) => {\n\t\tif (!ctx.context.options.emailAndPassword?.sendVerificationEmail) {\n\t\t\treturn ctx.json(null, {\n\t\t\t\tstatus: 400,\n\t\t\t\tstatusText: \"VERIFICATION_EMAIL_NOT_SENT\",\n\t\t\t\tbody: {\n\t\t\t\t\tmessage: \"Verification email isn't enabled\",\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t\tconst { email } = ctx.body;\n\t\tconst token = await createJWT(\n\t\t\t\"HS256\",\n\t\t\tBuffer.from(ctx.context.secret),\n\t\t\t{\n\t\t\t\temail: email.toLowerCase(),\n\t\t\t},\n\t\t\t{\n\t\t\t\texpiresIn: new TimeSpan(1, \"h\"),\n\t\t\t\tissuer: \"better-auth\",\n\t\t\t\tsubject: \"verify-email\",\n\t\t\t\taudiences: [email],\n\t\t\t\tincludeIssuedTimestamp: true,\n\t\t\t},\n\t\t);\n\t\tconst url = `${ctx.context.baseURL}/verify-email?token=${token}?callbackURL=${ctx.body.callbackURL}`;\n\t\tawait ctx.context.options.emailAndPassword.sendVerificationEmail(\n\t\t\temail,\n\t\t\turl,\n\t\t);\n\t\treturn ctx.json({\n\t\t\tstatus: true,\n\t\t});\n\t},\n);\n\nexport const verifyEmail = createAuthEndpoint(\n\t\"/verify-email\",\n\t{\n\t\tmethod: \"GET\",\n\t\tquery: z.object({\n\t\t\ttoken: z.string(),\n\t\t\tcallbackURL: z.string(),\n\t\t}),\n\t},\n\tasync (ctx) => {\n\t\tconst { token } = ctx.query;\n\t\ttry {\n\t\t\tconst jwt = await validateJWT(\n\t\t\t\t\"HS256\",\n\t\t\t\tBuffer.from(ctx.context.secret),\n\t\t\t\ttoken,\n\t\t\t);\n\t\t\tconst schema = z.object({\n\t\t\t\temail: z.string().email(),\n\t\t\t});\n\t\t\tconst parsed = schema.parse(jwt.payload);\n\t\t\tconst user = await ctx.context.internalAdapter.findUserByEmail(\n\t\t\t\tparsed.email,\n\t\t\t);\n\t\t\tif (!user) {\n\t\t\t\treturn ctx.json(null, {\n\t\t\t\t\tstatus: 400,\n\t\t\t\t\tstatusText: \"USER_NOT_FOUND\",\n\t\t\t\t\tbody: {\n\t\t\t\t\t\tmessage: \"User not found\",\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst account = user.accounts.find((a) => a.providerId === \"credential\");\n\t\t\tif (!account) {\n\t\t\t\treturn ctx.json(null, {\n\t\t\t\t\tstatus: 400,\n\t\t\t\t\tstatusText: \"ACCOUNT_NOT_FOUND\",\n\t\t\t\t\tbody: {\n\t\t\t\t\t\tmessage: \"Account not found\",\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t\tawait ctx.context.internalAdapter.updateUserByEmail(parsed.email, {\n\t\t\t\temailVerified: true,\n\t\t\t});\n\t\t\tif (ctx.query.callbackURL) {\n\t\t\t\tthrow ctx.redirect(ctx.query.callbackURL);\n\t\t\t}\n\t\t\treturn ctx.json({\n\t\t\t\tstatus: true,\n\t\t\t});\n\t\t} catch (e) {\n\t\t\treturn ctx.json(null, {\n\t\t\t\tstatus: 400,\n\t\t\t\tstatusText: \"INVALID_TOKEN\",\n\t\t\t\tbody: {\n\t\t\t\t\tmessage: \"Invalid token\",\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t},\n);\n","import { alphabet, generateRandomString } from \"oslo/crypto\";\nimport { HIDE_ON_CLIENT_METADATA } from \"../../client/client-utils\";\nimport { hs256 } from \"../../crypto\";\nimport { createAuthEndpoint } from \"../call\";\n\nexport const getCSRFToken = createAuthEndpoint(\n\t\"/csrf\",\n\t{\n\t\tmethod: \"GET\",\n\t\tmetadata: HIDE_ON_CLIENT_METADATA,\n\t},\n\tasync (ctx) => {\n\t\tconst csrfToken = await ctx.getSignedCookie(\n\t\t\tctx.context.authCookies.csrfToken.name,\n\t\t\tctx.context.secret,\n\t\t);\n\t\tif (csrfToken) {\n\t\t\treturn {\n\t\t\t\tcsrfToken,\n\t\t\t};\n\t\t}\n\t\tconst token = generateRandomString(32, alphabet(\"a-z\", \"0-9\", \"A-Z\"));\n\t\tconst hash = await hs256(ctx.context.secret, token);\n\t\tconst cookie = `${token}!${hash}`;\n\t\tawait ctx.setSignedCookie(\n\t\t\tctx.context.authCookies.csrfToken.name,\n\t\t\tcookie,\n\t\t\tctx.context.secret,\n\t\t\tctx.context.authCookies.csrfToken.options,\n\t\t);\n\t\treturn {\n\t\t\tcsrfToken: token,\n\t\t};\n\t},\n);\n","import { createAuthEndpoint } from \"../call\";\n\nexport const ok = createAuthEndpoint(\n\t\"/ok\",\n\t{\n\t\tmethod: \"GET\",\n\t},\n\tasync (ctx) => {\n\t\treturn ctx.json({\n\t\t\tok: true,\n\t\t});\n\t},\n);\n\nexport const welcome = createAuthEndpoint(\n\t\"/welcome/ok\",\n\t{\n\t\tmethod: \"GET\",\n\t},\n\tasync () => {\n\t\treturn new Response(\"Welcome to Better Auth\");\n\t},\n);\n","import { alphabet, generateRandomString } from \"oslo/crypto\";\nimport { Argon2id } from \"oslo/password\";\nimport { z } from \"zod\";\nimport { createAuthEndpoint } from \"../call\";\n\nexport const signUpEmail = createAuthEndpoint(\n\t\"/sign-up/email\",\n\t{\n\t\tmethod: \"POST\",\n\t\tbody: z.object({\n\t\t\tname: z.string(),\n\t\t\temail: z.string().email(),\n\t\t\tpassword: z.string(),\n\t\t\timage: z.string().optional(),\n\t\t\tcallbackURL: z.string().optional(),\n\t\t}),\n\t},\n\tasync (ctx) => {\n\t\tif (!ctx.context.options.emailAndPassword?.enabled) {\n\t\t\treturn ctx.json(null, {\n\t\t\t\tstatus: 400,\n\t\t\t\tbody: {\n\t\t\t\t\tmessage: \"Email and password is not enabled\",\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t\tconst { name, email, password, image } = ctx.body;\n\t\tconst minPasswordLength =\n\t\t\tctx.context.options?.emailAndPassword?.minPasswordLength || 8;\n\t\tif (password.length < minPasswordLength) {\n\t\t\tctx.context.logger.error(\"Password is too short\");\n\t\t\treturn ctx.json(null, {\n\t\t\t\tstatus: 400,\n\t\t\t\tbody: { message: \"Password is too short\" },\n\t\t\t});\n\t\t}\n\t\tconst argon2id = new Argon2id();\n\t\tconst dbUser = await ctx.context.internalAdapter.findUserByEmail(email);\n\t\t/**\n\t\t * hash first to avoid timing attacks\n\t\t */\n\t\tconst hash = await argon2id.hash(password);\n\t\tif (dbUser?.user) {\n\t\t\treturn ctx.json(null, {\n\t\t\t\tstatus: 400,\n\t\t\t\tbody: {\n\t\t\t\t\tmessage: \"User already exists\",\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t\tconst createdUser = await ctx.context.internalAdapter.createUser({\n\t\t\tid: generateRandomString(32, alphabet(\"a-z\", \"0-9\", \"A-Z\")),\n\t\t\temail: email.toLowerCase(),\n\t\t\tname,\n\t\t\timage,\n\t\t\temailVerified: false,\n\t\t\tcreatedAt: new Date(),\n\t\t\tupdatedAt: new Date(),\n\t\t});\n\t\t/**\n\t\t * Link the account to the user\n\t\t */\n\t\tawait ctx.context.internalAdapter.linkAccount({\n\t\t\tid: generateRandomString(32, alphabet(\"a-z\", \"0-9\", \"A-Z\")),\n\t\t\tuserId: createdUser.id,\n\t\t\tproviderId: \"credential\",\n\t\t\taccountId: createdUser.id,\n\t\t\tpassword: hash,\n\t\t});\n\t\tconst session = await ctx.context.internalAdapter.createSession(\n\t\t\tcreatedUser.id,\n\t\t\tctx.request,\n\t\t);\n\t\tawait ctx.setSignedCookie(\n\t\t\tctx.context.authCookies.sessionToken.name,\n\t\t\tsession.id,\n\t\t\tctx.context.secret,\n\t\t\tctx.context.authCookies.sessionToken.options,\n\t\t);\n\t\treturn ctx.json(\n\t\t\t{\n\t\t\t\tuser: createdUser,\n\t\t\t\tsession,\n\t\t\t},\n\t\t\t{\n\t\t\t\tbody: ctx.body.callbackURL\n\t\t\t\t\t? {\n\t\t\t\t\t\t\turl: ctx.body.callbackURL,\n\t\t\t\t\t\t\tredirect: true,\n\t\t\t\t\t\t}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tuser: createdUser,\n\t\t\t\t\t\t\tsession,\n\t\t\t\t\t\t},\n\t\t\t},\n\t\t);\n\t},\n);\n","import { createAuthEndpoint } from \"../call\";\n\nconst html = (errorCode: string = \"Unknown\") => `<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>Authentication Error</title>\n <style>\n :root {\n --bg-color: #f8f9fa;\n --text-color: #212529;\n --accent-color: #000000;\n --error-color: #dc3545;\n --border-color: #e9ecef;\n }\n body {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n background-color: var(--bg-color);\n color: var(--text-color);\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100vh;\n margin: 0;\n line-height: 1.5;\n }\n .error-container {\n background-color: #ffffff;\n border-radius: 12px;\n box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);\n padding: 2.5rem;\n text-align: center;\n max-width: 90%;\n width: 400px;\n }\n h1 {\n color: var(--error-color);\n font-size: 1.75rem;\n margin-bottom: 1rem;\n font-weight: 600;\n }\n p {\n margin-bottom: 1.5rem;\n color: #495057;\n }\n .btn {\n background-color: var(--accent-color);\n color: #ffffff;\n text-decoration: none;\n padding: 0.75rem 1.5rem;\n border-radius: 6px;\n transition: all 0.3s ease;\n display: inline-block;\n font-weight: 500;\n border: 2px solid var(--accent-color);\n }\n .btn:hover {\n background-color: #131721;\n }\n .error-code {\n font-size: 0.875rem;\n color: #6c757d;\n margin-top: 1.5rem;\n padding-top: 1.5rem;\n border-top: 1px solid var(--border-color);\n }\n .icon {\n font-size: 3rem;\n margin-bottom: 1rem;\n }\n </style>\n</head>\n<body>\n <div class=\"error-container\">\n <div class=\"icon\">⚠️</div>\n <h1>Better Auth Error</h1>\n <p>We encountered an issue while processing your request. Please try again or contact the application owner if the problem persists.</p>\n <a href=\"#\" id=\"returnLink\" class=\"btn\">Return to Application</a>\n <div class=\"error-code\">Error Code: <span id=\"errorCode\">${errorCode}</span></div>\n </div>\n</body>\n</html>`;\n\nexport const error = createAuthEndpoint(\n\t\"/error\",\n\t{\n\t\tmethod: \"GET\",\n\t},\n\tasync (c) => {\n\t\tconst query =\n\t\t\tnew URL(c.request?.url || \"\").searchParams.get(\"error\") || \"Unknown\";\n\t\treturn new Response(html(query), {\n\t\t\theaders: {\n\t\t\t\t\"Content-Type\": \"text/html\",\n\t\t\t},\n\t\t});\n\t},\n);\n","import Database from \"better-sqlite3\";\nimport { Kysely } from \"kysely\";\nimport {\n\ttype Dialect,\n\tMysqlDialect,\n\tPostgresDialect,\n\tSqliteDialect,\n} from \"kysely\";\nimport { createPool } from \"mysql2\";\nimport pg from \"pg\";\nimport type { FieldAttribute } from \"../db\";\nimport type { BetterAuthOptions } from \"../types\";\nimport type { Adapter, Where } from \"../types/adapter\";\n\nconst { Pool } = pg;\n\nfunction convertWhere(w?: Where[]) {\n\tif (!w)\n\t\treturn {\n\t\t\tand: null,\n\t\t\tor: null,\n\t\t};\n\tconst and = w\n\t\t?.filter((w) => w.connector === \"AND\" || !w.connector)\n\t\t.reduce(\n\t\t\t(acc, w) =>\n\t\t\t\t({\n\t\t\t\t\t...acc,\n\t\t\t\t\t[w.field]: w.value,\n\t\t\t\t}) as any,\n\t\t\t{},\n\t\t);\n\tconst or = w\n\t\t?.filter((w) => w.connector === \"OR\")\n\t\t.reduce(\n\t\t\t(acc, w) =>\n\t\t\t\t({\n\t\t\t\t\t...acc,\n\t\t\t\t\t[w.field]: w.value,\n\t\t\t\t}) as any,\n\t\t\t{},\n\t\t);\n\treturn {\n\t\tand: Object.keys(and).length ? and : null,\n\t\tor: Object.keys(or).length ? or : null,\n\t};\n}\n\nfunction transformTo(\n\tval: any,\n\tfields: Record<string, FieldAttribute>,\n\ttransform: KyselyAdapterConfig[\"transform\"],\n) {\n\tfor (const key in val) {\n\t\tif (\n\t\t\tval[key] === 0 &&\n\t\t\tfields[key]?.type === \"boolean\" &&\n\t\t\ttransform?.boolean\n\t\t) {\n\t\t\tval[key] = false;\n\t\t}\n\t\tif (\n\t\t\tval[key] === 1 &&\n\t\t\tfields[key]?.type === \"boolean\" &&\n\t\t\ttransform?.boolean\n\t\t) {\n\t\t\tval[key] = true;\n\t\t}\n\t\tif (fields[key]?.type === \"date\") {\n\t\t\tif (!(val[key] instanceof Date)) {\n\t\t\t\tval[key] = new Date(val[key]);\n\t\t\t}\n\t\t}\n\t}\n\treturn val;\n}\n\nfunction transformFrom(val: any, transform: KyselyAdapterConfig[\"transform\"]) {\n\tfor (const key in val) {\n\t\tif (typeof val[key] === \"boolean\" && transform?.boolean) {\n\t\t\tval[key] = val[key] ? 1 : 0;\n\t\t}\n\t\tif (val[key] instanceof Date) {\n\t\t\tval[key] = val[key].toISOString();\n\t\t}\n\t}\n\treturn val;\n}\n\nexport interface KyselyAdapterConfig {\n\t/**\n\t * Transform dates and booleans for sqlite.\n\t */\n\ttransform?: {\n\t\tschema: {\n\t\t\t[table: string]: Record<string, FieldAttribute>;\n\t\t};\n\t\tboolean: boolean;\n\t\tdate: boolean;\n\t};\n}\n\nexport const kyselyAdapter = (\n\tdb: Kysely<any>,\n\tconfig?: KyselyAdapterConfig,\n): Adapter => {\n\treturn {\n\t\tasync create(data) {\n\t\t\tlet { model, data: val, select } = data;\n\t\t\tif (config?.transform) {\n\t\t\t\tval = transformFrom(val, config.transform);\n\t\t\t}\n\t\t\tlet res = await db\n\t\t\t\t.insertInto(model)\n\t\t\t\t.values(val as any)\n\t\t\t\t.returningAll()\n\t\t\t\t.executeTakeFirst();\n\n\t\t\tif (config?.transform) {\n\t\t\t\tconst schema = config.transform.schema[model];\n\t\t\t\tres = schema ? transformTo(val, schema, config.transform) : res;\n\t\t\t}\n\n\t\t\tif (select?.length) {\n\t\t\t\tconst data = res\n\t\t\t\t\t? select.reduce((acc, cur) => {\n\t\t\t\t\t\t\tif (res?.[cur]) {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t\t\t\t[cur]: res[cur],\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t}, {} as any)\n\t\t\t\t\t: null;\n\t\t\t\tres = data;\n\t\t\t}\n\n\t\t\treturn res as any;\n\t\t},\n\t\tasync findOne(data) {\n\t\t\tconst { model, where, select } = data;\n\t\t\tconst { and, or } = convertWhere(where);\n\t\t\tlet query = db.selectFrom(model).selectAll();\n\t\t\tif (or) {\n\t\t\t\tquery = query.where((eb) => eb.or(or));\n\t\t\t}\n\t\t\tif (and) {\n\t\t\t\tquery = query.where((eb) => eb.and(and));\n\t\t\t}\n\t\t\tlet res = await query.executeTakeFirst();\n\t\t\tif (select?.length) {\n\t\t\t\tconst data = res\n\t\t\t\t\t? select.reduce((acc, cur) => {\n\t\t\t\t\t\t\tif (res?.[cur]) {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t\t\t\t[cur]: res[cur],\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t}, {} as any)\n\t\t\t\t\t: null;\n\t\t\t\tres = data;\n\t\t\t}\n\n\t\t\tif (config?.transform) {\n\t\t\t\tconst schema = config.transform.schema[model];\n\t\t\t\tres = res && schema ? transformTo(res, schema, config.transform) : res;\n\n\t\t\t\treturn res || null;\n\t\t\t}\n\t\t\treturn (res || null) as any;\n\t\t},\n\t\tasync findMany(data) {\n\t\t\tconst { model, where } = data;\n\t\t\tlet query = db.selectFrom(model);\n\t\t\tconst { and, or } = convertWhere(where);\n\t\t\tif (and) {\n\t\t\t\tquery = query.where((eb) => eb.and(and));\n\t\t\t}\n\t\t\tif (or) {\n\t\t\t\tquery = query.where((eb) => eb.or(or));\n\t\t\t}\n\t\t\tconst res = await query.selectAll().execute();\n\t\t\tif (config?.transform) {\n\t\t\t\tconst schema = config.transform.schema[model];\n\t\t\t\treturn schema\n\t\t\t\t\t? res.map((v) => transformTo(v, schema, config.transform))\n\t\t\t\t\t: res;\n\t\t\t}\n\t\t\treturn res as any;\n\t\t},\n\t\tasync update(data) {\n\t\t\tlet { model, where, update: val } = data;\n\t\t\tconst { and, or } = convertWhere(where);\n\n\t\t\tif (config?.transform) {\n\t\t\t\tval = transformFrom(val, config.transform);\n\t\t\t}\n\n\t\t\tlet query = db.updateTable(model).set(val);\n\t\t\tif (and) {\n\t\t\t\tquery = query.where((eb) => eb.and(and));\n\t\t\t}\n\t\t\tif (or) {\n\t\t\t\tquery = query.where((eb) => eb.or(or));\n\t\t\t}\n\t\t\tconst res = await query.returningAll().executeTakeFirst();\n\t\t\tif (config?.transform) {\n\t\t\t\tconst schema = config.transform.schema[model];\n\t\t\t\treturn schema ? transformTo(res, schema, config.transform) : res;\n\t\t\t}\n\t\t\treturn res as any;\n\t\t},\n\t\tasync delete(data) {\n\t\t\tconst { model, where } = data;\n\t\t\tconst { and, or } = convertWhere(where);\n\t\t\tlet query = db.deleteFrom(model);\n\n\t\t\tif (and) {\n\t\t\t\tquery = query.where((eb) => eb.and(and));\n\t\t\t}\n\t\t\tif (or) {\n\t\t\t\tquery = query.where((eb) => eb.or(or));\n\t\t\t}\n\n\t\t\tawait query.execute();\n\t\t},\n\t};\n};\n\nexport const getDialect = (config: BetterAuthOptions) => {\n\tif (!config.database) {\n\t\treturn null;\n\t}\n\tlet dialect: Dialect | null = null;\n\tif (\"provider\" in config.database) {\n\t\tconst provider = config.database.provider;\n\t\tconst connectionString = config.database.url.trim();\n\t\tif (provider === \"postgres\") {\n\t\t\tconst pool = new Pool({\n\t\t\t\tconnectionString,\n\t\t\t});\n\t\t\tdialect = new PostgresDialect({\n\t\t\t\tpool,\n\t\t\t});\n\t\t}\n\t\tif (provider === \"mysql\") {\n\t\t\tconst params = new URL(connectionString);\n\t\t\tconst pool = createPool({\n\t\t\t\thost: params.hostname,\n\t\t\t\tuser: params.username,\n\t\t\t\tpassword: params.password,\n\t\t\t\tdatabase: params.pathname.split(\"/\")[1],\n\t\t\t\tport: Number(params.port),\n\t\t\t});\n\t\t\tdialect = new MysqlDialect({ pool });\n\t\t}\n\n\t\tif (provider === \"sqlite\") {\n\t\t\tconst db = new Database(connectionString);\n\t\t\tdialect = new SqliteDialect({\n\t\t\t\tdatabase: db,\n\t\t\t});\n\t\t}\n\t}\n\treturn dialect;\n};\n\nexport const createKyselyAdapter = (config: BetterAuthOptions) => {\n\tconst dialect = getDialect(config);\n\tif (!dialect) {\n\t\treturn null;\n\t}\n\tconst db = new Kysely<any>({\n\t\tdialect,\n\t});\n\treturn db;\n};\n\nexport const getDatabaseType = (config: BetterAuthOptions) => {\n\tif (\"provider\" in config.database) {\n\t\treturn config.database.provider;\n\t}\n\tif (\"dialect\" in config.database) {\n\t\tif (config.database.dialect instanceof PostgresDialect) {\n\t\t\treturn \"postgres\";\n\t\t}\n\t\tif (config.database.dialect instanceof MysqlDialect) {\n\t\t\treturn \"mysql\";\n\t\t}\n\t\tif (config.database.dialect instanceof SqliteDialect) {\n\t\t\treturn \"sqlite\";\n\t\t}\n\t}\n\treturn \"sqlite\";\n};\n","import type { FieldAttribute } from \"../db\";\nimport type { BetterAuthOptions } from \"../types\";\n\nexport type BetterAuthDbSchema = Record<\n\tstring,\n\t{\n\t\ttableName: string;\n\t\tfields: Record<string, FieldAttribute>;\n\t\tdisableMigrations?: boolean;\n\t}\n>;\n\nexport const getAuthTables = (options: BetterAuthOptions) => {\n\tconst pluginSchema = options.plugins?.reduce((acc, plugin) => {\n\t\tconst schema = plugin.schema;\n\t\treturn {\n\t\t\t...acc,\n\t\t\t...schema,\n\t\t};\n\t}, {});\n\n\treturn {\n\t\t...pluginSchema,\n\t\tuser: {\n\t\t\ttableName: options.user?.modelName || \"user\",\n\t\t\tfields: {\n\t\t\t\tname: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t},\n\t\t\t\temail: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t},\n\t\t\t\temailVerified: {\n\t\t\t\t\ttype: \"boolean\",\n\t\t\t\t\tdefaultValue: () => false,\n\t\t\t\t},\n\t\t\t\timage: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t},\n\t\t\t\tcreatedAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\tdefaultValue: () => new Date(),\n\t\t\t\t},\n\t\t\t\tupdatedAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\tdefaultValue: () => new Date(),\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tsession: {\n\t\t\ttableName: options.session?.modelName || \"session\",\n\t\t\tfields: {\n\t\t\t\texpiresAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t},\n\t\t\t\tipAddress: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t},\n\t\t\t\tuserAgent: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t},\n\t\t\t\tuserId: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\treferences: {\n\t\t\t\t\t\tmodel: \"user\",\n\t\t\t\t\t\tfield: \"id\",\n\t\t\t\t\t\tonDelete: \"cascade\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\taccount: {\n\t\t\ttableName: options.account?.modelName || \"account\",\n\t\t\tfields: {\n\t\t\t\taccountId: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t},\n\t\t\t\tproviderId: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t},\n\t\t\t\tuserId: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\treferences: {\n\t\t\t\t\t\tmodel: \"user\",\n\t\t\t\t\t\tfield: \"id\",\n\t\t\t\t\t\tonDelete: \"cascade\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\taccessToken: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t},\n\t\t\t\trefreshToken: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t},\n\t\t\t\tidToken: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t},\n\t\t\t\taccessTokenExpiresAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: false,\n\t\t\t\t},\n\t\t\t\trefreshTokenExpiresAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: false,\n\t\t\t\t},\n\t\t\t\tpassword: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t} satisfies BetterAuthDbSchema;\n};\n","import { BetterAuthError } from \"../error/better-auth-error\";\nimport type { BetterAuthOptions } from \"../types\";\nimport type { Adapter } from \"../types/adapter\";\nimport { getAuthTables } from \"./get-tables\";\nimport { createKyselyAdapter, getDatabaseType, kyselyAdapter } from \"./kysely\";\n\nexport function getAdapter(options: BetterAuthOptions): Adapter {\n\tif (!options.database) {\n\t\tthrow new BetterAuthError(\"Database configuration is required\");\n\t}\n\tif (\"provider\" in options.database) {\n\t\tconst db = createKyselyAdapter(options);\n\t\tif (!db) {\n\t\t\tthrow new BetterAuthError(\"Failed to initialize database adapter\");\n\t\t}\n\t\tconst tables = getAuthTables(options);\n\t\treturn kyselyAdapter(db, {\n\t\t\ttransform: {\n\t\t\t\tschema: {\n\t\t\t\t\t[tables.user.tableName]: tables.user.fields,\n\t\t\t\t\t[tables.session.tableName]: tables.session.fields,\n\t\t\t\t\t[tables.account.tableName]: tables.account.fields,\n\t\t\t\t},\n\t\t\t\tdate: true,\n\t\t\t\tboolean: getDatabaseType(options) === \"sqlite\",\n\t\t\t},\n\t\t});\n\t}\n\treturn options.database;\n}\n","import { alphabet, generateRandomString } from \"oslo/crypto\";\nimport type { BetterAuthOptions } from \"../types\";\nimport type { Adapter } from \"../types/adapter\";\nimport { getDate } from \"../utils/date\";\nimport { getAuthTables } from \"./get-tables\";\nimport type { Account, Session, User } from \"./schema\";\n\nexport const createInternalAdapter = (\n\tadapter: Adapter,\n\toptions: BetterAuthOptions,\n) => {\n\tconst sessionExpiration = options.session?.expiresIn || 60 * 60 * 24 * 7; // 7 days\n\tconst tables = getAuthTables(options);\n\treturn {\n\t\tcreateOAuthUser: async (user: User, account: Account) => {\n\t\t\ttry {\n\t\t\t\tconst createdUser = await adapter.create({\n\t\t\t\t\tmodel: tables.user.tableName,\n\t\t\t\t\tdata: user,\n\t\t\t\t});\n\t\t\t\tconst createdAccount = await adapter.create({\n\t\t\t\t\tmodel: tables.account.tableName,\n\t\t\t\t\tdata: account,\n\t\t\t\t});\n\t\t\t\treturn {\n\t\t\t\t\tuser: createdUser,\n\t\t\t\t\taccount: createdAccount,\n\t\t\t\t};\n\t\t\t} catch (e) {\n\t\t\t\tconsole.log(e);\n\t\t\t\treturn null;\n\t\t\t}\n\t\t},\n\t\tcreateUser: async (user: User) => {\n\t\t\tconst createdUser = await adapter.create<User>({\n\t\t\t\tmodel: tables.user.tableName,\n\t\t\t\tdata: user,\n\t\t\t});\n\t\t\treturn createdUser;\n\t\t},\n\t\tcreateSession: async (userId: string, request?: Request) => {\n\t\t\tconst data: Session = {\n\t\t\t\tid: generateRandomString(32, alphabet(\"a-z\", \"0-9\", \"A-Z\")),\n\t\t\t\tuserId,\n\t\t\t\texpiresAt: getDate(sessionExpiration),\n\t\t\t\tipAddress: request?.headers.get(\"x-forwarded-for\") || \"\",\n\t\t\t\tuserAgent: request?.headers.get(\"user-agent\") || \"\",\n\t\t\t};\n\t\t\tconst session = adapter.create<Session>({\n\t\t\t\tmodel: tables.session.tableName,\n\t\t\t\tdata,\n\t\t\t});\n\t\t\treturn session;\n\t\t},\n\t\tfindSession: async (sessionId: string) => {\n\t\t\tconst session = await adapter.findOne<Session>({\n\t\t\t\tmodel: tables.session.tableName,\n\t\t\t\twhere: [\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: sessionId,\n\t\t\t\t\t\tfield: \"id\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t});\n\t\t\tif (!session) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst user = await adapter.findOne<User>({\n\t\t\t\tmodel: tables.user.tableName,\n\t\t\t\twhere: [\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: session.userId,\n\t\t\t\t\t\tfield: \"id\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t});\n\t\t\tif (!user) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tsession,\n\t\t\t\tuser,\n\t\t\t};\n\t\t},\n\t\tupdateSession: async (session: Session) => {\n\t\t\tconst updateAge =\n\t\t\t\toptions.session?.updateAge === undefined\n\t\t\t\t\t? 1000 // 1 hour update age\n\t\t\t\t\t: options.session?.updateAge;\n\t\t\tconst updateDate = updateAge === 0 ? 0 : getDate(updateAge).valueOf();\n\t\t\tconst maxAge = getDate(sessionExpiration);\n\t\t\tconst shouldBeUpdated =\n\t\t\t\tsession.expiresAt.valueOf() - maxAge.valueOf() + updateDate <=\n\t\t\t\tDate.now();\n\t\t\tif (shouldBeUpdated) {\n\t\t\t\tconst updatedSession = await adapter.create<Session>({\n\t\t\t\t\tmodel: tables.session.tableName,\n\t\t\t\t\tdata: {\n\t\t\t\t\t\t...session,\n\t\t\t\t\t\tid: generateRandomString(32, alphabet(\"a-z\", \"0-9\", \"A-Z\")),\n\t\t\t\t\t\texpiresAt: new Date(Date.now() + sessionExpiration),\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\tawait adapter.update<Session>({\n\t\t\t\t\tmodel: tables.session.tableName,\n\t\t\t\t\twhere: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfield: \"id\",\n\t\t\t\t\t\t\tvalue: session.id,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tupdate: {\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * update the session to expire in 2 minute. This is to prevent\n\t\t\t\t\t\t * the session from expiring too quickly and logging the user out.\n\t\t\t\t\t\t */\n\t\t\t\t\t\texpiresAt: new Date(Date.now() + 1000 * 60 * 2),\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\treturn updatedSession;\n\t\t\t}\n\n\t\t\treturn session;\n\t\t},\n\t\tdeleteSession: async (id: string) => {\n\t\t\tconst session = await adapter.delete<Session>({\n\t\t\t\tmodel: tables.session.tableName,\n\t\t\t\twhere: [\n\t\t\t\t\t{\n\t\t\t\t\t\tfield: \"id\",\n\t\t\t\t\t\tvalue: id,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn session;\n\t\t},\n\t\tfindUserByEmail: async (email: string) => {\n\t\t\tconst user = await adapter.findOne<User>({\n\t\t\t\tmodel: tables.user.tableName,\n\t\t\t\twhere: [\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: email.toLowerCase(),\n\t\t\t\t\t\tfield: \"email\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t});\n\t\t\tif (!user) return null;\n\t\t\tconst accounts = await adapter.findMany<Account>({\n\t\t\t\tmodel: tables.account.tableName,\n\t\t\t\twhere: [\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: user.id,\n\t\t\t\t\t\tfield: \"userId\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn {\n\t\t\t\tuser,\n\t\t\t\taccounts,\n\t\t\t};\n\t\t},\n\t\tfindUserById: async (userId: string) => {\n\t\t\tconst user = await adapter.findOne<User>({\n\t\t\t\tmodel: tables.user.tableName,\n\t\t\t\twhere: [\n\t\t\t\t\t{\n\t\t\t\t\t\tfield: \"id\",\n\t\t\t\t\t\tvalue: userId,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn user;\n\t\t},\n\t\tlinkAccount: async (account: Account) => {\n\t\t\tconst _account = await adapter.create<Account>({\n\t\t\t\tmodel: tables.account.tableName,\n\t\t\t\tdata: account,\n\t\t\t});\n\t\t\treturn _account;\n\t\t},\n\t\tupdateUserByEmail: async (\n\t\t\temail: string,\n\t\t\tdata: Partial<User & Record<string, any>>,\n\t\t) => {\n\t\t\tconst user = await adapter.update<User>({\n\t\t\t\tmodel: tables.user.tableName,\n\t\t\t\twhere: [\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: email,\n\t\t\t\t\t\tfield: \"email\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tupdate: data,\n\t\t\t});\n\t\t\treturn user;\n\t\t},\n\t\tupdatePassword: async (userId: string, password: string) => {\n\t\t\tconst account = await adapter.update<Account>({\n\t\t\t\tmodel: tables.account.tableName,\n\t\t\t\twhere: [\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: userId,\n\t\t\t\t\t\tfield: \"userId\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tfield: \"providerId\",\n\t\t\t\t\t\tvalue: \"credential\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tupdate: {\n\t\t\t\t\tpassword,\n\t\t\t\t},\n\t\t\t});\n\t\t\treturn account;\n\t\t},\n\t};\n};\n\nexport type InternalAdapter = ReturnType<typeof createInternalAdapter>;\n","export const getDate = (span: number) => {\n\tconst date = new Date();\n\treturn new Date(date.getTime() + span);\n};\n","import type { ZodSchema } from \"zod\";\n\nexport const createFieldAttribute = <\n\tT extends FieldType,\n\tC extends Omit<FieldAttributeConfig<T>, \"type\">,\n>(\n\ttype: T,\n\tconfig?: C,\n) => {\n\treturn {\n\t\ttype,\n\t\t...config,\n\t} satisfies FieldAttribute<T>;\n};\n\nexport type FieldAttribute<T extends FieldType = FieldType> = {\n\ttype: T;\n} & FieldAttributeConfig<T>;\n\nexport type FieldType = \"string\" | \"number\" | \"boolean\" | \"date\";\n\nexport type InferValueType<T extends FieldType> = T extends \"string\"\n\t? string\n\t: T extends \"number\"\n\t\t? number\n\t\t: T extends \"boolean\"\n\t\t\t? boolean\n\t\t\t: T extends \"date\"\n\t\t\t\t? Date\n\t\t\t\t: never;\n\nexport type InferFieldOutput<T extends FieldAttribute> =\n\tT[\"returned\"] extends false\n\t\t? never\n\t\t: T[\"required\"] extends false\n\t\t\t? InferValueType<T[\"type\"]> | undefined\n\t\t\t: InferValueType<T[\"type\"]>;\n\nexport type FieldAttributeConfig<T extends FieldType = FieldType> = {\n\t/**\n\t * if the field should be required on a new record.\n\t * @default false\n\t */\n\trequired?: boolean;\n\t/**\n\t * If the value should be returned on a response body.\n\t * @default true\n\t */\n\treturned?: boolean;\n\t/**\n\t * If the value should be hashed when it's stored.\n\t * @default false\n\t */\n\thashValue?: boolean;\n\t/**\n\t * Default value for the field\n\t *\n\t * Note: This will not create a default value on the database level. It will only\n\t * be used when creating a new record.\n\t */\n\tdefaultValue?: InferValueType<T> | (() => InferValueType<T>);\n\t/**\n\t * transform the value before storing it.\n\t */\n\ttransform?: (value: InferValueType<T>) => InferValueType<T>;\n\t/**\n\t * Reference to another model.\n\t */\n\treferences?: {\n\t\t/**\n\t\t * The model to reference.\n\t\t */\n\t\tmodel: string;\n\t\t/**\n\t\t * The field on the referenced model.\n\t\t */\n\t\tfield: string;\n\t\t/**\n\t\t * The action to perform when the reference is deleted.\n\t\t * @default \"cascade\"\n\t\t */\n\t\tonDelete?:\n\t\t\t| \"no action\"\n\t\t\t| \"restrict\"\n\t\t\t| \"cascade\"\n\t\t\t| \"set null\"\n\t\t\t| \"set default\";\n\t};\n\tunique?: boolean;\n\t/**\n\t * A zod schema to validate the value.\n\t */\n\tvalidator?: ZodSchema;\n};\n","import type { CookieOptions } from \"better-call\";\nimport { TimeSpan } from \"oslo\";\nimport type { BetterAuthOptions } from \"../types/options\";\n\nexport function getCookies(options: BetterAuthOptions) {\n\tconst secure =\n\t\t!!options.advanced?.useSecureCookies ||\n\t\tprocess.env.NODE_ENV === \"production\";\n\tconst secureCookiePrefix = secure ? \"__Secure-\" : \"\";\n\tconst cookiePrefix = \"better-auth\";\n\tconst sessionMaxAge = new TimeSpan(7, \"d\").seconds();\n\treturn {\n\t\tsessionToken: {\n\t\t\tname: `${secureCookiePrefix}${cookiePrefix}.session_token`,\n\t\t\toptions: {\n\t\t\t\thttpOnly: true,\n\t\t\t\tsameSite: \"lax\",\n\t\t\t\tpath: \"/\",\n\t\t\t\tsecure,\n\t\t\t\tmaxAge: sessionMaxAge,\n\t\t\t} satisfies CookieOptions,\n\t\t},\n\t\tcsrfToken: {\n\t\t\tname: `${secureCookiePrefix ? \"__Host-\" : \"\"}${cookiePrefix}.csrf_token`,\n\t\t\toptions: {\n\t\t\t\thttpOnly: true,\n\t\t\t\tsameSite: \"lax\",\n\t\t\t\tpath: \"/\",\n\t\t\t\tsecure,\n\t\t\t\tmaxAge: 60 * 60 * 24 * 7,\n\t\t\t} satisfies CookieOptions,\n\t\t},\n\t\tstate: {\n\t\t\tname: `${secureCookiePrefix}${cookiePrefix}.state`,\n\t\t\toptions: {\n\t\t\t\thttpOnly: true,\n\t\t\t\tsameSite: \"lax\",\n\t\t\t\tpath: \"/\",\n\t\t\t\tsecure,\n\t\t\t\tmaxAge: 60 * 15, // 15 minutes in seconds\n\t\t\t} satisfies CookieOptions,\n\t\t},\n\t\tpkCodeVerifier: {\n\t\t\tname: `${secureCookiePrefix}${cookiePrefix}.pk_code_verifier`,\n\t\t\toptions: {\n\t\t\t\thttpOnly: true,\n\t\t\t\tsameSite: \"lax\",\n\t\t\t\tpath: \"/\",\n\t\t\t\tsecure,\n\t\t\t\tmaxAge: 60 * 15, // 15 minutes in seconds\n\t\t\t} as CookieOptions,\n\t\t},\n\t\tnonce: {\n\t\t\tname: `${secureCookiePrefix}${cookiePrefix}.nonce`,\n\t\t\toptions: {\n\t\t\t\thttpOnly: true,\n\t\t\t\tsameSite: \"lax\",\n\t\t\t\tpath: \"/\",\n\t\t\t\tsecure,\n\t\t\t\tmaxAge: 60 * 15, // 15 minutes in seconds\n\t\t\t} as CookieOptions,\n\t\t},\n\t};\n}\n\nexport function createCookieGetter(options: BetterAuthOptions) {\n\tconst secure =\n\t\t!!options.advanced?.useSecureCookies ||\n\t\tprocess.env.NODE_ENV === \"production\";\n\tconst secureCookiePrefix = secure ? \"__Secure-\" : \"\";\n\tconst cookiePrefix = \"better-auth\";\n\tfunction getCookie(cookieName: string, options?: CookieOptions) {\n\t\treturn {\n\t\t\tname:\n\t\t\t\tprocess.env.NODE_ENV === \"production\"\n\t\t\t\t\t? `${secureCookiePrefix}${cookiePrefix}.${cookieName}`\n\t\t\t\t\t: `${cookiePrefix}.${cookieName}`,\n\t\t\toptions: {\n\t\t\t\tsecure,\n\t\t\t\tsameSite: \"lax\",\n\t\t\t\tpath: \"/\",\n\t\t\t\tmaxAge: 60 * 15, // 15 minutes in seconds\n\t\t\t\t...options,\n\t\t\t} as CookieOptions,\n\t\t};\n\t}\n\treturn getCookie;\n}\nexport type BetterAuthCookies = ReturnType<typeof getCookies>;\n","import { createConsola } from \"consola\";\n\nconst consola = createConsola({\n\tformatOptions: {\n\t\tdate: false,\n\t},\n});\n\nexport const createLogger = (options?: {\n\tdisabled?: boolean;\n}) => {\n\treturn {\n\t\tlog: (...args: any[]) => {\n\t\t\t!options?.disabled && consola.log(\"\", ...args);\n\t\t},\n\t\terror: (...args: any[]) => {\n\t\t\t!options?.disabled && consola.error(\"\", ...args);\n\t\t},\n\t\twarn: (...args: any[]) => {\n\t\t\t!options?.disabled && consola.warn(\"\", ...args);\n\t\t},\n\t\tinfo: (...args: any[]) => {\n\t\t\t!options?.disabled && consola.info(\"\", ...args);\n\t\t},\n\t\tdebug: (...args: any[]) => {\n\t\t\t!options?.disabled && consola.debug(\"\", ...args);\n\t\t},\n\t\tbox: (...args: any[]) => {\n\t\t\t!options?.disabled && consola.box(\"\", ...args);\n\t\t},\n\t\tsuccess: (...args: any[]) => {\n\t\t\t!options?.disabled && consola.success(\"\", ...args);\n\t\t},\n\t\tbreak: (...args: any[]) => {\n\t\t\t!options?.disabled && console.log(\"\\n\");\n\t\t},\n\t};\n};\n\nexport const logger = createLogger();\n","import { createKyselyAdapter } from \"./adapters/kysely\";\nimport { getAdapter } from \"./adapters/utils\";\nimport { createInternalAdapter } from \"./db\";\nimport type { BetterAuthOptions } from \"./types\";\nimport { getBaseURL } from \"./utils/base-url\";\nimport {\n\ttype BetterAuthCookies,\n\tcreateCookieGetter,\n\tgetCookies,\n} from \"./utils/cookies\";\nimport { createLogger } from \"./utils/logger\";\n\nexport const init = (options: BetterAuthOptions) => {\n\tconst adapter = getAdapter(options);\n\tconst db = createKyselyAdapter(options);\n\tconst { baseURL, withPath } = getBaseURL(options.baseURL, options.basePath);\n\n\treturn {\n\t\toptions: {\n\t\t\t...options,\n\t\t\tbaseURL: baseURL,\n\t\t\tbasePath: options.basePath || \"/api/auth\",\n\t\t},\n\t\tbaseURL: withPath,\n\t\tsecret:\n\t\t\toptions.secret ||\n\t\t\tprocess.env.BETTER_AUTH_SECRET ||\n\t\t\tprocess.env.AUTH_SECRET ||\n\t\t\t\"better-auth-secret-123456789\",\n\t\tauthCookies: getCookies(options),\n\t\tlogger: createLogger({\n\t\t\tdisabled: options.disableLog,\n\t\t}),\n\t\tdb,\n\t\tadapter: adapter,\n\t\tinternalAdapter: createInternalAdapter(adapter, options),\n\t\tcreateAuthCookie: createCookieGetter(options),\n\t};\n};\n\nexport type AuthContext = {\n\toptions: BetterAuthOptions;\n\tbaseURL: string;\n\tauthCookies: BetterAuthCookies;\n\tlogger: ReturnType<typeof createLogger>;\n\tdb: ReturnType<typeof createKyselyAdapter>;\n\tadapter: ReturnType<typeof getAdapter>;\n\tinternalAdapter: ReturnType<typeof createInternalAdapter>;\n\tcreateAuthCookie: ReturnType<typeof createCookieGetter>;\n\tsecret: string;\n};\n","import type { UnionToIntersection } from \"./types/helper\";\nimport { router } from \"./api\";\nimport { init } from \"./init\";\nimport type { BetterAuthOptions } from \"./types/options\";\nimport type { BetterAuthPlugin } from \"./types/plugins\";\n\nexport const betterAuth = <O extends BetterAuthOptions>(options: O) => {\n\tconst authContext = init(options);\n\ttype PluginEndpoint = UnionToIntersection<\n\t\tO[\"plugins\"] extends Array<infer T>\n\t\t\t? T extends BetterAuthPlugin\n\t\t\t\t? {\n\t\t\t\t\t\t[key in T[\"id\"]]: T[\"endpoints\"];\n\t\t\t\t\t}\n\t\t\t\t: {}\n\t\t\t: {}\n\t>;\n\tconst { handler, endpoints } = router(authContext);\n\ttype Endpoint = typeof endpoints;\n\n\treturn {\n\t\thandler,\n\t\tapi: endpoints as Endpoint & PluginEndpoint,\n\t\toptions,\n\t};\n};\n\nexport type Auth = {\n\thandler: (request: Request) => Promise<Response>;\n\tapi: ReturnType<typeof router>[\"endpoints\"];\n\toptions: BetterAuthOptions;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAEA,YAAQ,mBAAmB,CAAC,SAAS,QAAQ;AAC5C,UAAI,QAAQ;AACZ,UAAI,OAAO,WAAW,QAAQ,QAAQ,QAAQ,GAAG,OAAO,WAAW;AAClE,cAAM,IAAI,UAAU,iBAAiB,GAAG,0BAA0B;AAAA,MACnE;AACA,aAAO;AAAA,IACR;AAEA,YAAQ,QAAQ,OAAO;AACvB,YAAQ,UAAU,OAAO,IAAI,4BAA4B;AAAA;AAAA;;;ACXzD;AAAA;AAAA;AACA,QAAM,aAAa,EAAE,OAAO,eAAe,UAAU,MAAM,YAAY,OAAO,cAAc,KAAK;AAEjG,aAAS,YAAY,SAAS,MAAM;AACnC,UAAI,eAAe,aAAa;AAC/B,eAAO,IAAI,YAAY,SAAS,IAAI;AAAA,MACrC;AACA,UAAI,OAAO,SAAS,UAAU;AAC7B,cAAM,IAAI,UAAU,yCAAyC;AAAA,MAC9D;AACA,YAAM,KAAK,MAAM,OAAO;AACxB,iBAAW,QAAQ,KAAK;AACxB,aAAO,eAAe,MAAM,WAAW,UAAU;AACjD,YAAM,kBAAkB,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AAA,EACD;AACD;","names":["path","i","Database","Database","z","z","APIError","z","error","betterFetch","error","betterFetch","betterFetch","error","betterFetch","betterFetch","error","betterFetch","parseJWT","parseJWT","betterFetch","error","betterFetch","betterFetch","error","betterFetch","betterFetch","error","betterFetch","z","APIError","APIError","z","z","APIError","z","z","Argon2id","z","z","Argon2id","TimeSpan","createJWT","validateJWT","z","z","createJWT","TimeSpan","validateJWT","alphabet","generateRandomString","generateRandomString","alphabet","alphabet","generateRandomString","Argon2id","z","z","Argon2id","generateRandomString","alphabet","ctx","w","data","Database","alphabet","generateRandomString","generateRandomString","alphabet","TimeSpan","options","withPath"]}
|