better-auth-studio 1.1.2-beta.6 → 1.1.2-beta.8
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/dist/cli.js +0 -0
- package/dist/core/handler.js +1 -0
- package/dist/core/handler.js.map +1 -1
- package/dist/public/assets/{main-D2k7jV-x.js → main-CeN9M3ie.js} +27 -27
- package/dist/public/index.html +1 -1
- package/dist/routes/api-router.d.ts +2 -0
- package/dist/routes/api-router.d.ts.map +1 -1
- package/dist/routes/api-router.js.map +1 -1
- package/dist/routes.d.ts +3 -1
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +32 -17
- package/dist/routes.js.map +1 -1
- package/package.json +28 -36
- package/public/assets/{main-D2k7jV-x.js → main-CeN9M3ie.js} +27 -27
- package/public/index.html +1 -1
package/dist/public/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="icon" type="image/png" href="/logo.png" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>Better Auth Studio</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/main-
|
|
8
|
+
<script type="module" crossorigin src="/assets/main-CeN9M3ie.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/main-GcANPjqc.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { StudioConfig } from '../types/handler.js';
|
|
1
2
|
import type { StudioAccessConfig } from '../utils/html-injector.js';
|
|
2
3
|
export type ApiContext = {
|
|
3
4
|
path: string;
|
|
@@ -7,6 +8,7 @@ export type ApiContext = {
|
|
|
7
8
|
auth: any;
|
|
8
9
|
basePath?: string;
|
|
9
10
|
accessConfig?: StudioAccessConfig;
|
|
11
|
+
studioConfig?: StudioConfig;
|
|
10
12
|
};
|
|
11
13
|
export type ApiResponse = {
|
|
12
14
|
status: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-router.d.ts","sourceRoot":"","sources":["../../src/routes/api-router.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,IAAI,EAAE,GAAG,CAAC;IACV,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"api-router.d.ts","sourceRoot":"","sources":["../../src/routes/api-router.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,IAAI,EAAE,GAAG,CAAC;IACV,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,GAAG,CAAC;IACV,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,GAAG,CAAA;KAAE,CAAC,CAAC;CAChE,CAAC;AAEF,wBAAsB,eAAe,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,CAY3E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-router.js","sourceRoot":"","sources":["../../src/routes/api-router.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api-router.js","sourceRoot":"","sources":["../../src/routes/api-router.ts"],"names":[],"mappings":"AAoBA,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,GAAe;IACnD,MAAM,EAAE,sBAAsB,EAAE,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,CAAC;IAEhE,IAAI,CAAC;QACH,OAAO,MAAM,sBAAsB,CAAC,GAAG,CAAC,CAAC;IAC3C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;QAC3C,OAAO;YACL,MAAM,EAAE,GAAG;YACX,IAAI,EAAE,EAAE,KAAK,EAAE,uBAAuB,EAAE;SACzC,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/dist/routes.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Router } from 'express';
|
|
2
2
|
import type { AuthConfig } from './config.js';
|
|
3
|
+
import type { StudioConfig } from './types/handler.js';
|
|
3
4
|
import type { StudioAccessConfig } from './utils/html-injector.js';
|
|
4
5
|
export declare function safeImportAuthConfig(authConfigPath: string, noCache?: boolean): Promise<any>;
|
|
5
|
-
export declare function createRoutes(authConfig: AuthConfig, configPath?: string, geoDbPath?: string, preloadedAdapter?: any, preloadedAuthOptions?: any, accessConfig?: StudioAccessConfig, authInstance?: any): Router;
|
|
6
|
+
export declare function createRoutes(authConfig: AuthConfig, configPath?: string, geoDbPath?: string, preloadedAdapter?: any, preloadedAuthOptions?: any, accessConfig?: StudioAccessConfig, authInstance?: any, studioConfig?: StudioConfig): Router;
|
|
6
7
|
export declare function handleStudioApiRequest(ctx: {
|
|
7
8
|
path: string;
|
|
8
9
|
method: string;
|
|
@@ -12,6 +13,7 @@ export declare function handleStudioApiRequest(ctx: {
|
|
|
12
13
|
basePath?: string;
|
|
13
14
|
configPath?: string;
|
|
14
15
|
accessConfig?: StudioAccessConfig;
|
|
16
|
+
studioConfig?: StudioConfig;
|
|
15
17
|
}): Promise<{
|
|
16
18
|
status: number;
|
|
17
19
|
data: any;
|
package/dist/routes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAqBA,OAAO,EAA+B,MAAM,EAAE,MAAM,SAAS,CAAC;AAW9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAK9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AA0GnE,wBAAsB,oBAAoB,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,UAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAqLhG;AAeD,wBAAgB,YAAY,CAC1B,UAAU,EAAE,UAAU,EACtB,UAAU,CAAC,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,EAClB,gBAAgB,CAAC,EAAE,GAAG,EACtB,oBAAoB,CAAC,EAAE,GAAG,EAC1B,YAAY,CAAC,EAAE,kBAAkB,EACjC,YAAY,CAAC,EAAE,GAAG,EAClB,YAAY,CAAC,EAAE,YAAY,GAC1B,MAAM,CAs0NR;AAED,wBAAsB,sBAAsB,CAAC,GAAG,EAAE;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,IAAI,EAAE,GAAG,CAAC;IACV,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,GAAG,OAAO,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,GAAG,CAAC;IACV,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,GAAG,CAAA;KAAE,CAAC,CAAC;CAChE,CAAC,CAgGD"}
|
package/dist/routes.js
CHANGED
|
@@ -2,14 +2,19 @@ import { createHmac, randomBytes } from 'node:crypto';
|
|
|
2
2
|
import { existsSync, readFileSync, writeFileSync, } from 'node:fs';
|
|
3
3
|
import { dirname, join } from 'node:path';
|
|
4
4
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
5
|
+
// @ts-expect-error - No types available
|
|
6
|
+
import babelPresetReact from '@babel/preset-react';
|
|
7
|
+
// @ts-expect-error - No types available
|
|
8
|
+
import babelPresetTypeScript from '@babel/preset-typescript';
|
|
5
9
|
// @ts-expect-error
|
|
6
10
|
import { hex } from '@better-auth/utils/hex';
|
|
7
11
|
import { scryptAsync } from '@noble/hashes/scrypt.js';
|
|
12
|
+
import { loadConfig } from 'c12';
|
|
8
13
|
import { Router } from 'express';
|
|
9
14
|
import { createJiti } from 'jiti';
|
|
10
15
|
import { createRequire } from 'module';
|
|
11
16
|
import { createMockAccount, createMockSession, createMockUser, createMockVerification, getAuthAdapter, } from './auth-adapter.js';
|
|
12
|
-
import { possiblePaths } from './config.js';
|
|
17
|
+
import { getPathAliases, possiblePaths } from './config.js';
|
|
13
18
|
import { getAuthData } from './data.js';
|
|
14
19
|
import { initializeGeoService, resolveIPLocation, setGeoDbPath } from './geo-service.js';
|
|
15
20
|
import { detectDatabaseWithDialect } from './utils/database-detection.js';
|
|
@@ -264,7 +269,7 @@ async function findAuthConfigPath() {
|
|
|
264
269
|
}
|
|
265
270
|
return null;
|
|
266
271
|
}
|
|
267
|
-
export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter, preloadedAuthOptions, accessConfig, authInstance) {
|
|
272
|
+
export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter, preloadedAuthOptions, accessConfig, authInstance, studioConfig) {
|
|
268
273
|
const isSelfHosted = !!preloadedAdapter;
|
|
269
274
|
const getAuthConfigSafe = async () => {
|
|
270
275
|
if (isSelfHosted) {
|
|
@@ -933,8 +938,8 @@ export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter
|
|
|
933
938
|
const { isEventIngestionInitialized, getEventIngestionProvider } = await import('./utils/event-ingestion.js');
|
|
934
939
|
const initialized = isEventIngestionInitialized();
|
|
935
940
|
const provider = getEventIngestionProvider();
|
|
936
|
-
|
|
937
|
-
if (!initialized) {
|
|
941
|
+
let configToUse = studioConfig || null;
|
|
942
|
+
if (!initialized && !configToUse) {
|
|
938
943
|
try {
|
|
939
944
|
const { initializeEventIngestionAndHooks } = await import('./core/handler.js');
|
|
940
945
|
const { existsSync } = await import('node:fs');
|
|
@@ -964,19 +969,19 @@ export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter
|
|
|
964
969
|
}
|
|
965
970
|
}
|
|
966
971
|
if (studioConfigPath) {
|
|
967
|
-
const { loadConfig } = await import('c12');
|
|
968
|
-
const { getPathAliases } = await import('./config.js');
|
|
969
|
-
// @ts-expect-error - No types available
|
|
970
|
-
const babelPresetTypeScript = (await import('@babel/preset-typescript')).default;
|
|
971
|
-
// @ts-expect-error - No types available
|
|
972
|
-
const babelPresetReact = (await import('@babel/preset-react')).default;
|
|
973
972
|
const alias = getPathAliases(process.cwd()) || {};
|
|
974
973
|
const jitiOptions = {
|
|
975
974
|
debug: false,
|
|
976
975
|
transformOptions: {
|
|
977
976
|
babel: {
|
|
978
977
|
presets: [
|
|
979
|
-
[
|
|
978
|
+
[
|
|
979
|
+
babelPresetTypeScript,
|
|
980
|
+
{
|
|
981
|
+
isTSX: true,
|
|
982
|
+
allExtensions: true,
|
|
983
|
+
},
|
|
984
|
+
],
|
|
980
985
|
[babelPresetReact, { runtime: 'automatic' }],
|
|
981
986
|
],
|
|
982
987
|
},
|
|
@@ -986,22 +991,32 @@ export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter
|
|
|
986
991
|
interopDefault: true,
|
|
987
992
|
};
|
|
988
993
|
const { config } = await loadConfig({
|
|
989
|
-
configFile: studioConfigPath,
|
|
994
|
+
configFile: studioConfigPath || undefined,
|
|
990
995
|
cwd: process.cwd(),
|
|
991
996
|
dotenv: true,
|
|
992
997
|
jitiOptions,
|
|
993
998
|
});
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
await initializeEventIngestionAndHooks(studioConfig);
|
|
999
|
+
if (config) {
|
|
1000
|
+
configToUse = config?.default || config?.config || config;
|
|
997
1001
|
}
|
|
998
1002
|
}
|
|
999
1003
|
}
|
|
1004
|
+
catch (initError) {
|
|
1005
|
+
console.warn('Failed to load studio config:', initError?.message || initError);
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
if (!initialized && configToUse?.events?.enabled) {
|
|
1009
|
+
try {
|
|
1010
|
+
const { initializeEventIngestionAndHooks } = await import('./core/handler.js');
|
|
1011
|
+
await initializeEventIngestionAndHooks(configToUse);
|
|
1012
|
+
}
|
|
1000
1013
|
catch (initError) {
|
|
1001
1014
|
console.warn('Failed to initialize event ingestion:', initError?.message || initError);
|
|
1002
1015
|
}
|
|
1003
1016
|
}
|
|
1004
|
-
const isEnabled =
|
|
1017
|
+
const isEnabled = configToUse?.events?.enabled === true &&
|
|
1018
|
+
isEventIngestionInitialized() &&
|
|
1019
|
+
!!getEventIngestionProvider();
|
|
1005
1020
|
res.json({
|
|
1006
1021
|
enabled: isEnabled,
|
|
1007
1022
|
initialized: isEventIngestionInitialized(),
|
|
@@ -6387,7 +6402,7 @@ export async function handleStudioApiRequest(ctx) {
|
|
|
6387
6402
|
catch { }
|
|
6388
6403
|
}
|
|
6389
6404
|
const authOptions = ctx.auth?.options || null;
|
|
6390
|
-
const router = createRoutes(ctx.auth, ctx.configPath || '', undefined, preloadedAdapter, authOptions, ctx.accessConfig, ctx.auth);
|
|
6405
|
+
const router = createRoutes(ctx.auth, ctx.configPath || '', undefined, preloadedAdapter, authOptions, ctx.accessConfig, ctx.auth, ctx.studioConfig);
|
|
6391
6406
|
const [pathname, queryString] = ctx.path.split('?');
|
|
6392
6407
|
const query = {};
|
|
6393
6408
|
if (queryString) {
|