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.
- package/README.md +38 -25
- package/data/default-geo.json +1 -1
- package/dist/adapters/astro.d.ts +1 -1
- package/dist/adapters/astro.js +13 -13
- package/dist/adapters/elysia.d.ts +2 -2
- package/dist/adapters/elysia.js +13 -13
- package/dist/adapters/express.d.ts +2 -2
- package/dist/adapters/express.js +4 -4
- package/dist/adapters/hono.d.ts +2 -2
- package/dist/adapters/hono.js +12 -12
- package/dist/adapters/nextjs.d.ts +1 -1
- package/dist/adapters/nextjs.js +10 -10
- package/dist/adapters/nuxt.d.ts +1 -1
- package/dist/adapters/nuxt.js +22 -22
- package/dist/adapters/remix.d.ts +1 -1
- package/dist/adapters/remix.js +13 -13
- package/dist/adapters/solid-start.d.ts +1 -1
- package/dist/adapters/solid-start.js +13 -13
- package/dist/adapters/svelte-kit.d.ts +2 -2
- package/dist/adapters/svelte-kit.js +13 -13
- package/dist/adapters/tanstack-start.d.ts +1 -1
- package/dist/adapters/tanstack-start.js +13 -13
- package/dist/add-svelte-kit-env-modules.js +11 -11
- package/dist/auth-adapter.d.ts +1 -1
- package/dist/auth-adapter.js +96 -96
- package/dist/cli/commands/init.js +57 -57
- package/dist/cli.js +75 -75
- package/dist/config.d.ts +5 -5
- package/dist/config.js +37 -37
- package/dist/core/handler.d.ts +1 -1
- package/dist/core/handler.js +115 -115
- package/dist/data.d.ts +2 -2
- package/dist/data.js +60 -60
- package/dist/geo-service.js +78 -78
- package/dist/get-tsconfig-info.js +4 -4
- package/dist/index.d.ts +8 -8
- package/dist/index.js +6 -6
- package/dist/providers/events/helpers.d.ts +2 -2
- package/dist/providers/events/helpers.js +156 -156
- package/dist/public/assets/{main-Cu8ik7af.js → main-tA7wDMDp.js} +1 -1
- package/dist/public/index.html +1 -1
- package/dist/routes/api-router.d.ts +2 -2
- package/dist/routes/api-router.js +3 -3
- package/dist/routes.d.ts +4 -4
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +1272 -1272
- package/dist/routes.js.map +1 -1
- package/dist/studio.d.ts +3 -3
- package/dist/studio.js +64 -64
- package/dist/types/events.d.ts +7 -7
- package/dist/types/events.js +165 -165
- package/dist/types/handler.d.ts +5 -5
- package/dist/utils/auth-callbacks-injector.d.ts +2 -2
- package/dist/utils/auth-callbacks-injector.js +27 -27
- package/dist/utils/auth-callbacks-wrapper.d.ts +3 -3
- package/dist/utils/auth-callbacks-wrapper.js +117 -107
- package/dist/utils/database-detection.d.ts +1 -1
- package/dist/utils/database-detection.js +44 -44
- package/dist/utils/database-hook-injector.d.ts +3 -3
- package/dist/utils/database-hook-injector.js +135 -131
- package/dist/utils/email-otp-hooks-injector.d.ts +28 -12
- package/dist/utils/email-otp-hooks-injector.js +104 -97
- package/dist/utils/event-ingestion.d.ts +5 -5
- package/dist/utils/event-ingestion.d.ts.map +1 -1
- package/dist/utils/event-ingestion.js +14 -16
- package/dist/utils/event-ingestion.js.map +1 -1
- package/dist/utils/hook-injector.d.ts +2 -2
- package/dist/utils/hook-injector.js +199 -199
- package/dist/utils/html-injector.d.ts +3 -3
- package/dist/utils/html-injector.js +37 -37
- package/dist/utils/org-hooks-injector.d.ts +3 -3
- package/dist/utils/org-hooks-injector.js +63 -63
- package/dist/utils/org-hooks-wrapper.d.ts +41 -35
- package/dist/utils/org-hooks-wrapper.js +778 -658
- package/dist/utils/organization-hooks-wrapper.d.ts +23 -17
- package/dist/utils/organization-hooks-wrapper.js +325 -277
- package/dist/utils/package-json.js +11 -11
- package/dist/utils/paths.js +1 -1
- package/dist/utils/server-init.d.ts +1 -1
- package/dist/utils/server-init.js +25 -25
- package/dist/utils/session.js +12 -12
- package/dist/utils.js +24 -24
- package/package.json +47 -55
- package/public/assets/{main-Cu8ik7af.js → main-tA7wDMDp.js} +1 -1
- package/public/index.html +1 -1
- package/scripts/download-geolite2.js +8 -8
- package/scripts/generate-default-db.js +324 -324
- package/scripts/postinstall.js +25 -25
package/dist/adapters/remix.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { handleStudioRequest } from
|
|
2
|
-
import { injectEventHooks } from
|
|
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(
|
|
36
|
-
return new Response(JSON.stringify({ error:
|
|
35
|
+
console.error("Studio handler error:", error);
|
|
36
|
+
return new Response(JSON.stringify({ error: "Internal server error" }), {
|
|
37
37
|
status: 500,
|
|
38
|
-
headers: {
|
|
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 !==
|
|
47
|
-
const contentType = request.headers.get(
|
|
48
|
-
if (contentType.includes(
|
|
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(
|
|
55
|
-
contentType.includes(
|
|
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 ||
|
|
82
|
-
const normalizedBasePath = basePath.endsWith(
|
|
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,5 +1,5 @@
|
|
|
1
|
-
import { handleStudioRequest } from
|
|
2
|
-
import { injectEventHooks } from
|
|
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(
|
|
33
|
-
return new Response(JSON.stringify({ error:
|
|
32
|
+
console.error("Studio handler error:", error);
|
|
33
|
+
return new Response(JSON.stringify({ error: "Internal server error" }), {
|
|
34
34
|
status: 500,
|
|
35
|
-
headers: {
|
|
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 !==
|
|
45
|
-
const contentType = request.headers.get(
|
|
46
|
-
if (contentType.includes(
|
|
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(
|
|
53
|
-
contentType.includes(
|
|
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 ||
|
|
80
|
-
const normalizedBasePath = basePath.endsWith(
|
|
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
|
|
2
|
-
import type { StudioConfig } from
|
|
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
|
|
2
|
-
import { injectEventHooks } from
|
|
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(
|
|
47
|
-
return new Response(JSON.stringify({ error:
|
|
46
|
+
console.error("Studio handler error:", error);
|
|
47
|
+
return new Response(JSON.stringify({ error: "Internal server error" }), {
|
|
48
48
|
status: 500,
|
|
49
|
-
headers: {
|
|
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 !==
|
|
58
|
-
const contentType = event.request.headers.get(
|
|
59
|
-
if (contentType.includes(
|
|
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(
|
|
66
|
-
contentType.includes(
|
|
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 ||
|
|
93
|
-
const normalizedBasePath = basePath.endsWith(
|
|
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,5 +1,5 @@
|
|
|
1
|
-
import { handleStudioRequest } from
|
|
2
|
-
import { injectEventHooks } from
|
|
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(
|
|
40
|
-
return new Response(JSON.stringify({ error:
|
|
39
|
+
console.error("Studio handler error:", error);
|
|
40
|
+
return new Response(JSON.stringify({ error: "Internal server error" }), {
|
|
41
41
|
status: 500,
|
|
42
|
-
headers: {
|
|
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 !==
|
|
51
|
-
const contentType = request.headers.get(
|
|
52
|
-
if (contentType.includes(
|
|
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(
|
|
59
|
-
contentType.includes(
|
|
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 ||
|
|
86
|
-
const normalizedBasePath = basePath.endsWith(
|
|
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[
|
|
4
|
-
alias[
|
|
5
|
-
alias[
|
|
6
|
-
alias[
|
|
7
|
-
alias[
|
|
8
|
-
alias[
|
|
9
|
-
alias[
|
|
10
|
-
alias[
|
|
11
|
-
alias[
|
|
12
|
-
alias[
|
|
13
|
-
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";
|
|
14
14
|
}
|
|
15
15
|
//# sourceMappingURL=add-svelte-kit-env-modules.js.map
|
package/dist/auth-adapter.d.ts
CHANGED