better-auth 1.4.8-beta.2 → 1.4.8-beta.3

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.
Files changed (70) hide show
  1. package/dist/api/index.d.mts +393 -393
  2. package/dist/api/index.mjs.map +1 -1
  3. package/dist/api/middlewares/origin-check.d.mts +3 -3
  4. package/dist/api/routes/account.d.mts +11 -11
  5. package/dist/api/routes/callback.d.mts +2 -2
  6. package/dist/api/routes/email-verification.d.mts +4 -4
  7. package/dist/api/routes/error.d.mts +2 -2
  8. package/dist/api/routes/ok.d.mts +2 -2
  9. package/dist/api/routes/reset-password.d.mts +5 -5
  10. package/dist/api/routes/session.d.mts +14 -14
  11. package/dist/api/routes/sign-in.d.mts +3 -3
  12. package/dist/api/routes/sign-out.d.mts +2 -2
  13. package/dist/api/routes/sign-up.d.mts +2 -2
  14. package/dist/api/routes/update-user.d.mts +13 -13
  15. package/dist/auth/base.mjs +2 -0
  16. package/dist/auth/base.mjs.map +1 -1
  17. package/dist/client/lynx/index.d.mts +15 -15
  18. package/dist/client/react/index.d.mts +13 -13
  19. package/dist/client/solid/index.d.mts +13 -13
  20. package/dist/client/svelte/index.d.mts +15 -15
  21. package/dist/client/vanilla.d.mts +15 -15
  22. package/dist/client/vue/index.d.mts +15 -15
  23. package/dist/context/create-context.mjs +1 -0
  24. package/dist/context/create-context.mjs.map +1 -1
  25. package/dist/db/field.d.mts +6 -6
  26. package/dist/integrations/next-js.d.mts +4 -4
  27. package/dist/integrations/svelte-kit.d.mts +2 -2
  28. package/dist/integrations/tanstack-start.d.mts +4 -4
  29. package/dist/plugins/admin/admin.d.mts +113 -113
  30. package/dist/plugins/anonymous/index.d.mts +5 -5
  31. package/dist/plugins/api-key/index.d.mts +56 -56
  32. package/dist/plugins/bearer/index.d.mts +6 -6
  33. package/dist/plugins/captcha/index.d.mts +2 -2
  34. package/dist/plugins/custom-session/index.d.mts +5 -5
  35. package/dist/plugins/device-authorization/index.d.mts +6 -6
  36. package/dist/plugins/email-otp/index.d.mts +13 -13
  37. package/dist/plugins/generic-oauth/index.d.mts +31 -31
  38. package/dist/plugins/haveibeenpwned/index.d.mts +3 -3
  39. package/dist/plugins/jwt/client.d.mts +2 -2
  40. package/dist/plugins/jwt/index.d.mts +9 -9
  41. package/dist/plugins/last-login-method/index.d.mts +4 -4
  42. package/dist/plugins/magic-link/index.d.mts +4 -4
  43. package/dist/plugins/mcp/index.d.mts +10 -10
  44. package/dist/plugins/multi-session/index.d.mts +7 -7
  45. package/dist/plugins/oauth-proxy/index.d.mts +8 -8
  46. package/dist/plugins/oidc-provider/index.d.mts +13 -13
  47. package/dist/plugins/one-tap/client.d.mts +5 -5
  48. package/dist/plugins/one-tap/index.d.mts +2 -2
  49. package/dist/plugins/one-time-token/index.d.mts +5 -5
  50. package/dist/plugins/open-api/index.d.mts +3 -3
  51. package/dist/plugins/organization/client.d.mts +17 -17
  52. package/dist/plugins/organization/organization.d.mts +7 -7
  53. package/dist/plugins/organization/routes/crud-access-control.d.mts +22 -22
  54. package/dist/plugins/organization/routes/crud-invites.d.mts +58 -58
  55. package/dist/plugins/organization/routes/crud-members.d.mts +62 -62
  56. package/dist/plugins/organization/routes/crud-org.d.mts +51 -51
  57. package/dist/plugins/organization/routes/crud-team.d.mts +66 -66
  58. package/dist/plugins/phone-number/index.d.mts +33 -33
  59. package/dist/plugins/siwe/index.d.mts +3 -3
  60. package/dist/plugins/two-factor/backup-codes/index.d.mts +5 -5
  61. package/dist/plugins/two-factor/client.d.mts +2 -2
  62. package/dist/plugins/two-factor/index.d.mts +18 -18
  63. package/dist/plugins/two-factor/otp/index.d.mts +3 -3
  64. package/dist/plugins/two-factor/totp/index.d.mts +5 -5
  65. package/dist/plugins/username/index.d.mts +9 -9
  66. package/dist/plugins/username/schema.d.mts +3 -3
  67. package/dist/test-utils/test-instance.d.mts +1191 -1191
  68. package/dist/utils/url.mjs +23 -1
  69. package/dist/utils/url.mjs.map +1 -1
  70. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["methods: string[]","conflicts: {\n\t\tpath: string;\n\t\tplugins: string[];\n\t\tconflictingMethods: string[];\n\t}[]","conflictingMethods: string[]","APIError"],"sources":["../../src/api/index.ts"],"sourcesContent":["import type {\n\tAuthContext,\n\tAwaitable,\n\tBetterAuthOptions,\n\tBetterAuthPlugin,\n} from \"@better-auth/core\";\nimport type { InternalLogger } from \"@better-auth/core/env\";\nimport { logger } from \"@better-auth/core/env\";\nimport type { Endpoint, Middleware } from \"better-call\";\nimport { APIError, createRouter } from \"better-call\";\nimport type { UnionToIntersection } from \"../types/helper\";\nimport { originCheckMiddleware } from \"./middlewares\";\nimport { onRequestRateLimit } from \"./rate-limiter\";\nimport {\n\taccountInfo,\n\tcallbackOAuth,\n\tchangeEmail,\n\tchangePassword,\n\tdeleteUser,\n\tdeleteUserCallback,\n\terror,\n\tgetAccessToken,\n\tgetSession,\n\tlinkSocialAccount,\n\tlistSessions,\n\tlistUserAccounts,\n\tok,\n\trefreshToken,\n\trequestPasswordReset,\n\trequestPasswordResetCallback,\n\tresetPassword,\n\trevokeOtherSessions,\n\trevokeSession,\n\trevokeSessions,\n\tsendVerificationEmail,\n\tsetPassword,\n\tsignInEmail,\n\tsignInSocial,\n\tsignOut,\n\tsignUpEmail,\n\tunlinkAccount,\n\tupdateUser,\n\tverifyEmail,\n} from \"./routes\";\nimport { toAuthEndpoints } from \"./to-auth-endpoints\";\n\nexport function checkEndpointConflicts(\n\toptions: BetterAuthOptions,\n\tlogger: InternalLogger,\n) {\n\tconst endpointRegistry = new Map<\n\t\tstring,\n\t\t{ pluginId: string; endpointKey: string; methods: string[] }[]\n\t>();\n\n\toptions.plugins?.forEach((plugin) => {\n\t\tif (plugin.endpoints) {\n\t\t\tfor (const [key, endpoint] of Object.entries(plugin.endpoints)) {\n\t\t\t\tif (\n\t\t\t\t\tendpoint &&\n\t\t\t\t\t\"path\" in endpoint &&\n\t\t\t\t\ttypeof endpoint.path === \"string\"\n\t\t\t\t) {\n\t\t\t\t\tconst path = endpoint.path;\n\t\t\t\t\tlet methods: string[] = [];\n\t\t\t\t\tif (endpoint.options && \"method\" in endpoint.options) {\n\t\t\t\t\t\tif (Array.isArray(endpoint.options.method)) {\n\t\t\t\t\t\t\tmethods = endpoint.options.method;\n\t\t\t\t\t\t} else if (typeof endpoint.options.method === \"string\") {\n\t\t\t\t\t\t\tmethods = [endpoint.options.method];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (methods.length === 0) {\n\t\t\t\t\t\tmethods = [\"*\"];\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!endpointRegistry.has(path)) {\n\t\t\t\t\t\tendpointRegistry.set(path, []);\n\t\t\t\t\t}\n\t\t\t\t\tendpointRegistry.get(path)!.push({\n\t\t\t\t\t\tpluginId: plugin.id,\n\t\t\t\t\t\tendpointKey: key,\n\t\t\t\t\t\tmethods,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n\n\tconst conflicts: {\n\t\tpath: string;\n\t\tplugins: string[];\n\t\tconflictingMethods: string[];\n\t}[] = [];\n\tfor (const [path, entries] of endpointRegistry.entries()) {\n\t\tif (entries.length > 1) {\n\t\t\tconst methodMap = new Map<string, string[]>();\n\t\t\tlet hasConflict = false;\n\n\t\t\tfor (const entry of entries) {\n\t\t\t\tfor (const method of entry.methods) {\n\t\t\t\t\tif (!methodMap.has(method)) {\n\t\t\t\t\t\tmethodMap.set(method, []);\n\t\t\t\t\t}\n\t\t\t\t\tmethodMap.get(method)!.push(entry.pluginId);\n\n\t\t\t\t\tif (methodMap.get(method)!.length > 1) {\n\t\t\t\t\t\thasConflict = true;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (method === \"*\" && entries.length > 1) {\n\t\t\t\t\t\thasConflict = true;\n\t\t\t\t\t} else if (method !== \"*\" && methodMap.has(\"*\")) {\n\t\t\t\t\t\thasConflict = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (hasConflict) {\n\t\t\t\tconst uniquePlugins = [...new Set(entries.map((e) => e.pluginId))];\n\t\t\t\tconst conflictingMethods: string[] = [];\n\n\t\t\t\tfor (const [method, plugins] of methodMap.entries()) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tplugins.length > 1 ||\n\t\t\t\t\t\t(method === \"*\" && entries.length > 1) ||\n\t\t\t\t\t\t(method !== \"*\" && methodMap.has(\"*\"))\n\t\t\t\t\t) {\n\t\t\t\t\t\tconflictingMethods.push(method);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconflicts.push({\n\t\t\t\t\tpath,\n\t\t\t\t\tplugins: uniquePlugins,\n\t\t\t\t\tconflictingMethods,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tif (conflicts.length > 0) {\n\t\tconst conflictMessages = conflicts\n\t\t\t.map(\n\t\t\t\t(conflict) =>\n\t\t\t\t\t` - \"${conflict.path}\" [${conflict.conflictingMethods.join(\", \")}] used by plugins: ${conflict.plugins.join(\", \")}`,\n\t\t\t)\n\t\t\t.join(\"\\n\");\n\t\tlogger.error(\n\t\t\t`Endpoint path conflicts detected! Multiple plugins are trying to use the same endpoint paths with conflicting HTTP methods:\n${conflictMessages}\n\nTo resolve this, you can:\n\t1. Use only one of the conflicting plugins\n\t2. Configure the plugins to use different paths (if supported)\n\t3. Ensure plugins use different HTTP methods for the same path\n`,\n\t\t);\n\t}\n}\n\nexport function getEndpoints<Option extends BetterAuthOptions>(\n\tctx: Awaitable<AuthContext>,\n\toptions: Option,\n) {\n\tconst pluginEndpoints =\n\t\toptions.plugins?.reduce<Record<string, Endpoint>>((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\n\ttype PluginEndpoint = UnionToIntersection<\n\t\tOption[\"plugins\"] extends Array<infer T>\n\t\t\t? T extends BetterAuthPlugin\n\t\t\t\t? T extends {\n\t\t\t\t\t\tendpoints: infer E;\n\t\t\t\t\t}\n\t\t\t\t\t? E\n\t\t\t\t\t: {}\n\t\t\t\t: {}\n\t\t\t: {}\n\t>;\n\n\tconst middlewares =\n\t\toptions.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\tconst authContext = await ctx;\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...authContext,\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 Middleware;\n\t\t\t\t\tmiddleware.options = m.middleware.options;\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\tconst baseEndpoints = {\n\t\tsignInSocial: signInSocial<Option>(),\n\t\tcallbackOAuth,\n\t\tgetSession: getSession<Option>(),\n\t\tsignOut,\n\t\tsignUpEmail: signUpEmail<Option>(),\n\t\tsignInEmail: signInEmail<Option>(),\n\t\tresetPassword,\n\t\tverifyEmail,\n\t\tsendVerificationEmail,\n\t\tchangeEmail,\n\t\tchangePassword,\n\t\tsetPassword,\n\t\tupdateUser: updateUser<Option>(),\n\t\tdeleteUser,\n\t\trequestPasswordReset,\n\t\trequestPasswordResetCallback,\n\t\tlistSessions: listSessions<Option>(),\n\t\trevokeSession,\n\t\trevokeSessions,\n\t\trevokeOtherSessions,\n\t\tlinkSocialAccount,\n\t\tlistUserAccounts,\n\t\tdeleteUserCallback,\n\t\tunlinkAccount,\n\t\trefreshToken,\n\t\tgetAccessToken,\n\t\taccountInfo,\n\t};\n\tconst endpoints = {\n\t\t...baseEndpoints,\n\t\t...pluginEndpoints,\n\t\tok,\n\t\terror,\n\t} as const;\n\tconst api = toAuthEndpoints(endpoints, ctx);\n\treturn {\n\t\tapi: api as typeof endpoints & PluginEndpoint,\n\t\tmiddlewares,\n\t};\n}\nexport const router = <Option extends BetterAuthOptions>(\n\tctx: AuthContext,\n\toptions: Option,\n) => {\n\tconst { api, middlewares } = getEndpoints(ctx, options);\n\tconst basePath = new URL(ctx.baseURL).pathname;\n\n\treturn createRouter(api, {\n\t\trouterContext: ctx,\n\t\topenapi: {\n\t\t\tdisabled: true,\n\t\t},\n\t\tbasePath,\n\t\trouterMiddleware: [\n\t\t\t{\n\t\t\t\tpath: \"/**\",\n\t\t\t\tmiddleware: originCheckMiddleware,\n\t\t\t},\n\t\t\t...middlewares,\n\t\t],\n\t\tallowedMediaTypes: [\"application/json\"],\n\t\tasync onRequest(req) {\n\t\t\t//handle disabled paths\n\t\t\tconst disabledPaths = ctx.options.disabledPaths || [];\n\t\t\tconst pathname = new URL(req.url).pathname.replace(/\\/+$/, \"\") || \"/\";\n\t\t\tconst normalizedPath =\n\t\t\t\tbasePath === \"/\"\n\t\t\t\t\t? pathname\n\t\t\t\t\t: pathname.startsWith(basePath)\n\t\t\t\t\t\t? pathname.slice(basePath.length).replace(/\\/+$/, \"\") || \"/\"\n\t\t\t\t\t\t: pathname;\n\t\t\tif (disabledPaths.includes(normalizedPath)) {\n\t\t\t\treturn new Response(\"Not Found\", { status: 404 });\n\t\t\t}\n\t\t\tfor (const plugin of ctx.options.plugins || []) {\n\t\t\t\tif (plugin.onRequest) {\n\t\t\t\t\tconst response = await plugin.onRequest(req, ctx);\n\t\t\t\t\tif (response && \"response\" in response) {\n\t\t\t\t\t\treturn response.response;\n\t\t\t\t\t}\n\t\t\t\t\tif (response && \"request\" in response) {\n\t\t\t\t\t\tconst rateLimitResponse = await onRequestRateLimit(\n\t\t\t\t\t\t\tresponse.request,\n\t\t\t\t\t\t\tctx,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (rateLimitResponse) {\n\t\t\t\t\t\t\treturn rateLimitResponse;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn response.request;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn onRequestRateLimit(req, ctx);\n\t\t},\n\t\tasync onResponse(res) {\n\t\t\tfor (const plugin of ctx.options.plugins || []) {\n\t\t\t\tif (plugin.onResponse) {\n\t\t\t\t\tconst response = await plugin.onResponse(res, ctx);\n\t\t\t\t\tif (response) {\n\t\t\t\t\t\treturn response.response;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn res;\n\t\t},\n\t\tonError(e) {\n\t\t\tif (e instanceof APIError && e.status === \"FOUND\") {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (options.onAPIError?.throw) {\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t\tif (options.onAPIError?.onError) {\n\t\t\t\toptions.onAPIError.onError(e, ctx);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst optLogLevel = options.logger?.level;\n\t\t\tconst log =\n\t\t\t\toptLogLevel === \"error\" ||\n\t\t\t\toptLogLevel === \"warn\" ||\n\t\t\t\toptLogLevel === \"debug\"\n\t\t\t\t\t? logger\n\t\t\t\t\t: undefined;\n\t\t\tif (options.logger?.disabled !== true) {\n\t\t\t\tif (\n\t\t\t\t\te &&\n\t\t\t\t\ttypeof e === \"object\" &&\n\t\t\t\t\t\"message\" in e &&\n\t\t\t\t\ttypeof e.message === \"string\"\n\t\t\t\t) {\n\t\t\t\t\tif (\n\t\t\t\t\t\te.message.includes(\"no column\") ||\n\t\t\t\t\t\te.message.includes(\"column\") ||\n\t\t\t\t\t\te.message.includes(\"relation\") ||\n\t\t\t\t\t\te.message.includes(\"table\") ||\n\t\t\t\t\t\te.message.includes(\"does not exist\")\n\t\t\t\t\t) {\n\t\t\t\t\t\tctx.logger?.error(e.message);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (e instanceof APIError) {\n\t\t\t\t\tif (e.status === \"INTERNAL_SERVER_ERROR\") {\n\t\t\t\t\t\tctx.logger.error(e.status, e);\n\t\t\t\t\t}\n\t\t\t\t\tlog?.error(e.message);\n\t\t\t\t} else {\n\t\t\t\t\tctx.logger?.error(\n\t\t\t\t\t\te && typeof e === \"object\" && \"name\" in e ? (e.name as string) : \"\",\n\t\t\t\t\t\te,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t});\n};\n\nexport {\n\ttype AuthEndpoint,\n\ttype AuthMiddleware,\n\tcreateAuthEndpoint,\n\tcreateAuthMiddleware,\n\toptionsMiddleware,\n} from \"@better-auth/core/api\";\nexport { APIError } from \"better-call\";\nexport { getIp } from \"../utils/get-request-ip\";\nexport * from \"./middlewares\";\nexport * from \"./routes\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA8CA,SAAgB,uBACf,SACA,UACC;CACD,MAAM,mCAAmB,IAAI,KAG1B;AAEH,SAAQ,SAAS,SAAS,WAAW;AACpC,MAAI,OAAO,WACV;QAAK,MAAM,CAAC,KAAK,aAAa,OAAO,QAAQ,OAAO,UAAU,CAC7D,KACC,YACA,UAAU,YACV,OAAO,SAAS,SAAS,UACxB;IACD,MAAM,OAAO,SAAS;IACtB,IAAIA,UAAoB,EAAE;AAC1B,QAAI,SAAS,WAAW,YAAY,SAAS,SAC5C;SAAI,MAAM,QAAQ,SAAS,QAAQ,OAAO,CACzC,WAAU,SAAS,QAAQ;cACjB,OAAO,SAAS,QAAQ,WAAW,SAC7C,WAAU,CAAC,SAAS,QAAQ,OAAO;;AAGrC,QAAI,QAAQ,WAAW,EACtB,WAAU,CAAC,IAAI;AAGhB,QAAI,CAAC,iBAAiB,IAAI,KAAK,CAC9B,kBAAiB,IAAI,MAAM,EAAE,CAAC;AAE/B,qBAAiB,IAAI,KAAK,CAAE,KAAK;KAChC,UAAU,OAAO;KACjB,aAAa;KACb;K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WAAW,wBAChB,KAAI,OAAO,MAAM,EAAE,QAAQ,EAAE;AAE9B,UAAK,MAAM,EAAE,QAAQ;UAErB,KAAI,QAAQ,MACX,KAAK,OAAO,MAAM,YAAY,UAAU,IAAK,EAAE,OAAkB,IACjE,EACA;;;EAIJ,CAAC"}
