better-auth-studio 1.1.2-beta.15 → 1.1.2-beta.17

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 (88) hide show
  1. package/README.md +38 -25
  2. package/data/default-geo.json +1 -1
  3. package/dist/adapters/astro.d.ts +1 -1
  4. package/dist/adapters/astro.js +13 -13
  5. package/dist/adapters/elysia.d.ts +2 -2
  6. package/dist/adapters/elysia.js +13 -13
  7. package/dist/adapters/express.d.ts +2 -2
  8. package/dist/adapters/express.js +4 -4
  9. package/dist/adapters/hono.d.ts +2 -2
  10. package/dist/adapters/hono.js +12 -12
  11. package/dist/adapters/nextjs.d.ts +1 -1
  12. package/dist/adapters/nextjs.js +10 -10
  13. package/dist/adapters/nuxt.d.ts +1 -1
  14. package/dist/adapters/nuxt.js +22 -22
  15. package/dist/adapters/remix.d.ts +1 -1
  16. package/dist/adapters/remix.js +13 -13
  17. package/dist/adapters/solid-start.d.ts +1 -1
  18. package/dist/adapters/solid-start.js +13 -13
  19. package/dist/adapters/svelte-kit.d.ts +2 -2
  20. package/dist/adapters/svelte-kit.js +13 -13
  21. package/dist/adapters/tanstack-start.d.ts +1 -1
  22. package/dist/adapters/tanstack-start.js +13 -13
  23. package/dist/add-svelte-kit-env-modules.js +11 -11
  24. package/dist/auth-adapter.d.ts +1 -1
  25. package/dist/auth-adapter.js +96 -96
  26. package/dist/cli/commands/init.js +57 -57
  27. package/dist/cli.js +75 -75
  28. package/dist/config.d.ts +5 -5
  29. package/dist/config.js +37 -37
  30. package/dist/core/handler.d.ts +1 -1
  31. package/dist/core/handler.js +115 -115
  32. package/dist/data.d.ts +2 -2
  33. package/dist/data.js +60 -60
  34. package/dist/geo-service.js +78 -78
  35. package/dist/get-tsconfig-info.js +4 -4
  36. package/dist/index.d.ts +8 -8
  37. package/dist/index.js +6 -6
  38. package/dist/providers/events/helpers.d.ts +2 -2
  39. package/dist/providers/events/helpers.js +156 -156
  40. package/dist/public/assets/{main-Cu8ik7af.js → main-tA7wDMDp.js} +1 -1
  41. package/dist/public/index.html +1 -1
  42. package/dist/routes/api-router.d.ts +2 -2
  43. package/dist/routes/api-router.js +3 -3
  44. package/dist/routes.d.ts +4 -4
  45. package/dist/routes.d.ts.map +1 -1
  46. package/dist/routes.js +1272 -1272
  47. package/dist/routes.js.map +1 -1
  48. package/dist/studio.d.ts +3 -3
  49. package/dist/studio.js +64 -64
  50. package/dist/types/events.d.ts +7 -7
  51. package/dist/types/events.js +165 -165
  52. package/dist/types/handler.d.ts +5 -5
  53. package/dist/utils/auth-callbacks-injector.d.ts +2 -2
  54. package/dist/utils/auth-callbacks-injector.js +27 -27
  55. package/dist/utils/auth-callbacks-wrapper.d.ts +3 -3
  56. package/dist/utils/auth-callbacks-wrapper.js +117 -107
  57. package/dist/utils/database-detection.d.ts +1 -1
  58. package/dist/utils/database-detection.js +44 -44
  59. package/dist/utils/database-hook-injector.d.ts +3 -3
  60. package/dist/utils/database-hook-injector.js +135 -131
  61. package/dist/utils/email-otp-hooks-injector.d.ts +28 -12
  62. package/dist/utils/email-otp-hooks-injector.js +104 -97
  63. package/dist/utils/event-ingestion.d.ts +5 -5
  64. package/dist/utils/event-ingestion.d.ts.map +1 -1
  65. package/dist/utils/event-ingestion.js +14 -16
  66. package/dist/utils/event-ingestion.js.map +1 -1
  67. package/dist/utils/hook-injector.d.ts +2 -2
  68. package/dist/utils/hook-injector.js +199 -199
  69. package/dist/utils/html-injector.d.ts +3 -3
  70. package/dist/utils/html-injector.js +37 -37
  71. package/dist/utils/org-hooks-injector.d.ts +3 -3
  72. package/dist/utils/org-hooks-injector.js +63 -63
  73. package/dist/utils/org-hooks-wrapper.d.ts +41 -35
  74. package/dist/utils/org-hooks-wrapper.js +778 -658
  75. package/dist/utils/organization-hooks-wrapper.d.ts +23 -17
  76. package/dist/utils/organization-hooks-wrapper.js +325 -277
  77. package/dist/utils/package-json.js +11 -11
  78. package/dist/utils/paths.js +1 -1
  79. package/dist/utils/server-init.d.ts +1 -1
  80. package/dist/utils/server-init.js +25 -25
  81. package/dist/utils/session.js +12 -12
  82. package/dist/utils.js +24 -24
  83. package/package.json +47 -55
  84. package/public/assets/{main-Cu8ik7af.js → main-tA7wDMDp.js} +1 -1
  85. package/public/index.html +1 -1
  86. package/scripts/download-geolite2.js +8 -8
  87. package/scripts/generate-default-db.js +324 -324
  88. package/scripts/postinstall.js +25 -25
