better-auth 1.7.11 → 1.7.13

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 (276) hide show
  1. package/dist/adapters/index.d.mts +5 -10
  2. package/dist/api/dispatch.d.mts +3 -5
  3. package/dist/api/dispatch.mjs +6 -4
  4. package/dist/api/index.d.mts +506 -508
  5. package/dist/api/index.mjs +35 -34
  6. package/dist/api/middlewares/authorization.d.mts +15 -12
  7. package/dist/api/middlewares/authorization.mjs +2 -1
  8. package/dist/api/middlewares/index.d.mts +2 -1
  9. package/dist/api/middlewares/origin-check.d.mts +4 -7
  10. package/dist/api/routes/account.d.mts +11 -15
  11. package/dist/api/routes/account.mjs +7 -4
  12. package/dist/api/routes/callback.d.mts +2 -5
  13. package/dist/api/routes/callback.mjs +14 -53
  14. package/dist/api/routes/email-verification.d.mts +7 -12
  15. package/dist/api/routes/error.d.mts +2 -5
  16. package/dist/api/routes/index.d.mts +2 -1
  17. package/dist/api/routes/ok.d.mts +2 -5
  18. package/dist/api/routes/password.d.mts +8 -11
  19. package/dist/api/routes/password.mjs +3 -2
  20. package/dist/api/routes/session.d.mts +26 -29
  21. package/dist/api/routes/session.mjs +1 -1
  22. package/dist/api/routes/sign-in.d.mts +4 -6
  23. package/dist/api/routes/sign-out.d.mts +2 -5
  24. package/dist/api/routes/sign-up.d.mts +4 -6
  25. package/dist/api/routes/update-session.d.mts +4 -6
  26. package/dist/api/routes/update-user.d.mts +14 -16
  27. package/dist/api/routes/update-user.mjs +1 -1
  28. package/dist/api/state/oauth.d.mts +0 -3
  29. package/dist/api/state/oauth.mjs +2 -1
  30. package/dist/auth/full.d.mts +3 -4
  31. package/dist/auth/minimal.d.mts +3 -3
  32. package/dist/client/broadcast-channel.d.mts +6 -7
  33. package/dist/client/config.d.mts +15 -19
  34. package/dist/client/config.mjs +2 -2
  35. package/dist/client/equality.d.mts +3 -5
  36. package/dist/client/focus-manager.d.mts +4 -5
  37. package/dist/client/index.d.mts +8 -7
  38. package/dist/client/lynx/index.d.mts +6 -7
  39. package/dist/client/lynx/index.mjs +3 -2
  40. package/dist/client/lynx/lynx-store.d.mts +3 -4
  41. package/dist/client/online-manager.d.mts +4 -5
  42. package/dist/client/parser.d.mts +9 -5
  43. package/dist/client/path-to-object.d.mts +13 -14
  44. package/dist/client/plugins/index.d.mts +1 -1
  45. package/dist/client/plugins/infer-plugin.d.mts +2 -4
  46. package/dist/client/query.d.mts +4 -6
  47. package/dist/client/react/index.d.mts +6 -7
  48. package/dist/client/react/index.mjs +3 -2
  49. package/dist/client/react/react-store.d.mts +3 -4
  50. package/dist/client/session-atom.d.mts +4 -4
  51. package/dist/client/session-refresh.d.mts +3 -5
  52. package/dist/client/solid/index.d.mts +6 -7
  53. package/dist/client/solid/index.mjs +3 -2
  54. package/dist/client/svelte/index.d.mts +6 -7
  55. package/dist/client/svelte/index.mjs +3 -2
  56. package/dist/client/types.d.mts +11 -11
  57. package/dist/client/vanilla.d.mts +4 -5
  58. package/dist/client/vanilla.mjs +3 -2
  59. package/dist/client/vue/index.d.mts +6 -7
  60. package/dist/client/vue/index.mjs +3 -2
  61. package/dist/context/create-context.mjs +7 -7
  62. package/dist/context/helpers.mjs +9 -7
  63. package/dist/cookies/cookie-utils.d.mts +13 -13
  64. package/dist/cookies/cookie-utils.mjs +1 -3
  65. package/dist/cookies/index.d.mts +17 -18
  66. package/dist/cookies/index.mjs +11 -7
  67. package/dist/cookies/jwt.mjs +2 -1
  68. package/dist/cookies/session-store.d.mts +6 -5
  69. package/dist/cookies/session-store.mjs +3 -2
  70. package/dist/crypto/buffer.d.mts +2 -3
  71. package/dist/crypto/index.d.mts +9 -16
  72. package/dist/crypto/index.mjs +2 -1
  73. package/dist/crypto/jwt.d.mts +5 -7
  74. package/dist/crypto/jwt.mjs +2 -1
  75. package/dist/crypto/password.d.mts +1 -5
  76. package/dist/crypto/random.d.mts +2 -3
  77. package/dist/db/adapter-base.d.mts +2 -4
  78. package/dist/db/adapter-kysely.d.mts +2 -4
  79. package/dist/db/field-converter.d.mts +3 -5
  80. package/dist/db/field.d.mts +11 -12
  81. package/dist/db/get-migration.d.mts +4 -8
  82. package/dist/db/get-migration.mjs +22 -22
  83. package/dist/db/get-schema.d.mts +2 -4
  84. package/dist/db/internal-adapter.d.mts +2 -4
  85. package/dist/db/internal-adapter.mjs +6 -4
  86. package/dist/db/revoke-unproven-account-access.d.mts +3 -4
  87. package/dist/db/schema.d.mts +15 -16
  88. package/dist/db/schema.mjs +6 -3
  89. package/dist/db/to-zod.d.mts +5 -9
  90. package/dist/db/with-hooks.d.mts +3 -5
  91. package/dist/index.d.mts +4 -3
  92. package/dist/integrations/next-js.d.mts +7 -11
  93. package/dist/integrations/node.d.mts +5 -7
  94. package/dist/integrations/node.mjs +4 -2
  95. package/dist/integrations/solid-start.d.mts +2 -3
  96. package/dist/integrations/svelte-kit.d.mts +6 -14
  97. package/dist/integrations/tanstack-start-solid.d.mts +4 -8
  98. package/dist/integrations/tanstack-start.d.mts +4 -8
  99. package/dist/oauth2/callback.mjs +68 -0
  100. package/dist/oauth2/link-account.d.mts +5 -11
  101. package/dist/oauth2/link-account.mjs +12 -6
  102. package/dist/oauth2/state.d.mts +5 -7
  103. package/dist/oauth2/state.mjs +1 -1
  104. package/dist/oauth2/utils.d.mts +4 -6
  105. package/dist/package.mjs +1 -1
  106. package/dist/plugins/access/access.d.mts +4 -6
  107. package/dist/plugins/access/index.mjs +1 -2
  108. package/dist/plugins/access/types.d.mts +12 -14
  109. package/dist/plugins/additional-fields/client.d.mts +2 -4
  110. package/dist/plugins/admin/access/index.mjs +1 -2
  111. package/dist/plugins/admin/access/statement.d.mts +7 -7
  112. package/dist/plugins/admin/admin.d.mts +122 -128
  113. package/dist/plugins/admin/client.d.mts +32 -32
  114. package/dist/plugins/admin/client.mjs +1 -1
  115. package/dist/plugins/admin/error-codes.d.mts +25 -28
  116. package/dist/plugins/admin/index.d.mts +1 -1
  117. package/dist/plugins/admin/index.mjs +1 -2
  118. package/dist/plugins/admin/schema.d.mts +3 -4
  119. package/dist/plugins/admin/types.d.mts +8 -8
  120. package/dist/plugins/anonymous/client.d.mts +10 -12
  121. package/dist/plugins/anonymous/client.mjs +1 -1
  122. package/dist/plugins/anonymous/error-codes.d.mts +10 -13
  123. package/dist/plugins/anonymous/index.d.mts +17 -21
  124. package/dist/plugins/anonymous/schema.d.mts +2 -3
  125. package/dist/plugins/anonymous/types.d.mts +5 -6
  126. package/dist/plugins/bearer/index.d.mts +7 -11
  127. package/dist/plugins/captcha/constants.d.mts +2 -3
  128. package/dist/plugins/captcha/index.d.mts +6 -9
  129. package/dist/plugins/captcha/types.d.mts +11 -13
  130. package/dist/plugins/custom-session/client.d.mts +2 -4
  131. package/dist/plugins/custom-session/index.d.mts +10 -16
  132. package/dist/plugins/device-authorization/client.d.mts +2 -4
  133. package/dist/plugins/device-authorization/index.d.mts +39 -44
  134. package/dist/plugins/device-authorization/index.mjs +10 -9
  135. package/dist/plugins/device-authorization/routes.d.mts +7 -5
  136. package/dist/plugins/device-authorization/routes.mjs +6 -5
  137. package/dist/plugins/device-authorization/schema.d.mts +2 -3
  138. package/dist/plugins/email-otp/client.d.mts +5 -7
  139. package/dist/plugins/email-otp/client.mjs +1 -1
  140. package/dist/plugins/email-otp/error-codes.d.mts +5 -8
  141. package/dist/plugins/email-otp/index.d.mts +69 -76
  142. package/dist/plugins/email-otp/otp-token.mjs +19 -7
  143. package/dist/plugins/email-otp/types.d.mts +2 -4
  144. package/dist/plugins/generic-oauth/index.d.mts +9 -13
  145. package/dist/plugins/generic-oauth/index.mjs +6 -4
  146. package/dist/plugins/generic-oauth/providers/auth0.d.mts +3 -5
  147. package/dist/plugins/generic-oauth/providers/gumroad.d.mts +3 -5
  148. package/dist/plugins/generic-oauth/providers/hubspot.d.mts +3 -5
  149. package/dist/plugins/generic-oauth/providers/hubspot.mjs +2 -1
  150. package/dist/plugins/generic-oauth/providers/index.d.mts +2 -1
  151. package/dist/plugins/generic-oauth/providers/keycloak.d.mts +3 -5
  152. package/dist/plugins/generic-oauth/providers/line.d.mts +3 -5
  153. package/dist/plugins/generic-oauth/providers/microsoft-entra-id.d.mts +3 -5
  154. package/dist/plugins/generic-oauth/providers/okta.d.mts +3 -5
  155. package/dist/plugins/generic-oauth/providers/patreon.d.mts +3 -5
  156. package/dist/plugins/generic-oauth/providers/slack.d.mts +3 -5
  157. package/dist/plugins/generic-oauth/providers/yandex.d.mts +3 -5
  158. package/dist/plugins/generic-oauth/types.d.mts +6 -7
  159. package/dist/plugins/haveibeenpwned/index.d.mts +7 -11
  160. package/dist/plugins/index.d.mts +4 -1
  161. package/dist/plugins/jwt/adapter.mjs +14 -3
  162. package/dist/plugins/jwt/client.d.mts +2 -3
  163. package/dist/plugins/jwt/cookie-cache.mjs +3 -8
  164. package/dist/plugins/jwt/index.d.mts +11 -14
  165. package/dist/plugins/jwt/index.mjs +3 -3
  166. package/dist/plugins/jwt/schema.d.mts +2 -3
  167. package/dist/plugins/jwt/sign.d.mts +9 -8
  168. package/dist/plugins/jwt/sign.mjs +6 -5
  169. package/dist/plugins/jwt/types.d.mts +7 -8
  170. package/dist/plugins/jwt/utils.d.mts +6 -9
  171. package/dist/plugins/jwt/verify.d.mts +2 -4
  172. package/dist/plugins/jwt/verify.mjs +10 -4
  173. package/dist/plugins/last-login-method/client.d.mts +3 -4
  174. package/dist/plugins/last-login-method/index.d.mts +5 -9
  175. package/dist/plugins/last-login-method/index.mjs +1 -1
  176. package/dist/plugins/magic-link/client.d.mts +2 -4
  177. package/dist/plugins/magic-link/index.d.mts +7 -10
  178. package/dist/plugins/magic-link/index.mjs +20 -17
  179. package/dist/plugins/multi-session/client.d.mts +3 -5
  180. package/dist/plugins/multi-session/client.mjs +1 -1
  181. package/dist/plugins/multi-session/error-codes.d.mts +3 -6
  182. package/dist/plugins/multi-session/index.d.mts +10 -14
  183. package/dist/plugins/oauth-popup/client.d.mts +11 -17
  184. package/dist/plugins/oauth-popup/client.mjs +6 -4
  185. package/dist/plugins/oauth-popup/constants.d.mts +5 -6
  186. package/dist/plugins/oauth-popup/error-codes.d.mts +6 -9
  187. package/dist/plugins/oauth-popup/index.d.mts +11 -15
  188. package/dist/plugins/oauth-popup/index.mjs +8 -7
  189. package/dist/plugins/oauth-popup/types.d.mts +4 -6
  190. package/dist/plugins/oauth-proxy/index.d.mts +11 -15
  191. package/dist/plugins/oauth-proxy/index.mjs +24 -48
  192. package/dist/plugins/one-tap/client.d.mts +6 -9
  193. package/dist/plugins/one-tap/index.d.mts +4 -7
  194. package/dist/plugins/one-time-token/client.d.mts +2 -3
  195. package/dist/plugins/one-time-token/index.d.mts +8 -10
  196. package/dist/plugins/open-api/generator.d.mts +8 -8
  197. package/dist/plugins/open-api/generator.mjs +5 -5
  198. package/dist/plugins/open-api/index.d.mts +5 -7
  199. package/dist/plugins/organization/access/index.mjs +1 -2
  200. package/dist/plugins/organization/access/statement.d.mts +8 -8
  201. package/dist/plugins/organization/adapter.d.mts +60 -87
  202. package/dist/plugins/organization/adapter.mjs +14 -10
  203. package/dist/plugins/organization/client.d.mts +108 -107
  204. package/dist/plugins/organization/client.mjs +9 -5
  205. package/dist/plugins/organization/error-codes.d.mts +61 -64
  206. package/dist/plugins/organization/has-permission.d.mts +2 -4
  207. package/dist/plugins/organization/has-permission.mjs +1 -1
  208. package/dist/plugins/organization/index.d.mts +1 -1
  209. package/dist/plugins/organization/organization.d.mts +20 -20
  210. package/dist/plugins/organization/organization.mjs +13 -8
  211. package/dist/plugins/organization/permission.d.mts +4 -5
  212. package/dist/plugins/organization/routes/crud-access-control.d.mts +28 -28
  213. package/dist/plugins/organization/routes/crud-invites.d.mts +64 -65
  214. package/dist/plugins/organization/routes/crud-invites.mjs +21 -18
  215. package/dist/plugins/organization/routes/crud-members.d.mts +53 -56
  216. package/dist/plugins/organization/routes/crud-members.mjs +23 -21
  217. package/dist/plugins/organization/routes/crud-org.d.mts +63 -65
  218. package/dist/plugins/organization/routes/crud-org.mjs +4 -2
  219. package/dist/plugins/organization/routes/crud-team.d.mts +65 -66
  220. package/dist/plugins/organization/routes/crud-team.mjs +4 -2
  221. package/dist/plugins/organization/schema.d.mts +33 -33
  222. package/dist/plugins/organization/schema.mjs +1 -1
  223. package/dist/plugins/organization/types.d.mts +16 -17
  224. package/dist/plugins/phone-number/client.d.mts +14 -16
  225. package/dist/plugins/phone-number/client.mjs +1 -1
  226. package/dist/plugins/phone-number/error-codes.d.mts +14 -17
  227. package/dist/plugins/phone-number/index.d.mts +48 -54
  228. package/dist/plugins/phone-number/schema.d.mts +2 -3
  229. package/dist/plugins/phone-number/types.d.mts +4 -5
  230. package/dist/plugins/siwe/client.d.mts +2 -4
  231. package/dist/plugins/siwe/index.d.mts +7 -9
  232. package/dist/plugins/siwe/index.mjs +1 -1
  233. package/dist/plugins/siwe/parse-message.mjs +1 -3
  234. package/dist/plugins/siwe/schema.d.mts +3 -4
  235. package/dist/plugins/siwe/types.d.mts +4 -4
  236. package/dist/plugins/test-utils/auth-helpers.mjs +4 -2
  237. package/dist/plugins/test-utils/index.d.mts +3 -5
  238. package/dist/plugins/test-utils/types.d.mts +7 -7
  239. package/dist/plugins/two-factor/backup-codes/index.d.mts +11 -14
  240. package/dist/plugins/two-factor/backup-codes/index.mjs +12 -6
  241. package/dist/plugins/two-factor/client.d.mts +16 -19
  242. package/dist/plugins/two-factor/client.mjs +1 -1
  243. package/dist/plugins/two-factor/constant.mjs +1 -1
  244. package/dist/plugins/two-factor/error-code.d.mts +15 -18
  245. package/dist/plugins/two-factor/index.d.mts +31 -35
  246. package/dist/plugins/two-factor/index.mjs +6 -3
  247. package/dist/plugins/two-factor/otp/index.d.mts +5 -8
  248. package/dist/plugins/two-factor/otp/index.mjs +159 -154
  249. package/dist/plugins/two-factor/schema.d.mts +2 -3
  250. package/dist/plugins/two-factor/totp/index.d.mts +7 -10
  251. package/dist/plugins/two-factor/totp/index.mjs +153 -148
  252. package/dist/plugins/two-factor/types.d.mts +6 -7
  253. package/dist/plugins/username/client.d.mts +12 -14
  254. package/dist/plugins/username/client.mjs +1 -1
  255. package/dist/plugins/username/error-codes.d.mts +11 -14
  256. package/dist/plugins/username/index.d.mts +26 -31
  257. package/dist/plugins/username/schema.d.mts +7 -10
  258. package/dist/state.d.mts +4 -5
  259. package/dist/test-utils/headers.d.mts +2 -3
  260. package/dist/test-utils/http-test-instance.d.mts +26 -29
  261. package/dist/test-utils/test-instance.d.mts +7 -6
  262. package/dist/test-utils/test-instance.mjs +4 -2
  263. package/dist/types/adapter.d.mts +1 -1
  264. package/dist/types/api.d.mts +4 -6
  265. package/dist/types/auth.d.mts +2 -4
  266. package/dist/types/helper.d.mts +11 -12
  267. package/dist/types/index.d.mts +2 -2
  268. package/dist/types/models.d.mts +4 -5
  269. package/dist/types/plugins.d.mts +7 -8
  270. package/dist/utils/hide-metadata.d.mts +2 -3
  271. package/dist/utils/index.d.mts +2 -1
  272. package/dist/utils/is-api-error.mjs +1 -2
  273. package/dist/utils/time.d.mts +4 -4
  274. package/dist/utils/url.d.mts +13 -15
  275. package/dist/utils/wildcard.mjs +5 -3
  276. package/package.json +13 -13
