@better-auth/core 1.4.6-beta.2 → 1.4.6-beta.4

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 (59) hide show
  1. package/.turbo/turbo-build.log +31 -30
  2. package/dist/api/index.d.mts +1 -2
  3. package/dist/api/index.mjs +3 -2
  4. package/dist/async_hooks/index.d.mts +1 -1
  5. package/dist/async_hooks/index.mjs +2 -1
  6. package/dist/async_hooks-CrTStdt6.mjs +45 -0
  7. package/dist/context/index.d.mts +2 -3
  8. package/dist/context/index.mjs +3 -2
  9. package/dist/{context-DgQ9XGBl.mjs → context-su4uu82y.mjs} +1 -1
  10. package/dist/db/adapter/index.d.mts +2 -3
  11. package/dist/db/adapter/index.mjs +955 -1
  12. package/dist/db/index.d.mts +2 -3
  13. package/dist/db/index.mjs +2 -1
  14. package/dist/env/index.d.mts +1 -1
  15. package/dist/env/index.mjs +1 -1
  16. package/dist/error/index.mjs +3 -2
  17. package/dist/{error-BhAKg8LX.mjs → error-CMXuwPsa.mjs} +1 -1
  18. package/dist/get-tables-BGfrxIVZ.mjs +252 -0
  19. package/dist/{index-D_XSRX55.d.mts → index-Bp1Bfmzt.d.mts} +307 -32
  20. package/dist/{index-DgwIISs7.d.mts → index-Da4Ujjef.d.mts} +0 -1
  21. package/dist/index.d.mts +2 -3
  22. package/dist/oauth2/index.d.mts +1 -2
  23. package/dist/oauth2/index.mjs +1 -1
  24. package/dist/social-providers/index.d.mts +2 -3
  25. package/dist/social-providers/index.mjs +22 -8
  26. package/dist/utils/index.d.mts +10 -1
  27. package/dist/utils/index.mjs +3 -2
  28. package/dist/utils-BqQC77zO.mjs +43 -0
  29. package/package.json +8 -6
  30. package/src/async_hooks/convex.spec.ts +12 -0
  31. package/src/async_hooks/index.ts +60 -25
  32. package/src/db/adapter/factory.ts +1368 -0
  33. package/src/db/adapter/get-default-field-name.ts +59 -0
  34. package/src/db/adapter/get-default-model-name.ts +51 -0
  35. package/src/db/adapter/get-field-attributes.ts +62 -0
  36. package/src/db/adapter/get-field-name.ts +43 -0
  37. package/src/db/adapter/get-id-field.ts +141 -0
  38. package/src/db/adapter/get-model-name.ts +36 -0
  39. package/src/db/adapter/index.ts +12 -0
  40. package/src/db/adapter/types.ts +161 -0
  41. package/src/db/adapter/utils.ts +61 -0
  42. package/src/db/get-tables.ts +276 -0
  43. package/src/db/index.ts +2 -0
  44. package/src/db/test/get-tables.test.ts +62 -0
  45. package/src/env/logger.ts +4 -6
  46. package/src/oauth2/oauth-provider.ts +1 -1
  47. package/src/social-providers/google.ts +46 -17
  48. package/src/types/context.ts +10 -0
  49. package/src/types/helper.ts +4 -0
  50. package/src/types/init-options.ts +24 -24
  51. package/src/utils/id.ts +5 -0
  52. package/src/utils/index.ts +3 -0
  53. package/src/utils/json.ts +25 -0
  54. package/src/utils/string.ts +3 -0
  55. package/dist/async_hooks-BfRfbd1J.mjs +0 -18
  56. package/dist/utils-C5EN75oV.mjs +0 -7
  57. /package/dist/{env-8yWFh7b8.mjs → env-D6s-lvJz.mjs} +0 -0
  58. /package/dist/{index-X1Fs3IbM.d.mts → index-D4vfN5ui.d.mts} +0 -0
  59. /package/dist/{oauth2-B2XPHgx5.mjs → oauth2-7k48hhcV.mjs} +0 -0
@@ -0,0 +1,25 @@
1
+ import { logger } from "../env";
2
+
3
+ export function safeJSONParse<T>(data: unknown): T | null {
4
+ function reviver(_: string, value: any): any {
5
+ if (typeof value === "string") {
6
+ const iso8601Regex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;
7
+ if (iso8601Regex.test(value)) {
8
+ const date = new Date(value);
9
+ if (!isNaN(date.getTime())) {
10
+ return date;
11
+ }
12
+ }
13
+ }
14
+ return value;
15
+ }
16
+ try {
17
+ if (typeof data !== "string") {
18
+ return data as T;
19
+ }
20
+ return JSON.parse(data, reviver);
21
+ } catch (e) {
22
+ logger.error("Error parsing JSON", { error: e });
23
+ return null;
24
+ }
25
+ }
@@ -0,0 +1,3 @@
1
+ export function capitalizeFirstLetter(str: string) {
2
+ return str.charAt(0).toUpperCase() + str.slice(1);
3
+ }
@@ -1,18 +0,0 @@
1
- //#region src/async_hooks/index.ts
2
- const AsyncLocalStoragePromise = import(
3
- /* @vite-ignore */
4
- /* webpackIgnore: true */
5
- "node:async_hooks"
6
- ).then((mod) => mod.AsyncLocalStorage).catch((err) => {
7
- if ("AsyncLocalStorage" in globalThis) return globalThis.AsyncLocalStorage;
8
- console.warn("[better-auth] Warning: AsyncLocalStorage is not available in this environment. Some features may not work as expected.");
9
- console.warn("[better-auth] Please read more about this warning at https://better-auth.com/docs/installation#mount-handler");
10
- console.warn("[better-auth] If you are using Cloudflare Workers, please see: https://developers.cloudflare.com/workers/configuration/compatibility-flags/#nodejs-compatibility-flag");
11
- throw err;
12
- });
13
- async function getAsyncLocalStorage() {
14
- return AsyncLocalStoragePromise;
15
- }
16
-
17
- //#endregion
18
- export { getAsyncLocalStorage as t };
@@ -1,7 +0,0 @@
1
- //#region src/utils/error-codes.ts
2
- function defineErrorCodes(codes) {
3
- return codes;
4
- }
5
-
6
- //#endregion
7
- export { defineErrorCodes as t };
File without changes