@@ -1,5 +1,5 @@
1
- import { handleStudioRequest } from '../core/handler.js';
2
- import { injectEventHooks } from '../utils/hook-injector.js';
1
+ import { handleStudioRequest } from "../core/handler.js";
2
+ import { injectEventHooks } from "../utils/hook-injector.js";
3
3
  /**
4
4
  * Remix adapter for Better Auth Studio
5
5
  *
@@ -32,10 +32,10 @@ export function betterAuthStudio(config) {
32
32
  return universalToResponse(universalRes);
33
33
  }
34
34
  catch (error) {
35
- console.error('Studio handler error:', error);
36
- return new Response(JSON.stringify({ error: 'Internal server error' }), {
35
+ console.error("Studio handler error:", error);
36
+ return new Response(JSON.stringify({ error: "Internal server error" }), {
37
37
  status: 500,
38
- headers: { 'Content-Type': 'application/json' },
38
+ headers: { "Content-Type": "application/json" },
39
39
  });
40
40
  }
41
41
  };
@@ -43,16 +43,16 @@ export function betterAuthStudio(config) {
43
43
  async function convertRemixToUniversal({ request }, config) {
44
44
  let body;
45
45
  const method = request.method;
46
- if (method !== 'GET' && method !== 'HEAD') {
47
- const contentType = request.headers.get('content-type') || '';
48
- if (contentType.includes('application/json')) {
46
+ if (method !== "GET" && method !== "HEAD") {
47
+ const contentType = request.headers.get("content-type") || "";
48
+ if (contentType.includes("application/json")) {
49
49
  try {
50
50
  body = await request.json();
51
51
  }
52
52
  catch { }
53
53
  }
54
- else if (contentType.includes('application/x-www-form-urlencoded') ||
55
- contentType.includes('multipart/form-data')) {
54
+ else if (contentType.includes("application/x-www-form-urlencoded") ||
55
+ contentType.includes("multipart/form-data")) {
56
56
  try {
57
57
  const formData = await request.formData();
58
58
  body = Object.fromEntries(formData.entries());
@@ -78,12 +78,12 @@ async function convertRemixToUniversal({ request }, config) {
78
78
  request.headers.forEach((value, key) => {
79
79
  headers[key] = value;
80
80
  });
81
- const basePath = config.basePath || '/api/studio';
82
- const normalizedBasePath = basePath.endsWith('/') ? basePath.slice(0, -1) : basePath;
81
+ const basePath = config.basePath || "/api/studio";
82
+ const normalizedBasePath = basePath.endsWith("/") ? basePath.slice(0, -1) : basePath;
83
83
  const url = new URL(request.url);
84
84
  let path = url.pathname;
85
85
  if (path.startsWith(normalizedBasePath)) {
86
- path = path.slice(normalizedBasePath.length) || '/';
86
+ path = path.slice(normalizedBasePath.length) || "/";
87
87
  }
88
88
  const pathWithQuery = path + url.search;
89
89
  return {
@@ -1,4 +1,4 @@
1
- import type { StudioConfig } from '../types/handler.js';
1
+ import type { StudioConfig } from "../types/handler.js";
2
2
  type ApiEvent = {
3
3
  request: Request;
4
4
  params: Record<string, string>;
@@ -1,5 +1,5 @@
1
- import { handleStudioRequest } from '../core/handler.js';
2
- import { injectEventHooks } from '../utils/hook-injector.js';
1
+ import { handleStudioRequest } from "../core/handler.js";
2
+ import { injectEventHooks } from "../utils/hook-injector.js";
3
3
  /**
4
4
  * SolidStart adapter for Better Auth Studio
5
5
  *
@@ -29,10 +29,10 @@ export function betterAuthStudio(config) {
29
29
  return universalToResponse(universalRes);
30
30
  }
31
31
  catch (error) {
32
- console.error('Studio handler error:', error);
33
- return new Response(JSON.stringify({ error: 'Internal server error' }), {
32
+ console.error("Studio handler error:", error);
33
+ return new Response(JSON.stringify({ error: "Internal server error" }), {
34
34
  status: 500,
35
- headers: { 'Content-Type': 'application/json' },
35
+ headers: { "Content-Type": "application/json" },
36
36
  });
37
37
  }
38
38
  };
@@ -41,16 +41,16 @@ async function convertSolidStartToUniversal(event, config) {
41
41
  const request = event.request;
42
42
  let body;
43
43
  const method = request.method;
44
- if (method !== 'GET' && method !== 'HEAD') {
45
- const contentType = request.headers.get('content-type') || '';
46
- if (contentType.includes('application/json')) {
44
+ if (method !== "GET" && method !== "HEAD") {
45
+ const contentType = request.headers.get("content-type") || "";
46
+ if (contentType.includes("application/json")) {
47
47
  try {
48
48
  body = await request.json();
49
49
  }
50
50
  catch { }
51
51
  }
52
- else if (contentType.includes('application/x-www-form-urlencoded') ||
53
- contentType.includes('multipart/form-data')) {
52
+ else if (contentType.includes("application/x-www-form-urlencoded") ||
53
+ contentType.includes("multipart/form-data")) {
54
54
  try {
55
55
  const formData = await request.formData();
56
56
  body = Object.fromEntries(formData.entries());
@@ -76,12 +76,12 @@ async function convertSolidStartToUniversal(event, config) {
76
76
  request.headers.forEach((value, key) => {
77
77
  headers[key] = value;
78
78
  });
79
- const basePath = config.basePath || '/api/studio';
80
- const normalizedBasePath = basePath.endsWith('/') ? basePath.slice(0, -1) : basePath;
79
+ const basePath = config.basePath || "/api/studio";
80
+ const normalizedBasePath = basePath.endsWith("/") ? basePath.slice(0, -1) : basePath;
81
81
  const url = new URL(request.url);
82
82
  let path = url.pathname;
83
83
  if (path.startsWith(normalizedBasePath)) {
84
- path = path.slice(normalizedBasePath.length) || '/';
84
+ path = path.slice(normalizedBasePath.length) || "/";
85
85
  }
86
86
  const pathWithQuery = path + url.search;
87
87
  return {
@@ -1,5 +1,5 @@
1
- import type { RequestEvent } from '@sveltejs/kit';
2
- import type { StudioConfig } from '../types/handler.js';
1
+ import type { RequestEvent } from "@sveltejs/kit";
2
+ import type { StudioConfig } from "../types/handler.js";
3
3
  /**
4
4
  * SvelteKit adapter for Better Auth Studio
5
5
  *
@@ -1,5 +1,5 @@
1
- import { handleStudioRequest } from '../core/handler.js';
2
- import { injectEventHooks } from '../utils/hook-injector.js';
1
+ import { handleStudioRequest } from "../core/handler.js";
2
+ import { injectEventHooks } from "../utils/hook-injector.js";
3
3
  /**
4
4
  * SvelteKit adapter for Better Auth Studio
5
5
  *
@@ -43,10 +43,10 @@ export function betterAuthStudio(config) {
43
43
  return universalToResponse(universalRes);
44
44
  }
45
45
  catch (error) {
46
- console.error('Studio handler error:', error);
47
- return new Response(JSON.stringify({ error: 'Internal server error' }), {
46
+ console.error("Studio handler error:", error);
47
+ return new Response(JSON.stringify({ error: "Internal server error" }), {
48
48
  status: 500,
49
- headers: { 'Content-Type': 'application/json' },
49
+ headers: { "Content-Type": "application/json" },
50
50
  });
51
51
  }
52
52
  };
@@ -54,16 +54,16 @@ export function betterAuthStudio(config) {
54
54
  async function convertSvelteKitToUniversal(event, config) {
55
55
  let body;
56
56
  const method = event.request.method;
57
- if (method !== 'GET' && method !== 'HEAD') {
58
- const contentType = event.request.headers.get('content-type') || '';
59
- if (contentType.includes('application/json')) {
57
+ if (method !== "GET" && method !== "HEAD") {
58
+ const contentType = event.request.headers.get("content-type") || "";
59
+ if (contentType.includes("application/json")) {
60
60
  try {
61
61
  body = await event.request.json();
62
62
  }
63
63
  catch { }
64
64
  }
65
- else if (contentType.includes('application/x-www-form-urlencoded') ||
66
- contentType.includes('multipart/form-data')) {
65
+ else if (contentType.includes("application/x-www-form-urlencoded") ||
66
+ contentType.includes("multipart/form-data")) {
67
67
  try {
68
68
  const formData = await event.request.formData();
69
69
  body = Object.fromEntries(formData.entries());
@@ -89,11 +89,11 @@ async function convertSvelteKitToUniversal(event, config) {
89
89
  event.request.headers.forEach((value, key) => {
90
90
  headers[key] = value;
91
91
  });
92
- const basePath = config.basePath || '/api/studio';
93
- const normalizedBasePath = basePath.endsWith('/') ? basePath.slice(0, -1) : basePath;
92
+ const basePath = config.basePath || "/api/studio";
93
+ const normalizedBasePath = basePath.endsWith("/") ? basePath.slice(0, -1) : basePath;
94
94
  let path = event.url.pathname;
95
95
  if (path.startsWith(normalizedBasePath)) {
96
- path = path.slice(normalizedBasePath.length) || '/';
96
+ path = path.slice(normalizedBasePath.length) || "/";
97
97
  }
98
98
  const pathWithQuery = path + event.url.search;
99
99
  return {
@@ -1,4 +1,4 @@
1
- import type { StudioConfig } from '../types/handler.js';
1
+ import type { StudioConfig } from "../types/handler.js";
2
2
  type TanStackStartHandlerContext = {
3
3
  request: Request;
4
4
  };
@@ -1,5 +1,5 @@
1
- import { handleStudioRequest } from '../core/handler.js';
2
- import { injectEventHooks } from '../utils/hook-injector.js';
1
+ import { handleStudioRequest } from "../core/handler.js";
2
+ import { injectEventHooks } from "../utils/hook-injector.js";
3
3
  /**
4
4
  * TanStack Start adapter for Better Auth Studio
5
5
  *
@@ -36,10 +36,10 @@ export function betterAuthStudio(config) {
36
36
  return universalToResponse(universalRes);
37
37
  }
38
38
  catch (error) {
39
- console.error('Studio handler error:', error);
40
- return new Response(JSON.stringify({ error: 'Internal server error' }), {
39
+ console.error("Studio handler error:", error);
40
+ return new Response(JSON.stringify({ error: "Internal server error" }), {
41
41
  status: 500,
42
- headers: { 'Content-Type': 'application/json' },
42
+ headers: { "Content-Type": "application/json" },
43
43
  });
44
44
  }
45
45
  };
@@ -47,16 +47,16 @@ export function betterAuthStudio(config) {
47
47
  async function convertTanStackStartToUniversal(request, config) {
48
48
  let body;
49
49
  const method = request.method;
50
- if (method !== 'GET' && method !== 'HEAD') {
51
- const contentType = request.headers.get('content-type') || '';
52
- if (contentType.includes('application/json')) {
50
+ if (method !== "GET" && method !== "HEAD") {
51
+ const contentType = request.headers.get("content-type") || "";
52
+ if (contentType.includes("application/json")) {
53
53
  try {
54
54
  body = await request.json();
55
55
  }
56
56
  catch { }
57
57
  }
58
- else if (contentType.includes('application/x-www-form-urlencoded') ||
59
- contentType.includes('multipart/form-data')) {
58
+ else if (contentType.includes("application/x-www-form-urlencoded") ||
59
+ contentType.includes("multipart/form-data")) {
60
60
  try {
61
61
  const formData = await request.formData();
62
62
  body = Object.fromEntries(formData.entries());
@@ -82,12 +82,12 @@ async function convertTanStackStartToUniversal(request, config) {
82
82
  request.headers.forEach((value, key) => {
83
83
  headers[key] = value;
84
84
  });
85
- const basePath = config.basePath || '/api/studio';
86
- const normalizedBasePath = basePath.endsWith('/') ? basePath.slice(0, -1) : basePath;
85
+ const basePath = config.basePath || "/api/studio";
86
+ const normalizedBasePath = basePath.endsWith("/") ? basePath.slice(0, -1) : basePath;
87
87
  const url = new URL(request.url);
88
88
  let path = url.pathname;
89
89
  if (path.startsWith(normalizedBasePath)) {
90
- path = path.slice(normalizedBasePath.length) || '/';
90
+ path = path.slice(normalizedBasePath.length) || "/";
91
91
  }
92
92
  const pathWithQuery = path + url.search;
93
93
  return {
@@ -1,15 +1,15 @@
1
1
  export function addSvelteKitEnvModules(alias) {
2
2
  // Add SvelteKit environment modules to the alias
3
- alias['$env/static/public'] = 'sveltekit-env-static-public';
4
- alias['$env/static/private'] = 'sveltekit-env-static-private';
5
- alias['$env/dynamic/public'] = 'sveltekit-env-dynamic-public';
6
- alias['$env/dynamic/private'] = 'sveltekit-env-dynamic-private';
7
- alias['$app/environment'] = '@sveltejs/kit';
8
- alias['$app/forms'] = '@sveltejs/kit';
9
- alias['$app/navigation'] = '@sveltejs/kit';
10
- alias['$app/paths'] = '@sveltejs/kit';
11
- alias['$app/stores'] = '@sveltejs/kit';
12
- alias['$app/types'] = '@sveltejs/kit';
13
- alias['$app/*'] = '@sveltejs/kit';
3
+ alias["$env/static/public"] = "sveltekit-env-static-public";
4
+ alias["$env/static/private"] = "sveltekit-env-static-private";
5
+ alias["$env/dynamic/public"] = "sveltekit-env-dynamic-public";
6
+ alias["$env/dynamic/private"] = "sveltekit-env-dynamic-private";
7
+ alias["$app/environment"] = "@sveltejs/kit";
8
+ alias["$app/forms"] = "@sveltejs/kit";
9
+ alias["$app/navigation"] = "@sveltejs/kit";
10
+ alias["$app/paths"] = "@sveltejs/kit";
11
+ alias["$app/stores"] = "@sveltejs/kit";
12
+ alias["$app/types"] = "@sveltejs/kit";
13
+ alias["$app/*"] = "@sveltejs/kit";
14
14
  }
15
15
  //# sourceMappingURL=add-svelte-kit-env-modules.js.map
@@ -1,4 +1,4 @@
1
- import type { InternalAdapter } from 'better-auth';
1
+ import type { InternalAdapter } from "better-auth";
2
2
  type OptionalFields<T> = {
3
3
  [K in keyof T]?: T[K];
4
4
  };