@@ -4,19 +4,17 @@ import { originCheck } from "../../api/middlewares/origin-check.mjs";
4
4
  import { parseSetCookieHeader } from "../../cookies/cookie-utils.mjs";
5
5
  import { symmetricDecrypt, symmetricEncrypt } from "../../crypto/index.mjs";
6
6
  import { setSessionCookie } from "../../cookies/index.mjs";
7
- import { resolveOAuthAccountKey, toOAuthProfileRecord } from "../../oauth2/account-key.mjs";
8
7
  import { redirectOnError } from "../../oauth2/errors.mjs";
9
- import { getOAuthCallbackPath } from "../../oauth2/utils.mjs";
10
8
  import { handleOAuthUserInfo, linkOAuthAccount } from "../../oauth2/link-account.mjs";
11
9
  import { setOAuthState } from "../../api/state/oauth.mjs";
12
10
  import { derivePurposeKey } from "../../crypto/purpose.mjs";
13
11
  import { getAuthStateVerificationIdentifier, parseGenericState } from "../../state.mjs";
12
+ import { exchangeOAuthCallback } from "../../oauth2/callback.mjs";
14
13
  import { PACKAGE_VERSION } from "../../version.mjs";
15
14
  import { parseJSON } from "../../client/parser.mjs";
16
15
  import { checkSkipProxy, resolveCurrentURL, stripTrailingSlash } from "./utils.mjs";