1
+ {"version":3,"file":"index.mjs","names":["methods: string[]","conflicts: {\n\t\tpath: string;\n\t\tplugins: string[];\n\t\tconflictingMethods: string[];\n\t}[]","conflictingMethods: string[]","APIError"],"sources":["../../src/api/index.ts"],"sourcesContent":["import type {\n\tAuthContext,\n\tAwaitable,\n\tBetterAuthOptions,\n\tBetterAuthPlugin,\n} from \"@better-auth/core\";\nimport type { InternalLogger } from \"@better-auth/core/env\";\nimport { logger } from \"@better-auth/core/env\";\nimport type { Endpoint, Middleware } from \"better-call\";\nimport { APIError, createRouter } from \"better-call\";\nimport type { UnionToIntersection } from \"../types/helper\";\nimport { originCheckMiddleware } from \"./middlewares\";\nimport { onRequestRateLimit } from \"./rate-limiter\";\nimport {\n\taccountInfo,\n\tcallbackOAuth,\n\tchangeEmail,\n\tchangePassword,\n\tdeleteUser,\n\tdeleteUserCallback,\n\terror,\n\tgetAccessToken,\n\tgetSession,\n\tlinkSocialAccount,\n\tlistSessions,\n\tlistUserAccounts,\n\tok,\n\trefreshToken,\n\trequestPasswordReset,\n\trequestPasswordResetCallback,\n\tresetPassword,\n\trevokeOtherSessions,\n\trevokeSession,\n\trevokeSessions,\n\tsendVerificationEmail,\n\tsetPassword,\n\tsignInEmail,\n\tsignInSocial,\n\tsignOut,\n\tsignUpEmail,\n\tunlinkAccount,\n\tupdateUser,\n\tverifyEmail,\n} from \"./routes\";\nimport { toAuthEndpoints } from \"./to-auth-endpoints\";\n\nexport function checkEndpointConflicts(\n\toptions: BetterAuthOptions,\n\tlogger: InternalLogger,\n) {\n\tconst endpointRegistry = new Map<\n\t\tstring,\n\t\t{ pluginId: string; endpointKey: string; methods: string[] }[]\n\t>();\n\n\toptions.plugins?.forEach((plugin) => {\n\t\tif (plugin.endpoints) {\n\t\t\tfor (const [key, endpoint] of Object.entries(plugin.endpoints)) {\n\t\t\t\tif (\n\t\t\t\t\tendpoint &&\n\t\t\t\t\t\"path\" in endpoint &&\n\t\t\t\t\ttypeof endpoint.path === \"string\"\n\t\t\t\t) {\n\t\t\t\t\tconst path = endpoint.path;\n\t\t\t\t\tlet methods: string[] = [];\n\t\t\t\t\tif (endpoint.options && \"method\" in endpoint.options) {\n\t\t\t\t\t\tif (Array.isArray(endpoint.options.method)) {\n\t\t\t\t\t\t\tmethods = endpoint.options.method;\n\t\t\t\t\t\t} else if (typeof endpoint.options.method === \"string\") {\n\t\t\t\t\t\t\tmethods = [endpoint.options.method];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (methods.length === 0) {\n\t\t\t\t\t\tmethods = [\"*\"];\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!endpointRegistry.has(path)) {\n\t\t\t\t\t\tendpointRegistry.set(path, []);\n\t\t\t\t\t}\n\t\t\t\t\tendpointRegistry.get(path)!.push({\n\t\t\t\t\t\tpluginId: plugin.id,\n\t\t\t\t\t\tendpointKey: key,\n\t\t\t\t\t\tmethods,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n\n\tconst conflicts: {\n\t\tpath: string;\n\t\tplugins: string[];\n\t\tconflictingMethods: string[];\n\t}[] = [];\n\tfor (const [path, entries] of endpointRegistry.entries()) {\n\t\tif (entries.length > 1) {\n\t\t\tconst methodMap = new Map<string, string[]>();\n\t\t\tlet hasConflict = false;\n\n\t\t\tfor (const entry of entries) {\n\t\t\t\tfor (const method of entry.methods) {\n\t\t\t\t\tif (!methodMap.has(method)) {\n\t\t\t\t\t\tmethodMap.set(method, []);\n\t\t\t\t\t}\n\t\t\t\t\tmethodMap.get(method)!.push(entry.pluginId);\n\n\t\t\t\t\tif (methodMap.get(method)!.length > 1) {\n\t\t\t\t\t\thasConflict = true;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (method === \"*\" && entries.length > 1) {\n\t\t\t\t\t\thasConflict = true;\n\t\t\t\t\t} else if (method !== \"*\" && methodMap.has(\"*\")) {\n\t\t\t\t\t\thasConflict = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (hasConflict) {\n\t\t\t\tconst uniquePlugins = [...new Set(entries.map((e) => e.pluginId))];\n\t\t\t\tconst conflictingMethods: string[] = [];\n\n\t\t\t\tfor (const [method, plugins] of methodMap.entries()) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tplugins.length > 1 ||\n\t\t\t\t\t\t(method === \"*\" && entries.length > 1) ||\n\t\t\t\t\t\t(method !== \"*\" && methodMap.has(\"*\"))\n\t\t\t\t\t) {\n\t\t\t\t\t\tconflictingMethods.push(method);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconflicts.push({\n\t\t\t\t\tpath,\n\t\t\t\t\tplugins: uniquePlugins,\n\t\t\t\t\tconflictingMethods,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tif (conflicts.length > 0) {\n\t\tconst conflictMessages = conflicts\n\t\t\t.map(\n\t\t\t\t(conflict) =>\n\t\t\t\t\t` - \"${conflict.path}\" [${conflict.conflictingMethods.join(\", \")}] used by plugins: ${conflict.plugins.join(\", \")}`,\n\t\t\t)\n\t\t\t.join(\"\\n\");\n\t\tlogger.error(\n\t\t\t`Endpoint path conflicts detected! Multiple plugins are trying to use the same endpoint paths with conflicting HTTP methods:\n${conflictMessages}\n\nTo resolve this, you can:\n\t1. Use only one of the conflicting plugins\n\t2. Configure the plugins to use different paths (if supported)\n\t3. Ensure plugins use different HTTP methods for the same path\n`,\n\t\t);\n\t}\n}\n\nexport function getEndpoints<Option extends BetterAuthOptions>(\n\tctx: Awaitable<AuthContext>,\n\toptions: Option,\n) {\n\tconst pluginEndpoints =\n\t\toptions.plugins?.reduce<Record<string, Endpoint>>((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\n\ttype PluginEndpoint = UnionToIntersection<\n\t\tOption[\"plugins\"] extends Array<infer T>\n\t\t\t? T extends BetterAuthPlugin\n\t\t\t\t? T extends {\n\t\t\t\t\t\tendpoints: infer E;\n\t\t\t\t\t}\n\t\t\t\t\t? E\n\t\t\t\t\t: {}\n\t\t\t\t: {}\n\t\t\t: {}\n\t>;\n\n\tconst middlewares =\n\t\toptions.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\tconst authContext = await ctx;\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...authContext,\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 Middleware;\n\t\t\t\t\tmiddleware.options = m.middleware.options;\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\tconst baseEndpoints = {\n\t\tsignInSocial: signInSocial<Option>(),\n\t\tcallbackOAuth,\n\t\tgetSession: getSession<Option>(),\n\t\tsignOut,\n\t\tsignUpEmail: signUpEmail<Option>(),\n\t\tsignInEmail: signInEmail<Option>(),\n\t\tresetPassword,\n\t\tverifyEmail,\n\t\tsendVerificationEmail,\n\t\tchangeEmail,\n\t\tchangePassword,\n\t\tsetPassword,\n\t\tupdateUser: updateUser<Option>(),\n\t\tdeleteUser,\n\t\trequestPasswordReset,\n\t\trequestPasswordResetCallback,\n\t\tlistSessions: listSessions<Option>(),\n\t\trevokeSession,\n\t\trevokeSessions,\n\t\trevokeOtherSessions,\n\t\tlinkSocialAccount,\n\t\tlistUserAccounts,\n\t\tdeleteUserCallback,\n\t\tunlinkAccount,\n\t\trefreshToken,\n\t\tgetAccessToken,\n\t\taccountInfo,\n\t};\n\tconst endpoints = {\n\t\t...baseEndpoints,\n\t\t...pluginEndpoints,\n\t\tok,\n\t\terror,\n\t} as const;\n\tconst api = toAuthEndpoints(endpoints, ctx);\n\treturn {\n\t\tapi: api as typeof endpoints & PluginEndpoint,\n\t\tmiddlewares,\n\t};\n}\nexport const router = <Option extends BetterAuthOptions>(\n\tctx: AuthContext,\n\toptions: Option,\n) => {\n\tconst { api, middlewares } = getEndpoints(ctx, options);\n\tconst basePath = new URL(ctx.baseURL).pathname;\n\n\treturn createRouter(api, {\n\t\trouterContext: ctx,\n\t\topenapi: {\n\t\t\tdisabled: true,\n\t\t},\n\t\tbasePath,\n\t\trouterMiddleware: [\n\t\t\t{\n\t\t\t\tpath: \"/**\",\n\t\t\t\tmiddleware: originCheckMiddleware,\n\t\t\t},\n\t\t\t...middlewares,\n\t\t],\n\t\tallowedMediaTypes: [\"application/json\"],\n\t\tasync onRequest(req) {\n\t\t\t//handle disabled paths\n\t\t\tconst disabledPaths = ctx.options.disabledPaths || [];\n\t\t\tconst pathname = new URL(req.url).pathname.replace(/\\/+$/, \"\") || \"/\";\n\n\t\t\tconst normalizedPath =\n\t\t\t\tbasePath === \"/\"\n\t\t\t\t\t? pathname\n\t\t\t\t\t: pathname.startsWith(basePath)\n\t\t\t\t\t\t? pathname.slice(basePath.length).replace(/\\/+$/, \"\") || \"/\"\n\t\t\t\t\t\t: pathname;\n\t\t\tif (disabledPaths.includes(normalizedPath)) {\n\t\t\t\treturn new Response(\"Not Found\", { status: 404 });\n\t\t\t}\n\t\t\tfor (const plugin of ctx.options.plugins || []) {\n\t\t\t\tif (plugin.onRequest) {\n\t\t\t\t\tconst response = await plugin.onRequest(req, ctx);\n\t\t\t\t\tif (response && \"response\" in response) {\n\t\t\t\t\t\treturn response.response;\n\t\t\t\t\t}\n\t\t\t\t\tif (response && \"request\" in response) {\n\t\t\t\t\t\tconst rateLimitResponse = await onRequestRateLimit(\n\t\t\t\t\t\t\tresponse.request,\n\t\t\t\t\t\t\tctx,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (rateLimitResponse) {\n\t\t\t\t\t\t\treturn rateLimitResponse;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn response.request;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn onRequestRateLimit(req, ctx);\n\t\t},\n\t\tasync onResponse(res) {\n\t\t\tfor (const plugin of ctx.options.plugins || []) {\n\t\t\t\tif (plugin.onResponse) {\n\t\t\t\t\tconst response = await plugin.onResponse(res, ctx);\n\t\t\t\t\tif (response) {\n\t\t\t\t\t\treturn response.response;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn res;\n\t\t},\n\t\tonError(e) {\n\t\t\tif (e instanceof APIError && e.status === \"FOUND\") {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (options.onAPIError?.throw) {\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t\tif (options.onAPIError?.onError) {\n\t\t\t\toptions.onAPIError.onError(e, ctx);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst optLogLevel = options.logger?.level;\n\t\t\tconst log =\n\t\t\t\toptLogLevel === \"error\" ||\n\t\t\t\toptLogLevel === \"warn\" ||\n\t\t\t\toptLogLevel === \"debug\"\n\t\t\t\t\t? logger\n\t\t\t\t\t: undefined;\n\t\t\tif (options.logger?.disabled !== true) {\n\t\t\t\tif (\n\t\t\t\t\te &&\n\t\t\t\t\ttypeof e === \"object\" &&\n\t\t\t\t\t\"message\" in e &&\n\t\t\t\t\ttypeof e.message === \"string\"\n\t\t\t\t) {\n\t\t\t\t\tif (\n\t\t\t\t\t\te.message.includes(\"no column\") ||\n\t\t\t\t\t\te.message.includes(\"column\") ||\n\t\t\t\t\t\te.message.includes(\"relation\") ||\n\t\t\t\t\t\te.message.includes(\"table\") ||\n\t\t\t\t\t\te.message.includes(\"does not exist\")\n\t\t\t\t\t) {\n\t\t\t\t\t\tctx.logger?.error(e.message);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (e instanceof APIError) {\n\t\t\t\t\tif (e.status === \"INTERNAL_SERVER_ERROR\") {\n\t\t\t\t\t\tctx.logger.error(e.status, e);\n\t\t\t\t\t}\n\t\t\t\t\tlog?.error(e.message);\n\t\t\t\t} else {\n\t\t\t\t\tctx.logger?.error(\n\t\t\t\t\t\te && typeof e === \"object\" && \"name\" in e ? (e.name as string) : \"\",\n\t\t\t\t\t\te,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t});\n};\n\nexport {\n\ttype AuthEndpoint,\n\ttype AuthMiddleware,\n\tcreateAuthEndpoint,\n\tcreateAuthMiddleware,\n\toptionsMiddleware,\n} from \"@better-auth/core/api\";\nexport { APIError } from \"better-call\";\nexport { getIp } from \"../utils/get-request-ip\";\nexport * from \"./middlewares\";\nexport * from \"./routes\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA8CA,SAAgB,uBACf,SACA,UACC;CACD,MAAM,mCAAmB,IAAI,KAG1B;AAEH,SAAQ,SAAS,SAAS,WAAW;AACpC,MAAI,OAAO,WACV;QAAK,MAAM,CAAC,KAAK,aAAa,OAAO,QAAQ,OAAO,UAAU,CAC7D,KACC,YACA,UAAU,YACV,OAAO,SAAS,SAAS,UACxB;IACD,MAAM,OAAO,SAAS;IACtB,IAAIA,UAAoB,EAAE;AAC1B,QAAI,SAAS,WAAW,YAAY,SAAS,SAC5C;SAAI,MAAM,QAAQ,SAAS,QAAQ,OAAO,CACzC,WAAU,SAAS,QAAQ;cACjB,OAAO,SAAS,QAAQ,WAAW,SAC7C,WAAU,CAAC,SAAS,QAAQ,OAAO;;AAGrC,QAAI,QAAQ,WAAW,EACtB,WAAU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W,IAC9B,EAAE,QAAQ,SAAS,QAAQ,IAC3B,EAAE,QAAQ,SAAS,iBAAiB,EACnC;AACD,UAAI,QAAQ,MAAM,EAAE,QAAQ;AAC5B;;;AAIF,QAAI,aAAaA,YAAU;AAC1B,SAAI,EAAE,WAAW,wBAChB,KAAI,OAAO,MAAM,EAAE,QAAQ,EAAE;AAE9B,UAAK,MAAM,EAAE,QAAQ;UAErB,KAAI,QAAQ,MACX,KAAK,OAAO,MAAM,YAAY,UAAU,IAAK,EAAE,OAAkB,IACjE,EACA;;;EAIJ,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { GenericEndpointContext } from "@better-auth/core";
2
- import * as better_call684 from "better-call";
2
+ import * as better_call764 from "better-call";
3
3
 
4
4
  //#region src/api/middlewares/origin-check.d.ts
5
5
 
@@ -7,8 +7,8 @@ import * as better_call684 from "better-call";
7
7
  * A middleware to validate callbackURL and origin against
8
8
  * trustedOrigins.
9
9
  */
10
- declare const originCheckMiddleware: (inputContext: better_call684.MiddlewareInputContext<better_call684.MiddlewareOptions>) => Promise<void>;
11
- declare const originCheck: (getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: better_call684.MiddlewareInputContext<better_call684.MiddlewareOptions>) => Promise<void>;
10
+ declare const originCheckMiddleware: (inputContext: better_call764.MiddlewareInputContext<better_call764.MiddlewareOptions>) => Promise<void>;
11
+ declare const originCheck: (getValue: (ctx: GenericEndpointContext) => string | string[]) => (inputContext: better_call764.MiddlewareInputContext<better_call764.MiddlewareOptions>) => Promise<void>;
12
12
  //#endregion
13
13
  export { originCheck, originCheckMiddleware };
14
14
  //# sourceMappingURL=origin-check.d.mts.map
@@ -1,11 +1,11 @@
1
1
  import * as _better_auth_core_oauth28 from "@better-auth/core/oauth2";
2
2
  import * as z from "zod";
3
- import * as better_call688 from "better-call";
3
+ import * as better_call696 from "better-call";
4
4
 
5
5
  //#region src/api/routes/account.d.ts
6
- declare const listUserAccounts: better_call688.StrictEndpoint<"/list-accounts", {
6
+ declare const listUserAccounts: better_call696.StrictEndpoint<"/list-accounts", {
7
7
  method: "GET";
8
- use: ((inputContext: better_call688.MiddlewareInputContext<better_call688.MiddlewareOptions>) => Promise<{
8
+ use: ((inputContext: better_call696.MiddlewareInputContext<better_call696.MiddlewareOptions>) => Promise<{
9
9
  session: {
10
10
  session: Record<string, any> & {
11
11
  id: string;
@@ -87,7 +87,7 @@ declare const listUserAccounts: better_call688.StrictEndpoint<"/list-accounts",
87
87
  userId: string;
88
88
  scopes: string[];
89
89
  }[]>;
90
- declare const linkSocialAccount: better_call688.StrictEndpoint<"/link-social", {
90
+ declare const linkSocialAccount: better_call696.StrictEndpoint<"/link-social", {
91
91
  method: "POST";
92
92
  requireHeaders: true;
93
93
  body: z.ZodObject<{
@@ -106,7 +106,7 @@ declare const linkSocialAccount: better_call688.StrictEndpoint<"/link-social", {
106
106
  disableRedirect: z.ZodOptional<z.ZodBoolean>;
107
107
  additionalData: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
108
108
  }, z.core.$strip>;
109
- use: ((inputContext: better_call688.MiddlewareInputContext<better_call688.MiddlewareOptions>) => Promise<{
109
+ use: ((inputContext: better_call696.MiddlewareInputContext<better_call696.MiddlewareOptions>) => Promise<{
110
110
  session: {
111
111
  session: Record<string, any> & {
112
112
  id: string;
@@ -165,13 +165,13 @@ declare const linkSocialAccount: better_call688.StrictEndpoint<"/link-social", {
165
165
  url: string;
166
166
  redirect: boolean;
167
167
  }>;
168
- declare const unlinkAccount: better_call688.StrictEndpoint<"/unlink-account", {
168
+ declare const unlinkAccount: better_call696.StrictEndpoint<"/unlink-account", {
169
169
  method: "POST";
170
170
  body: z.ZodObject<{
171
171
  providerId: z.ZodString;
172
172
  accountId: z.ZodOptional<z.ZodString>;
173
173
  }, z.core.$strip>;
174
- use: ((inputContext: better_call688.MiddlewareInputContext<better_call688.MiddlewareOptions>) => Promise<{
174
+ use: ((inputContext: better_call696.MiddlewareInputContext<better_call696.MiddlewareOptions>) => Promise<{
175
175
  session: {
176
176
  session: Record<string, any> & {
177
177
  id: string;
@@ -219,7 +219,7 @@ declare const unlinkAccount: better_call688.StrictEndpoint<"/unlink-account", {
219
219
  }, {
220
220
  status: boolean;
221
221
  }>;
222
- declare const getAccessToken: better_call688.StrictEndpoint<"/get-access-token", {
222
+ declare const getAccessToken: better_call696.StrictEndpoint<"/get-access-token", {
223
223
  method: "POST";
224
224
  body: z.ZodObject<{
225
225
  providerId: z.ZodString;
@@ -274,7 +274,7 @@ declare const getAccessToken: better_call688.StrictEndpoint<"/get-access-token",
274
274
  scopes: string[];
275
275
  idToken: string | undefined;
276
276
  }>;
277
- declare const refreshToken: better_call688.StrictEndpoint<"/refresh-token", {
277
+ declare const refreshToken: better_call696.StrictEndpoint<"/refresh-token", {
278
278
  method: "POST";
279
279
  body: z.ZodObject<{
280
280
  providerId: z.ZodString;
@@ -333,9 +333,9 @@ declare const refreshToken: better_call688.StrictEndpoint<"/refresh-token", {
333
333
  providerId: string;
334
334
  accountId: string;
335
335
  }>;
336
- declare const accountInfo: better_call688.StrictEndpoint<"/account-info", {
336
+ declare const accountInfo: better_call696.StrictEndpoint<"/account-info", {
337
337
  method: "GET";
338
- use: ((inputContext: better_call688.MiddlewareInputContext<better_call688.MiddlewareOptions>) => Promise<{
338
+ use: ((inputContext: better_call696.MiddlewareInputContext<better_call696.MiddlewareOptions>) => Promise<{
339
339
  session: {
340
340
  session: Record<string, any> & {
341
341
  id: string;
@@ -1,8 +1,8 @@
1
1
  import * as z from "zod";
2
- import * as better_call721 from "better-call";
2
+ import * as better_call754 from "better-call";
3
3
 
4
4
  //#region src/api/routes/callback.d.ts
5
- declare const callbackOAuth: better_call721.StrictEndpoint<"/callback/:id", {
5
+ declare const callbackOAuth: better_call754.StrictEndpoint<"/callback/:id", {
6
6
  method: ("GET" | "POST")[];
7
7
  operationId: string;
8
8
  body: z.ZodOptional<z.ZodObject<{
@@ -2,7 +2,7 @@ import { User } from "../../types/models.mjs";
2
2
  import "../../types/index.mjs";
3
3
  import { GenericEndpointContext } from "@better-auth/core";
4
4
  import * as z from "zod";
5
- import * as better_call750 from "better-call";
5
+ import * as better_call710 from "better-call";
6
6
 
7
7
  //#region src/api/routes/email-verification.d.ts
8
8
  declare function createEmailVerificationToken(secret: string, email: string,
@@ -22,7 +22,7 @@ extraPayload?: Record<string, any>): Promise<string>;
22
22
  * A function to send a verification email to the user
23
23
  */
24
24
  declare function sendVerificationEmailFn(ctx: GenericEndpointContext, user: User): Promise<void>;
25
- declare const sendVerificationEmail: better_call750.StrictEndpoint<"/send-verification-email", {
25
+ declare const sendVerificationEmail: better_call710.StrictEndpoint<"/send-verification-email", {
26
26
  method: "POST";
27
27
  operationId: string;
28
28
  body: z.ZodObject<{
@@ -97,14 +97,14 @@ declare const sendVerificationEmail: better_call750.StrictEndpoint<"/send-verifi
97
97
  }, {
98
98
  status: boolean;
99
99
  }>;
100
- declare const verifyEmail: better_call750.StrictEndpoint<"/verify-email", {
100
+ declare const verifyEmail: better_call710.StrictEndpoint<"/verify-email", {
101
101
  method: "GET";
102
102
  operationId: string;
103
103
  query: z.ZodObject<{
104
104
  token: z.ZodString;
105
105
  callbackURL: z.ZodOptional<z.ZodString>;
106
106
  }, z.core.$strip>;
107
- use: ((inputContext: better_call750.MiddlewareInputContext<better_call750.MiddlewareOptions>) => Promise<void>)[];
107
+ use: ((inputContext: better_call710.MiddlewareInputContext<better_call710.MiddlewareOptions>) => Promise<void>)[];
108
108
  metadata: {
109
109
  openapi: {
110
110
  description: string;
@@ -1,7 +1,7 @@
1
- import * as better_call683 from "better-call";
1
+ import * as better_call695 from "better-call";
2
2
 
3
3
  //#region src/api/routes/error.d.ts
4
- declare const error: better_call683.StrictEndpoint<"/error", {
4
+ declare const error: better_call695.StrictEndpoint<"/error", {
5
5
  method: "GET";
6
6
  metadata: {
7
7
  openapi: {
@@ -1,7 +1,7 @@
1
- import * as better_call720 from "better-call";
1
+ import * as better_call753 from "better-call";
2
2
 
3
3
  //#region src/api/routes/ok.d.ts
4
- declare const ok: better_call720.StrictEndpoint<"/ok", {
4
+ declare const ok: better_call753.StrictEndpoint<"/ok", {
5
5
  method: "GET";
6
6
  metadata: {
7
7
  openapi: {
@@ -1,8 +1,8 @@
1
1
  import * as z from "zod";
2
- import * as better_call722 from "better-call";
2
+ import * as better_call755 from "better-call";
3
3
 
4
4
  //#region src/api/routes/reset-password.d.ts
5
- declare const requestPasswordReset: better_call722.StrictEndpoint<"/request-password-reset", {
5
+ declare const requestPasswordReset: better_call755.StrictEndpoint<"/request-password-reset", {
6
6
  method: "POST";
7
7
  body: z.ZodObject<{
8
8
  email: z.ZodEmail;
@@ -38,13 +38,13 @@ declare const requestPasswordReset: better_call722.StrictEndpoint<"/request-pass
38
38
  status: boolean;
39
39
  message: string;
40
40
  }>;
41
- declare const requestPasswordResetCallback: better_call722.StrictEndpoint<"/reset-password/:token", {
41
+ declare const requestPasswordResetCallback: better_call755.StrictEndpoint<"/reset-password/:token", {
42
42
  method: "GET";
43
43
  operationId: string;
44
44
  query: z.ZodObject<{
45
45
  callbackURL: z.ZodString;
46
46
  }, z.core.$strip>;
47
- use: ((inputContext: better_call722.MiddlewareInputContext<better_call722.MiddlewareOptions>) => Promise<void>)[];
47
+ use: ((inputContext: better_call755.MiddlewareInputContext<better_call755.MiddlewareOptions>) => Promise<void>)[];
48
48
  metadata: {
49
49
  openapi: {
50
50
  operationId: string;
@@ -86,7 +86,7 @@ declare const requestPasswordResetCallback: better_call722.StrictEndpoint<"/rese
86
86
  };
87
87
  };
88
88
  }, never>;
89
- declare const resetPassword: better_call722.StrictEndpoint<"/reset-password", {
89
+ declare const resetPassword: better_call755.StrictEndpoint<"/reset-password", {
90
90
  method: "POST";
91
91
  operationId: string;
92
92
  query: z.ZodOptional<z.ZodObject<{
@@ -3,10 +3,10 @@ import { InferSession, InferUser, Session, User } from "../../types/models.mjs";
3
3
  import "../../types/index.mjs";
4
4
  import { BetterAuthOptions, GenericEndpointContext } from "@better-auth/core";
5
5
  import * as z from "zod";
6
- import * as better_call727 from "better-call";
6
+ import * as better_call714 from "better-call";
7
7
 
8
8
  //#region src/api/routes/session.d.ts
9
- declare const getSession: <Option extends BetterAuthOptions>() => better_call727.StrictEndpoint<"/get-session", {
9
+ declare const getSession: <Option extends BetterAuthOptions>() => better_call714.StrictEndpoint<"/get-session", {
10
10
  method: "GET";
11
11
  operationId: string;
12
12
  query: z.ZodOptional<z.ZodObject<{
@@ -56,7 +56,7 @@ declare const getSessionFromCtx: <U extends Record<string, any> = Record<string,
56
56
  /**
57
57
  * The middleware forces the endpoint to require a valid session.
58
58
  */
59
- declare const sessionMiddleware: (inputContext: better_call727.MiddlewareInputContext<better_call727.MiddlewareOptions>) => Promise<{
59
+ declare const sessionMiddleware: (inputContext: better_call714.MiddlewareInputContext<better_call714.MiddlewareOptions>) => Promise<{
60
60
  session: {
61
61
  session: Record<string, any> & {
62
62
  id: string;
@@ -84,7 +84,7 @@ declare const sessionMiddleware: (inputContext: better_call727.MiddlewareInputCo
84
84
  * This should be used for sensitive operations like password changes, account deletion, etc.
85
85
  * to ensure that revoked sessions cannot be used even if they're still cached in cookies.
86
86
  */
87
- declare const sensitiveSessionMiddleware: (inputContext: better_call727.MiddlewareInputContext<better_call727.MiddlewareOptions>) => Promise<{
87
+ declare const sensitiveSessionMiddleware: (inputContext: better_call714.MiddlewareInputContext<better_call714.MiddlewareOptions>) => Promise<{
88
88
  session: {
89
89
  session: Record<string, any> & {
90
90
  id: string;
@@ -111,7 +111,7 @@ declare const sensitiveSessionMiddleware: (inputContext: better_call727.Middlewa
111
111
  * This middleware allows you to call the endpoint on the client if session is valid.
112
112
  * However, if called on the server, no session is required.
113
113
  */
114
- declare const requestOnlySessionMiddleware: (inputContext: better_call727.MiddlewareInputContext<better_call727.MiddlewareOptions>) => Promise<{
114
+ declare const requestOnlySessionMiddleware: (inputContext: better_call714.MiddlewareInputContext<better_call714.MiddlewareOptions>) => Promise<{
115
115
  session: {
116
116
  session: Record<string, any> & {
117
117
  id: string;
@@ -141,7 +141,7 @@ declare const requestOnlySessionMiddleware: (inputContext: better_call727.Middle
141
141
  * Session freshness check will be skipped if the session config's freshAge
142
142
  * is set to 0
143
143
  */
144
- declare const freshSessionMiddleware: (inputContext: better_call727.MiddlewareInputContext<better_call727.MiddlewareOptions>) => Promise<{
144
+ declare const freshSessionMiddleware: (inputContext: better_call714.MiddlewareInputContext<better_call714.MiddlewareOptions>) => Promise<{
145
145
  session: {
146
146
  session: Record<string, any> & {
147
147
  id: string;
@@ -167,10 +167,10 @@ declare const freshSessionMiddleware: (inputContext: better_call727.MiddlewareIn
167
167
  /**
168
168
  * user active sessions list
169
169
  */
170
- declare const listSessions: <Option extends BetterAuthOptions>() => better_call727.StrictEndpoint<"/list-sessions", {
170
+ declare const listSessions: <Option extends BetterAuthOptions>() => better_call714.StrictEndpoint<"/list-sessions", {
171
171
  method: "GET";
172
172
  operationId: string;
173
- use: ((inputContext: better_call727.MiddlewareInputContext<better_call727.MiddlewareOptions>) => Promise<{
173
+ use: ((inputContext: better_call714.MiddlewareInputContext<better_call714.MiddlewareOptions>) => Promise<{
174
174
  session: {
175
175
  session: Record<string, any> & {
176
176
  id: string;
@@ -219,12 +219,12 @@ declare const listSessions: <Option extends BetterAuthOptions>() => better_call7
219
219
  /**
220
220
  * revoke a single session
221
221
  */
222
- declare const revokeSession: better_call727.StrictEndpoint<"/revoke-session", {
222
+ declare const revokeSession: better_call714.StrictEndpoint<"/revoke-session", {
223
223
  method: "POST";
224
224
  body: z.ZodObject<{
225
225
  token: z.ZodString;
226
226
  }, z.core.$strip>;
227
- use: ((inputContext: better_call727.MiddlewareInputContext<better_call727.MiddlewareOptions>) => Promise<{
227
+ use: ((inputContext: better_call714.MiddlewareInputContext<better_call714.MiddlewareOptions>) => Promise<{
228
228
  session: {
229
229
  session: Record<string, any> & {
230
230
  id: string;
@@ -294,9 +294,9 @@ declare const revokeSession: better_call727.StrictEndpoint<"/revoke-session", {
294
294
  /**
295
295
  * revoke all user sessions
296
296
  */
297
- declare const revokeSessions: better_call727.StrictEndpoint<"/revoke-sessions", {
297
+ declare const revokeSessions: better_call714.StrictEndpoint<"/revoke-sessions", {
298
298
  method: "POST";
299
- use: ((inputContext: better_call727.MiddlewareInputContext<better_call727.MiddlewareOptions>) => Promise<{
299
+ use: ((inputContext: better_call714.MiddlewareInputContext<better_call714.MiddlewareOptions>) => Promise<{
300
300
  session: {
301
301
  session: Record<string, any> & {
302
302
  id: string;
@@ -347,10 +347,10 @@ declare const revokeSessions: better_call727.StrictEndpoint<"/revoke-sessions",
347
347
  }, {
348
348
  status: boolean;
349
349
  }>;
350
- declare const revokeOtherSessions: better_call727.StrictEndpoint<"/revoke-other-sessions", {
350
+ declare const revokeOtherSessions: better_call714.StrictEndpoint<"/revoke-other-sessions", {
351
351
  method: "POST";
352
352
  requireHeaders: true;
353
- use: ((inputContext: better_call727.MiddlewareInputContext<better_call727.MiddlewareOptions>) => Promise<{
353
+ use: ((inputContext: better_call714.MiddlewareInputContext<better_call714.MiddlewareOptions>) => Promise<{
354
354
  session: {
355
355
  session: Record<string, any> & {
356
356
  id: string;
@@ -2,7 +2,7 @@ import { InferUser } from "../../types/models.mjs";
2
2
  import "../../types/index.mjs";
3
3
  import { BetterAuthOptions } from "@better-auth/core";
4
4
  import * as z from "zod";
5
- import * as better_call748 from "better-call";
5
+ import * as better_call760 from "better-call";
6
6
 
7
7
  //#region src/api/routes/sign-in.d.ts
8
8
  declare const socialSignInBodySchema: z.ZodObject<{
@@ -23,7 +23,7 @@ declare const socialSignInBodySchema: z.ZodObject<{
23
23
  loginHint: z.ZodOptional<z.ZodString>;
24
24
  additionalData: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
25
25
  }, z.core.$strip>;
26
- declare const signInSocial: <O extends BetterAuthOptions>() => better_call748.StrictEndpoint<"/sign-in/social", {
26
+ declare const signInSocial: <O extends BetterAuthOptions>() => better_call760.StrictEndpoint<"/sign-in/social", {
27
27
  method: "POST";
28
28
  operationId: string;
29
29
  body: z.ZodObject<{
@@ -98,7 +98,7 @@ declare const signInSocial: <O extends BetterAuthOptions>() => better_call748.St
98
98
  url: undefined;
99
99
  user: InferUser<O>;
100
100
  }>;
101
- declare const signInEmail: <O extends BetterAuthOptions>() => better_call748.StrictEndpoint<"/sign-in/email", {
101
+ declare const signInEmail: <O extends BetterAuthOptions>() => better_call760.StrictEndpoint<"/sign-in/email", {
102
102
  method: "POST";
103
103
  operationId: string;
104
104
  body: z.ZodObject<{
@@ -1,7 +1,7 @@
1
- import * as better_call754 from "better-call";
1
+ import * as better_call763 from "better-call";
2
2
 
3
3
  //#region src/api/routes/sign-out.d.ts
4
- declare const signOut: better_call754.StrictEndpoint<"/sign-out", {
4
+ declare const signOut: better_call763.StrictEndpoint<"/sign-out", {
5
5
  method: "POST";
6
6
  operationId: string;
7
7
  requireHeaders: true;
@@ -2,10 +2,10 @@ import { AdditionalUserFieldsInput, InferUser } from "../../types/models.mjs";
2
2
  import "../../types/index.mjs";
3
3
  import { BetterAuthOptions } from "@better-auth/core";
4
4
  import * as z from "zod";
5
- import * as better_call755 from "better-call";
5
+ import * as better_call762 from "better-call";
6
6
 
7
7
  //#region src/api/routes/sign-up.d.ts
8
- declare const signUpEmail: <O extends BetterAuthOptions>() => better_call755.StrictEndpoint<"/sign-up/email", {
8
+ declare const signUpEmail: <O extends BetterAuthOptions>() => better_call762.StrictEndpoint<"/sign-up/email", {
9
9
  method: "POST";
10
10
  operationId: string;
11
11
  body: z.ZodIntersection<z.ZodObject<{
@@ -2,14 +2,14 @@ import { AdditionalUserFieldsInput } from "../../types/models.mjs";
2
2
  import "../../types/index.mjs";
3
3
  import { BetterAuthOptions } from "@better-auth/core";
4
4
  import * as z from "zod";
5
- import * as better_call702 from "better-call";
5
+ import * as better_call735 from "better-call";
6
6
 
7
7
  //#region src/api/routes/update-user.d.ts
8
- declare const updateUser: <O extends BetterAuthOptions>() => better_call702.StrictEndpoint<"/update-user", {
8
+ declare const updateUser: <O extends BetterAuthOptions>() => better_call735.StrictEndpoint<"/update-user", {
9
9
  method: "POST";
10
10
  operationId: string;
11
11
  body: z.ZodRecord<z.ZodString, z.ZodAny>;
12
- use: ((inputContext: better_call702.MiddlewareInputContext<better_call702.MiddlewareOptions>) => Promise<{
12
+ use: ((inputContext: better_call735.MiddlewareInputContext<better_call735.MiddlewareOptions>) => Promise<{
13
13
  session: {
14
14
  session: Record<string, any> & {
15
15
  id: string;
@@ -85,7 +85,7 @@ declare const updateUser: <O extends BetterAuthOptions>() => better_call702.Stri
85
85
  }, {
86
86
  status: boolean;
87
87
  }>;
88
- declare const changePassword: better_call702.StrictEndpoint<"/change-password", {
88
+ declare const changePassword: better_call735.StrictEndpoint<"/change-password", {
89
89
  method: "POST";
90
90
  operationId: string;
91
91
  body: z.ZodObject<{
@@ -93,7 +93,7 @@ declare const changePassword: better_call702.StrictEndpoint<"/change-password",
93
93
  currentPassword: z.ZodString;
94
94
  revokeOtherSessions: z.ZodOptional<z.ZodBoolean>;
95
95
  }, z.core.$strip>;
96
- use: ((inputContext: better_call702.MiddlewareInputContext<better_call702.MiddlewareOptions>) => Promise<{
96
+ use: ((inputContext: better_call735.MiddlewareInputContext<better_call735.MiddlewareOptions>) => Promise<{
97
97
  session: {
98
98
  session: Record<string, any> & {
99
99
  id: string;
@@ -193,12 +193,12 @@ declare const changePassword: better_call702.StrictEndpoint<"/change-password",
193
193
  updatedAt: Date;
194
194
  };
195
195
  }>;
196
- declare const setPassword: better_call702.StrictEndpoint<string, {
196
+ declare const setPassword: better_call735.StrictEndpoint<string, {
197
197
  method: "POST";
198
198
  body: z.ZodObject<{
199
199
  newPassword: z.ZodString;
200
200
  }, z.core.$strip>;
201
- use: ((inputContext: better_call702.MiddlewareInputContext<better_call702.MiddlewareOptions>) => Promise<{
201
+ use: ((inputContext: better_call735.MiddlewareInputContext<better_call735.MiddlewareOptions>) => Promise<{
202
202
  session: {
203
203
  session: Record<string, any> & {
204
204
  id: string;
@@ -224,9 +224,9 @@ declare const setPassword: better_call702.StrictEndpoint<string, {
224
224
  }, {
225
225
  status: boolean;
226
226
  }>;
227
- declare const deleteUser: better_call702.StrictEndpoint<"/delete-user", {
227
+ declare const deleteUser: better_call735.StrictEndpoint<"/delete-user", {
228
228
  method: "POST";
229
- use: ((inputContext: better_call702.MiddlewareInputContext<better_call702.MiddlewareOptions>) => Promise<{
229
+ use: ((inputContext: better_call735.MiddlewareInputContext<better_call735.MiddlewareOptions>) => Promise<{
230
230
  session: {
231
231
  session: Record<string, any> & {
232
232
  id: string;
@@ -311,13 +311,13 @@ declare const deleteUser: better_call702.StrictEndpoint<"/delete-user", {
311
311
  success: boolean;
312
312
  message: string;
313
313
  }>;
314
- declare const deleteUserCallback: better_call702.StrictEndpoint<"/delete-user/callback", {
314
+ declare const deleteUserCallback: better_call735.StrictEndpoint<"/delete-user/callback", {
315
315
  method: "GET";
316
316
  query: z.ZodObject<{
317
317
  token: z.ZodString;
318
318
  callbackURL: z.ZodOptional<z.ZodString>;
319
319
  }, z.core.$strip>;
320
- use: ((inputContext: better_call702.MiddlewareInputContext<better_call702.MiddlewareOptions>) => Promise<void>)[];
320
+ use: ((inputContext: better_call735.MiddlewareInputContext<better_call735.MiddlewareOptions>) => Promise<void>)[];
321
321
  metadata: {
322
322
  openapi: {
323
323
  description: string;
@@ -351,13 +351,13 @@ declare const deleteUserCallback: better_call702.StrictEndpoint<"/delete-user/ca
351
351
  success: boolean;
352
352
  message: string;
353
353
  }>;
354
- declare const changeEmail: better_call702.StrictEndpoint<"/change-email", {
354
+ declare const changeEmail: better_call735.StrictEndpoint<"/change-email", {
355
355
  method: "POST";
356
356
  body: z.ZodObject<{
357
357
  newEmail: z.ZodEmail;
358
358
  callbackURL: z.ZodOptional<z.ZodString>;
359
359
  }, z.core.$strip>;
360
- use: ((inputContext: better_call702.MiddlewareInputContext<better_call702.MiddlewareOptions>) => Promise<{
360
+ use: ((inputContext: better_call735.MiddlewareInputContext<better_call735.MiddlewareOptions>) => Promise<{
361
361
  session: {
362
362
  session: Record<string, any> & {
363
363
  id: string;
@@ -1,5 +1,6 @@
1
1
  import { getEndpoints, router } from "../api/index.mjs";
2
2
  import { getBaseURL, getOrigin } from "../utils/url.mjs";
3
+ import { getTrustedOrigins } from "../context/helpers.mjs";
3
4
  import { runWithAdapter } from "@better-auth/core/context";
4
5
  import { BASE_ERROR_CODES, BetterAuthError } from "@better-auth/core/error";
5
6
 
@@ -16,6 +17,7 @@ const createBetterAuth = (options, initFn) => {
16
17
  if (baseURL) {
17
18
  ctx.baseURL = baseURL;
18
19
  ctx.options.baseURL = getOrigin(ctx.baseURL) || void 0;
20
+ ctx.trustedOrigins = getTrustedOrigins(ctx.options);
19
21
  } else throw new BetterAuthError("Could not get base URL from request. Please provide a valid base URL.");
20
22
  }
21
23
  if (typeof options.trustedOrigins === "function") ctx.trustedOrigins = [...ctx.trustedOrigins, ...await options.trustedOrigins(request)];
@@ -1 +1 @@
1
- {"version":3,"file":"base.mjs","names":[],"sources":["../../src/auth/base.ts"],"sourcesContent":["import type { AuthContext, BetterAuthOptions } from \"@better-auth/core\";\nimport { runWithAdapter } from \"@better-auth/core/context\";\nimport { BASE_ERROR_CODES, BetterAuthError } from \"@better-auth/core/error\";\nimport { getEndpoints, router } from \"../api\";\nimport type { Auth } from \"../types\";\nimport { getBaseURL, getOrigin } from \"../utils/url\";\n\nexport const createBetterAuth = <Options extends BetterAuthOptions>(\n\toptions: Options &\n\t\t// fixme(alex): do we need Record<never, never> here?\n\t\tRecord<never, never>,\n\tinitFn: (options: Options) => Promise<AuthContext>,\n): Auth<Options> => {\n\tconst authContext = initFn(options);\n\tconst { api } = getEndpoints(authContext, options);\n\tconst errorCodes = options.plugins?.reduce((acc, plugin) => {\n\t\tif (plugin.$ERROR_CODES) {\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t...plugin.$ERROR_CODES,\n\t\t\t};\n\t\t}\n\t\treturn acc;\n\t}, {});\n\treturn {\n\t\thandler: async (request: Request) => {\n\t\t\tconst ctx = await authContext;\n\t\t\tconst basePath = ctx.options.basePath || \"/api/auth\";\n\t\t\tif (!ctx.options.baseURL) {\n\t\t\t\tconst baseURL = getBaseURL(\n\t\t\t\t\tundefined,\n\t\t\t\t\tbasePath,\n\t\t\t\t\trequest,\n\t\t\t\t\tundefined,\n\t\t\t\t\tctx.options.advanced?.trustedProxyHeaders,\n\t\t\t\t);\n\t\t\t\tif (baseURL) {\n\t\t\t\t\tctx.baseURL = baseURL;\n\t\t\t\t\tctx.options.baseURL = getOrigin(ctx.baseURL) || undefined;\n\t\t\t\t} else {\n\t\t\t\t\tthrow new BetterAuthError(\n\t\t\t\t\t\t\"Could not get base URL from request. Please provide a valid base URL.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (typeof options.trustedOrigins === \"function\") {\n\t\t\t\tctx.trustedOrigins = [\n\t\t\t\t\t...ctx.trustedOrigins,\n\t\t\t\t\t...(await options.trustedOrigins(request)),\n\t\t\t\t];\n\t\t\t}\n\t\t\tconst { handler } = router(ctx, options);\n\t\t\treturn runWithAdapter(ctx.adapter, () => handler(request));\n\t\t},\n\t\tapi,\n\t\toptions: options,\n\t\t$context: authContext,\n\t\t$ERROR_CODES: {\n\t\t\t...errorCodes,\n\t\t\t...BASE_ERROR_CODES,\n\t\t},\n\t} as any;\n};\n"],"mappings":";;;;;;AAOA,MAAa,oBACZ,SAGA,WACmB;CACnB,MAAM,cAAc,OAAO,QAAQ;CACnC,MAAM,EAAE,QAAQ,aAAa,aAAa,QAAQ;AAUlD,QAAO;EACN,SAAS,OAAO,YAAqB;GACpC,MAAM,MAAM,MAAM;GAClB,MAAM,WAAW,IAAI,QAAQ,YAAY;AACzC,OAAI,CAAC,IAAI,QAAQ,SAAS;IACzB,MAAM,UAAU,WACf,QACA,UACA,SACA,QACA,IAAI,QAAQ,UAAU,oBACtB;AACD,QAAI,SAAS;AACZ,SAAI,UAAU;AACd,SAAI,QAAQ,UAAU,UAAU,IAAI,QAAQ,IAAI;UAEhD,OAAM,IAAI,gBACT,wEACA;;AAIH,OAAI,OAAO,QAAQ,mBAAmB,WACrC,KAAI,iBAAiB,CACpB,GAAG,IAAI,gBACP,GAAI,MAAM,QAAQ,eAAe,QAAQ,CACzC;GAEF,MAAM,EAAE,YAAY,OAAO,KAAK,QAAQ;AACxC,UAAO,eAAe,IAAI,eAAe,QAAQ,QAAQ,CAAC;;EAE3D;EACS;EACT,UAAU;EACV,cAAc;GACb,GA5CiB,QAAQ,SAAS,QAAQ,KAAK,WAAW;AAC3D,QAAI,OAAO,aACV,QAAO;KACN,GAAG;KACH,GAAG,OAAO;KACV;AAEF,WAAO;MACL,EAAE,CAAC;GAqCJ,GAAG;GACH;EACD"}
1
+ {"version":3,"file":"base.mjs","names":[],"sources":["../../src/auth/base.ts"],"sourcesContent":["import type { AuthContext, BetterAuthOptions } from \"@better-auth/core\";\nimport { runWithAdapter } from \"@better-auth/core/context\";\nimport { BASE_ERROR_CODES, BetterAuthError } from \"@better-auth/core/error\";\nimport { getEndpoints, router } from \"../api\";\nimport { getTrustedOrigins } from \"../context/helpers\";\nimport type { Auth } from \"../types\";\nimport { getBaseURL, getOrigin } from \"../utils/url\";\n\nexport const createBetterAuth = <Options extends BetterAuthOptions>(\n\toptions: Options &\n\t\t// fixme(alex): do we need Record<never, never> here?\n\t\tRecord<never, never>,\n\tinitFn: (options: Options) => Promise<AuthContext>,\n): Auth<Options> => {\n\tconst authContext = initFn(options);\n\tconst { api } = getEndpoints(authContext, options);\n\tconst errorCodes = options.plugins?.reduce((acc, plugin) => {\n\t\tif (plugin.$ERROR_CODES) {\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t...plugin.$ERROR_CODES,\n\t\t\t};\n\t\t}\n\t\treturn acc;\n\t}, {});\n\treturn {\n\t\thandler: async (request: Request) => {\n\t\t\tconst ctx = await authContext;\n\t\t\tconst basePath = ctx.options.basePath || \"/api/auth\";\n\t\t\tif (!ctx.options.baseURL) {\n\t\t\t\tconst baseURL = getBaseURL(\n\t\t\t\t\tundefined,\n\t\t\t\t\tbasePath,\n\t\t\t\t\trequest,\n\t\t\t\t\tundefined,\n\t\t\t\t\tctx.options.advanced?.trustedProxyHeaders,\n\t\t\t\t);\n\t\t\t\tif (baseURL) {\n\t\t\t\t\tctx.baseURL = baseURL;\n\t\t\t\t\tctx.options.baseURL = getOrigin(ctx.baseURL) || undefined;\n\t\t\t\t\tctx.trustedOrigins = getTrustedOrigins(ctx.options);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new BetterAuthError(\n\t\t\t\t\t\t\"Could not get base URL from request. Please provide a valid base URL.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (typeof options.trustedOrigins === \"function\") {\n\t\t\t\tctx.trustedOrigins = [\n\t\t\t\t\t...ctx.trustedOrigins,\n\t\t\t\t\t...(await options.trustedOrigins(request)),\n\t\t\t\t];\n\t\t\t}\n\t\t\tconst { handler } = router(ctx, options);\n\t\t\treturn runWithAdapter(ctx.adapter, () => handler(request));\n\t\t},\n\t\tapi,\n\t\toptions: options,\n\t\t$context: authContext,\n\t\t$ERROR_CODES: {\n\t\t\t...errorCodes,\n\t\t\t...BASE_ERROR_CODES,\n\t\t},\n\t} as any;\n};\n"],"mappings":";;;;;;;AAQA,MAAa,oBACZ,SAGA,WACmB;CACnB,MAAM,cAAc,OAAO,QAAQ;CACnC,MAAM,EAAE,QAAQ,aAAa,aAAa,QAAQ;AAUlD,QAAO;EACN,SAAS,OAAO,YAAqB;GACpC,MAAM,MAAM,MAAM;GAClB,MAAM,WAAW,IAAI,QAAQ,YAAY;AACzC,OAAI,CAAC,IAAI,QAAQ,SAAS;IACzB,MAAM,UAAU,WACf,QACA,UACA,SACA,QACA,IAAI,QAAQ,UAAU,oBACtB;AACD,QAAI,SAAS;AACZ,SAAI,UAAU;AACd,SAAI,QAAQ,UAAU,UAAU,IAAI,QAAQ,IAAI;AAChD,SAAI,iBAAiB,kBAAkB,IAAI,QAAQ;UAEnD,OAAM,IAAI,gBACT,wEACA;;AAGH,OAAI,OAAO,QAAQ,mBAAmB,WACrC,KAAI,iBAAiB,CACpB,GAAG,IAAI,gBACP,GAAI,MAAM,QAAQ,eAAe,QAAQ,CACzC;GAEF,MAAM,EAAE,YAAY,OAAO,KAAK,QAAQ;AACxC,UAAO,eAAe,IAAI,eAAe,QAAQ,QAAQ,CAAC;;EAE3D;EACS;EACT,UAAU;EACV,cAAc;GACb,GA5CiB,QAAQ,SAAS,QAAQ,KAAK,WAAW;AAC3D,QAAI,OAAO,aACV,QAAO;KACN,GAAG;KACH,GAAG,OAAO;KACV;AAEF,WAAO;MACL,EAAE,CAAC;GAqCJ,GAAG;GACH;EACD"}