17
16
  import { accountSchema, userSchema } from "@better-auth/core/db";
18
- import { safeJSONParse } from "@better-auth/core/utils/json";
19
- import { defu } from "defu";
17
+ import { defu as defu$1 } from "defu";
20
18
  import { createAuthEndpoint, createAuthMiddleware } from "@better-auth/core/api";
21
19
  import * as z from "zod";
22
20
  //#region src/plugins/oauth-proxy/index.ts
@@ -63,7 +61,9 @@ const oauthProxyQuerySchema = z.object({
63
61
  const oauthCallbackQuerySchema = z.object({
64
62
  code: z.string().optional(),
65
63
  error: z.string().optional(),
66
- user: z.string().optional()
64
+ user: z.string().optional(),
65
+ iss: z.string().optional(),
66
+ device_id: z.string().optional()
67
67
  });
68
68
  const oAuthProxy = (opts) => {
69
69
  const maxAge = opts?.maxAge ?? 60;
@@ -220,15 +220,16 @@ const oAuthProxy = (opts) => {
220
220
  return context.path === "/callback/:id";
221
221
  },
222
222
  handler: createAuthMiddleware(async (ctx) => {
223
- const callbackParams = defu(ctx.query, ctx.body);
223
+ const callbackParams = defu$1(ctx.query, ctx.body);
224
224
  const state = callbackParams.state;
225
225
  if (!state || typeof state !== "string") return;
226
226
  let statePackage;
227
227
  try {
228
- statePackage = parseJSON(await symmetricDecrypt({
228
+ const decryptedPackage = await symmetricDecrypt({
229
229
  key: getEncryptionKey(ctx, "oauth-proxy-package"),
230
230
  data: state
231
- }));
231
+ });
232
+ statePackage = parseJSON(decryptedPackage);
232
233
  } catch {
233
234
  ctx.context.logger.debug("OAuth proxy: could not decrypt state package, falling back to regular callback");
234
235
  return;
@@ -242,13 +243,14 @@ const oAuthProxy = (opts) => {
242
243
  ctx.context.logger.warn("Invalid OAuth callback query", query.error);
243
244
  return;
244
245
  }
245
- const { code, error, user: userData } = query.data;
246
+ const { code, error, user: userData, iss, device_id: deviceId } = query.data;
246
247
  let stateData;
247
248
  try {
248
- stateData = parseJSON(await symmetricDecrypt({
249
+ const decryptedState = await symmetricDecrypt({
249
250
  key: getEncryptionKey(ctx, "oauth-proxy-state"),
250
251
  data: statePackage.stateCookie
251
- }));
252
+ });
253
+ stateData = parseJSON(decryptedState);
252
254
  } catch (e) {
253
255
  ctx.context.logger.error("Failed to decrypt OAuth proxy state cookie:", e);
254
256
  return;
@@ -269,47 +271,20 @@ const oAuthProxy = (opts) => {
269
271
  ctx.context.logger.warn("OAuth provider not found", { providerId });
270
272
  throw redirectOnError(ctx, errorURL, "oauth_provider_not_found");
271
273
  }
272
- let tokens;
273
- try {
274
- tokens = await provider.validateAuthorizationCode({
275
- code,
276
- codeVerifier: stateData.codeVerifier,
277
- redirectURI: `${ctx.context.baseURL}${getOAuthCallbackPath(provider)}`
278
- });
279
- } catch (e) {
280
- ctx.context.logger.error("Failed to validate authorization code", e);
281
- throw redirectOnError(ctx, errorURL, "invalid_code");
282
- }
283
- if (!tokens) throw redirectOnError(ctx, errorURL, "invalid_code");
284
- const parsedUserData = userData ? safeJSONParse(userData) : null;
285
- const userInfoResult = await provider.getUserInfo({
286
- ...tokens,
287
- /**
288
- * The user object from the provider
289
- * This is only available for some providers like Apple
290
- */
291
- user: parsedUserData ?? void 0
274
+ const exchanged = await exchangeOAuthCallback(ctx, provider, {
275
+ code,
276
+ codeVerifier: stateData.codeVerifier,
277
+ iss,
278
+ deviceId,
279
+ user: userData,
280
+ idTokenNonce: stateData.idTokenNonce
292
281
  });
293
- const userInfo = userInfoResult?.user;
294
- if (!userInfo) {
295
- ctx.context.logger.error("Unable to get user info from provider");
296
- throw redirectOnError(ctx, errorURL, "unable_to_get_user_info");
297
- }
282
+ if (exchanged.error) throw redirectOnError(ctx, errorURL, exchanged.error);
283
+ const { tokens, userInfo, providerProfile, accountKey } = exchanged;
298
284
  if (!userInfo.email) {
299
285
  ctx.context.logger.error("Provider did not return email");
300
286
  throw redirectOnError(ctx, errorURL, "email_not_found");
301
287
  }
302
- let accountKey;
303
- try {
304
- accountKey = await resolveOAuthAccountKey(provider, tokens, userInfoResult.data);
305
- } catch (error) {
306
- ctx.context.logger.error("Unable to derive provider account identity", {
307
- providerId: provider.id,
308
- error
309
- });
310
- throw redirectOnError(ctx, errorURL, "unable_to_get_user_info");
311
- }
312
- const providerProfile = toOAuthProfileRecord(userInfoResult.data);
313
288
  const proxyCallbackURL = new URL(stateData.callbackURL);
314
289
  const finalCallbackURL = proxyCallbackURL.searchParams.get("callbackURL") || stateData.callbackURL;
315
290
  const payload = {
@@ -404,7 +379,8 @@ const oAuthProxy = (opts) => {
404
379
  handler: createAuthMiddleware(async (ctx) => {
405
380
  const location = ctx.context.responseHeaders?.get("location");
406
381
  if (!location?.includes("/oauth-proxy?callbackURL") && !location?.includes("/oauth-proxy-callback?callbackURL") || !location.startsWith("http")) return;
407
- const productionOrigin = getOrigin(opts?.productionURL || (typeof ctx.context.options.baseURL === "string" ? ctx.context.options.baseURL : void 0) || ctx.context.baseURL);
382
+ const productionURL = opts?.productionURL || (typeof ctx.context.options.baseURL === "string" ? ctx.context.options.baseURL : void 0) || ctx.context.baseURL;
383
+ const productionOrigin = getOrigin(productionURL);
408
384
  const locationURL = new URL(location);
409
385
  if (locationURL.origin === productionOrigin) {
410
386
  const newLocation = locationURL.searchParams.get("callbackURL");
@@ -1,14 +1,12 @@
1
1
  import { BetterAuthClientOptions, ClientFetchOption, ClientStore } from "@better-auth/core";
2
- import * as _$_better_fetch_fetch0 from "@better-fetch/fetch";
3
2
  import { BetterFetch } from "@better-fetch/fetch";
4
-
5
3
  //#region src/plugins/one-tap/client.d.ts
6
4
  declare global {
7
5
  interface Window {
8
6
  googleScriptInitialized?: boolean | undefined;
9
7
  }
10
8
  }
11
- interface GsiButtonConfiguration {
9
+ export interface GsiButtonConfiguration {
12
10
  /**
13
11
  * The button type: icon, or standard button.
14
12
  */
@@ -69,7 +67,7 @@ interface GsiButtonConfiguration {
69
67
  */
70
68
  state?: string;
71
69
  }
72
- interface GoogleOneTapOptions {
70
+ export interface GoogleOneTapOptions {
73
71
  /**
74
72
  * Google client ID
75
73
  */
@@ -129,7 +127,7 @@ interface GoogleOneTapOptions {
129
127
  fedCM?: boolean | undefined;
130
128
  } | undefined;
131
129
  }
132
- interface GoogleOneTapActionOptions extends Omit<GoogleOneTapOptions, "clientId" | "promptOptions"> {
130
+ export interface GoogleOneTapActionOptions extends Omit<GoogleOneTapOptions, "clientId" | "promptOptions"> {
133
131
  fetchOptions?: ClientFetchOption | undefined;
134
132
  /**
135
133
  * Callback URL.
@@ -157,14 +155,14 @@ interface GoogleOneTapActionOptions extends Omit<GoogleOneTapOptions, "clientId"
157
155
  config?: GsiButtonConfiguration | undefined;
158
156
  } | undefined;
159
157
  }
160
- declare const oneTapClient: (options: GoogleOneTapOptions) => {
158
+ export declare const oneTapClient: (options: GoogleOneTapOptions) => {
161
159
  id: "one-tap";
162
160
  version: string;
163
161
  fetchPlugins: {
164
162
  id: string;
165
163
  name: string;
166
164
  hooks: {
167
- onResponse(ctx: _$_better_fetch_fetch0.ResponseContext): Promise<void>;
165
+ onResponse(ctx: import("@better-fetch/fetch").ResponseContext): Promise<void>;
168
166
  };
169
167
  }[];
170
168
  getActions: ($fetch: BetterFetch, _$store: ClientStore, _options: BetterAuthClientOptions | undefined) => {
@@ -172,5 +170,4 @@ declare const oneTapClient: (options: GoogleOneTapOptions) => {
172
170
  };
173
171
  getAtoms($fetch: BetterFetch): {};
174
172
  };
175
- //#endregion
176
- export { GoogleOneTapActionOptions, GoogleOneTapOptions, GsiButtonConfiguration, oneTapClient };
173
+ //#endregion
@@ -1,6 +1,4 @@
1
- import * as _$better_call0 from "better-call";
2
1
  import * as z from "zod";
3
-
4
2
  //#region src/plugins/one-tap/index.d.ts
5
3
  declare module "@better-auth/core" {
6
4
  interface BetterAuthPluginRegistry<AuthOptions, Options> {
@@ -9,7 +7,7 @@ declare module "@better-auth/core" {
9
7
  };
10
8
  }
11
9
  }
12
- interface OneTapOptions {
10
+ export interface OneTapOptions {
13
11
  /**
14
12
  * Disable the signup flow
15
13
  *
@@ -24,11 +22,11 @@ interface OneTapOptions {
24
22
  */
25
23
  clientId?: string | undefined;
26
24
  }
27
- declare const oneTap: (options?: OneTapOptions | undefined) => {
25
+ export declare const oneTap: (options?: OneTapOptions | undefined) => {
28
26
  id: "one-tap";
29
27
  version: string;
30
28
  endpoints: {
31
- oneTapCallback: _$better_call0.StrictEndpoint<"/one-tap/callback", {
29
+ oneTapCallback: import("better-call").StrictEndpoint<"/one-tap/callback", {
32
30
  method: "POST";
33
31
  body: z.ZodObject<{
34
32
  idToken: z.ZodString;
@@ -78,5 +76,4 @@ declare const oneTap: (options?: OneTapOptions | undefined) => {
78
76
  };
79
77
  options: OneTapOptions | undefined;
80
78
  };
81
- //#endregion
82
- export { OneTapOptions, oneTap };
79
+ //#endregion
@@ -1,10 +1,9 @@
1
1
  import { OneTimeTokenOptions, oneTimeToken } from "./index.mjs";
2
-
3
2
  //#region src/plugins/one-time-token/client.d.ts
4
- declare const oneTimeTokenClient: () => {
3
+ export declare const oneTimeTokenClient: () => {
5
4
  id: "one-time-token";
6
5
  version: string;
7
6
  $InferServerPlugin: ReturnType<typeof oneTimeToken>;
8
7
  };
9
8
  //#endregion
10
- export { oneTimeTokenClient };
9
+ export type { OneTimeTokenOptions };
@@ -1,8 +1,7 @@
1
1
  import { Session, User } from "../../types/models.mjs";
2
+ import "../../types/index.mjs";
2
3
  import { GenericEndpointContext } from "@better-auth/core";
3
- import * as _$better_call0 from "better-call";
4
4
  import * as z from "zod";
5
-
6
5
  //#region src/plugins/one-time-token/index.d.ts
7
6
  declare module "@better-auth/core" {
8
7
  interface BetterAuthPluginRegistry<AuthOptions, Options> {
@@ -11,7 +10,7 @@ declare module "@better-auth/core" {
11
10
  };
12
11
  }
13
12
  }
14
- interface OneTimeTokenOptions {
13
+ export interface OneTimeTokenOptions {
15
14
  /**
16
15
  * Expires in minutes
17
16
  *
@@ -48,7 +47,7 @@ interface OneTimeTokenOptions {
48
47
  */
49
48
  setOttHeaderOnNewSession?: boolean;
50
49
  }
51
- declare const oneTimeToken: (options?: OneTimeTokenOptions | undefined) => {
50
+ export declare const oneTimeToken: (options?: OneTimeTokenOptions | undefined) => {
52
51
  id: "one-time-token";
53
52
  version: string;
54
53
  endpoints: {
@@ -67,9 +66,9 @@ declare const oneTimeToken: (options?: OneTimeTokenOptions | undefined) => {
67
66
  *
68
67
  * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/one-time-token#api-method-one-time-token-generate)
69
68
  */
70
- generateOneTimeToken: _$better_call0.StrictEndpoint<"/one-time-token/generate", {
69
+ generateOneTimeToken: import("better-call").StrictEndpoint<"/one-time-token/generate", {
71
70
  method: "GET";
72
- use: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
71
+ use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
73
72
  session: {
74
73
  session: Record<string, any> & {
75
74
  id: string;
@@ -110,7 +109,7 @@ declare const oneTimeToken: (options?: OneTimeTokenOptions | undefined) => {
110
109
  *
111
110
  * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/one-time-token#api-method-one-time-token-verify)
112
111
  */
113
- verifyOneTimeToken: _$better_call0.StrictEndpoint<"/one-time-token/verify", {
112
+ verifyOneTimeToken: import("better-call").StrictEndpoint<"/one-time-token/verify", {
114
113
  method: "POST";
115
114
  body: z.ZodObject<{
116
115
  token: z.ZodString;
@@ -123,10 +122,9 @@ declare const oneTimeToken: (options?: OneTimeTokenOptions | undefined) => {
123
122
  hooks: {
124
123
  after: {
125
124
  matcher: () => true;
126
- handler: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<void>>;
125
+ handler: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>>;
127
126
  }[];
128
127
  };
129
128
  options: OneTimeTokenOptions | undefined;
130
129
  };
131
- //#endregion
132
- export { OneTimeTokenOptions, oneTimeToken };
130
+ //#endregion
@@ -1,9 +1,8 @@
1
1
  import { AuthContext, BetterAuthOptions } from "@better-auth/core";
2
2
  import { DBFieldAttributeConfig, DBFieldType } from "@better-auth/core/db";
3
3
  import { OpenAPIParameter, OpenAPISchemaType } from "better-call";
4
-
5
4
  //#region src/plugins/open-api/generator.d.ts
6
- interface Path {
5
+ export interface Path {
7
6
  get?: OpenAPIOperation | undefined;
8
7
  post?: OpenAPIOperation | undefined;
9
8
  put?: OpenAPIOperation | undefined;
@@ -11,7 +10,7 @@ interface Path {
11
10
  delete?: OpenAPIOperation | undefined;
12
11
  }
13
12
  type OpenAPISchemaPrimitiveType = OpenAPISchemaType | "null";
14
- type OpenAPISchema = {
13
+ export type OpenAPISchema = {
15
14
  type?: OpenAPISchemaPrimitiveType | OpenAPISchemaPrimitiveType[];
16
15
  properties?: Record<string, OpenAPISchema>;
17
16
  required?: string[];
@@ -70,8 +69,9 @@ type OpenAPIOperation = {
70
69
  requestBody?: OpenAPIRequestBody;
71
70
  responses?: Record<string, OpenAPIResponse>;
72
71
  };
73
- type FieldSchema = {
74
- type: DBFieldType | "array"; /** Element schema for `type: "array"` (JSON Schema / OpenAPI array shape). */
72
+ export type FieldSchema = {
73
+ type: DBFieldType | "array";
74
+ /** Element schema for `type: "array"` (JSON Schema / OpenAPI array shape). */
75
75
  items?: {
76
76
  type: string;
77
77
  };
@@ -79,12 +79,12 @@ type FieldSchema = {
79
79
  readOnly?: boolean | undefined;
80
80
  format?: string;
81
81
  };
82
- type OpenAPIModelSchema = {
82
+ export type OpenAPIModelSchema = {
83
83
  type: "object";
84
84
  properties: Record<string, FieldSchema>;
85
85
  required?: string[] | undefined;
86
86
  };
87
- declare function generator(ctx: AuthContext, options: BetterAuthOptions): Promise<{
87
+ export declare function generator(ctx: AuthContext, options: BetterAuthOptions): Promise<{
88
88
  openapi: string;
89
89
  info: {
90
90
  title: string;
@@ -123,4 +123,4 @@ declare function generator(ctx: AuthContext, options: BetterAuthOptions): Promis
123
123
  paths: Record<string, Path>;
124
124
  }>;
125
125
  //#endregion
126
- export { FieldSchema, OpenAPIModelSchema, OpenAPIParameter$1 as OpenAPIParameter, OpenAPISchema, Path, generator };
126
+ export { OpenAPIParameter$1 as OpenAPIParameter };
@@ -2,7 +2,7 @@ import { db_exports } from "../../db/index.mjs";
2
2
  import { getEndpoints } from "../../api/index.mjs";
3
3
  import * as z from "zod";
4
4
  //#region src/plugins/open-api/generator.ts
5
- const OPEN_API_SCHEMA_TYPES = new Set([
5
+ const OPEN_API_SCHEMA_TYPES = /* @__PURE__ */ new Set([
6
6
  "string",
7
7
  "number",
8
8
  "boolean",
@@ -51,7 +51,7 @@ function withDescription(schema, zodType) {
51
51
  function addNullType(schema) {
52
52
  if (schema.type) {
53
53
  const type = Array.isArray(schema.type) ? schema.type : [schema.type];
54
- const nullableType = Array.from(new Set([...type, "null"]));
54
+ const nullableType = Array.from(/* @__PURE__ */ new Set([...type, "null"]));
55
55
  return {
56
56
  ...schema,
57
57
  type: nullableType
@@ -152,7 +152,7 @@ function mergeObjectSchemas(left, right, description) {
152
152
  if (properties[key] !== void 0 && !areSchemasEqual(properties[key], value)) return;
153
153
  properties[key] = value;
154
154
  }
155
- const required = Array.from(new Set([...left.required || [], ...right.required || []]));
155
+ const required = Array.from(/* @__PURE__ */ new Set([...left.required || [], ...right.required || []]));
156
156
  const leftAdditionalProperties = left.additionalProperties;
157
157
  const rightAdditionalProperties = right.additionalProperties;
158
158
  if (!areSchemaMembersCompatible(leftAdditionalProperties, rightAdditionalProperties)) return;
@@ -184,7 +184,7 @@ function getRequestBody(options) {
184
184
  * Paths that accept `user.additionalFields` and plugin user schema fields via
185
185
  * `parseUserInput`. Their static OpenAPI request bodies need those fields merged in.
186
186
  */
187
- const USER_INPUT_BODY_PATHS = new Set(["/sign-up/email", "/update-user"]);
187
+ const USER_INPUT_BODY_PATHS = /* @__PURE__ */ new Set(["/sign-up/email", "/update-user"]);
188
188
  function dbFieldToRequestBodyProperty(field) {
189
189
  if (field.type === "date") return {
190
190
  type: "string",
@@ -414,7 +414,7 @@ async function generator(ctx, options) {
414
414
  const components = { schemas: { ...Object.entries(tables).reduce((acc, [key, value]) => {
415
415
  const modelName = key.charAt(0).toUpperCase() + key.slice(1);
416
416
  const fields = value.fields;
417
- const required = new Set(["id"]);
417
+ const required = /* @__PURE__ */ new Set(["id"]);
418
418
  const properties = { id: {
419
419
  type: "string",
420
420
  readOnly: true
@@ -1,7 +1,5 @@
1
1
  import { FieldSchema, OpenAPIModelSchema, OpenAPIParameter, OpenAPISchema, Path, generator } from "./generator.mjs";
2
2
  import { LiteralString } from "@better-auth/core";
3
- import * as _$better_call0 from "better-call";
4
-
5
3
  //#region src/plugins/open-api/index.d.ts
6
4
  declare module "@better-auth/core" {
7
5
  interface BetterAuthPluginRegistry<AuthOptions, Options> {
@@ -11,7 +9,7 @@ declare module "@better-auth/core" {
11
9
  }
12
10
  }
13
11
  type ScalarTheme = "alternate" | "default" | "moon" | "purple" | "solarized" | "bluePlanet" | "saturn" | "kepler" | "mars" | "deepSpace" | "laserwave" | "none";
14
- interface OpenAPIOptions {
12
+ export interface OpenAPIOptions {
15
13
  /**
16
14
  * The path to the OpenAPI reference page
17
15
  *
@@ -40,11 +38,11 @@ interface OpenAPIOptions {
40
38
  */
41
39
  nonce?: string | undefined;
42
40
  }
43
- declare const openAPI: <O extends OpenAPIOptions>(options?: O | undefined) => {
41
+ export declare const openAPI: <O extends OpenAPIOptions>(options?: O | undefined) => {
44
42
  id: "open-api";
45
43
  version: string;
46
44
  endpoints: {
47
- generateOpenAPISchema: _$better_call0.StrictEndpoint<"/open-api/generate-schema", {
45
+ generateOpenAPISchema: import("better-call").StrictEndpoint<"/open-api/generate-schema", {
48
46
  method: "GET";
49
47
  }, {
50
48
  openapi: string;
@@ -84,7 +82,7 @@ declare const openAPI: <O extends OpenAPIOptions>(options?: O | undefined) => {
84
82
  }[];
85
83
  paths: Record<string, Path>;
86
84
  }>;
87
- openAPIReference: _$better_call0.StrictEndpoint<LiteralString | "/reference", {
85
+ openAPIReference: import("better-call").StrictEndpoint<LiteralString | "/reference", {
88
86
  method: "GET";
89
87
  metadata: {
90
88
  readonly scope: "server";
@@ -94,4 +92,4 @@ declare const openAPI: <O extends OpenAPIOptions>(options?: O | undefined) => {
94
92
  options: NoInfer<O>;
95
93
  };
96
94
  //#endregion
97
- export { type FieldSchema, type OpenAPIModelSchema, OpenAPIOptions, OpenAPIParameter, OpenAPISchema, type Path, generator, openAPI };
95
+ export type { FieldSchema, OpenAPIModelSchema, OpenAPIParameter, OpenAPISchema, Path, generator };
@@ -1,2 +1 @@
1
- import { adminAc, defaultAc, defaultRoles, defaultStatements, memberAc, ownerAc } from "./statement.mjs";
2
- export { adminAc, defaultAc, defaultRoles, defaultStatements, memberAc, ownerAc };
1
+ export { adminAc, defaultAc, defaultRoles, defaultStatements, memberAc, ownerAc } from "./statement.mjs";
@@ -1,13 +1,14 @@
1
1
  import { ExactRoleStatements, Role, RoleInput, Statements } from "../../access/types.mjs";
2
+ import "../../index.mjs";
2
3
  //#region src/plugins/organization/access/statement.d.ts
3
- declare const defaultStatements: {
4
+ export declare const defaultStatements: {
4
5
  readonly organization: readonly ["update", "delete"];
5
6
  readonly member: readonly ["create", "update", "delete"];
6
7
  readonly invitation: readonly ["create", "cancel"];
7
8
  readonly team: readonly ["create", "update", "delete"];
8
9
  readonly ac: readonly ["create", "read", "update", "delete"];
9
10
  };
10
- declare const defaultAc: {
11
+ export declare const defaultAc: {
11
12
  newRole<const TRoleStatements extends Statements>(statements: RoleInput<{
12
13
  readonly organization: readonly ["update", "delete"];
13
14
  readonly member: readonly ["create", "update", "delete"];
@@ -29,7 +30,7 @@ declare const defaultAc: {
29
30
  readonly ac: readonly ["create", "read", "update", "delete"];
30
31
  };
31
32
  };
32
- declare const adminAc: Role<ExactRoleStatements<{
33
+ export declare const adminAc: Role<ExactRoleStatements<{
33
34
  readonly organization: ["update"];
34
35
  readonly invitation: ["create", "cancel"];
35
36
  readonly member: ["create", "update", "delete"];
@@ -42,7 +43,7 @@ declare const adminAc: Role<ExactRoleStatements<{
42
43
  readonly team: readonly ["create", "update", "delete"];
43
44
  readonly ac: readonly ["create", "read", "update", "delete"];
44
45
  }>;
45
- declare const ownerAc: Role<ExactRoleStatements<{
46
+ export declare const ownerAc: Role<ExactRoleStatements<{
46
47
  readonly organization: ["update", "delete"];
47
48
  readonly member: ["create", "update", "delete"];
48
49
  readonly invitation: ["create", "cancel"];
@@ -55,7 +56,7 @@ declare const ownerAc: Role<ExactRoleStatements<{
55
56
  readonly team: readonly ["create", "update", "delete"];
56
57
  readonly ac: readonly ["create", "read", "update", "delete"];
57
58
  }>;
58
- declare const memberAc: Role<ExactRoleStatements<{
59
+ export declare const memberAc: Role<ExactRoleStatements<{
59
60
  readonly organization: [];
60
61
  readonly member: [];
61
62
  readonly invitation: [];
@@ -68,7 +69,7 @@ declare const memberAc: Role<ExactRoleStatements<{
68
69
  readonly team: readonly ["create", "update", "delete"];
69
70
  readonly ac: readonly ["create", "read", "update", "delete"];
70
71
  }>;
71
- declare const defaultRoles: {
72
+ export declare const defaultRoles: {
72
73
  admin: Role<ExactRoleStatements<{
73
74
  readonly organization: ["update"];
74
75
  readonly invitation: ["create", "cancel"];
@@ -109,5 +110,4 @@ declare const defaultRoles: {
109
110
  readonly ac: readonly ["create", "read", "update", "delete"];
110
111
  }>;
111
112
  };
112
- //#endregion
113
- export { adminAc, defaultAc, defaultRoles, defaultStatements, memberAc, ownerAc };
113
+ //#endregion