better-auth-studio 1.1.2-beta.6 → 1.1.2-beta.7
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/routes.d.ts.map +1 -1
- package/dist/routes.js +36 -32
- package/dist/routes.js.map +1 -1
- package/package.json +28 -36
package/dist/cli.js
CHANGED
|
File without changes
|
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;AAU9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAM9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AA4GnE,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,GACjB,MAAM,CAyzNR;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;CACnC,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,CA+FD"}
|
package/dist/routes.js
CHANGED
|
@@ -2,6 +2,10 @@ 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';
|
|
@@ -9,11 +13,12 @@ import { Router } from 'express';
|
|
|
9
13
|
import { createJiti } from 'jiti';
|
|
10
14
|
import { createRequire } from 'module';
|
|
11
15
|
import { createMockAccount, createMockSession, createMockUser, createMockVerification, getAuthAdapter, } from './auth-adapter.js';
|
|
12
|
-
import { possiblePaths } from './config.js';
|
|
16
|
+
import { getPathAliases, possiblePaths } from './config.js';
|
|
13
17
|
import { getAuthData } from './data.js';
|
|
14
18
|
import { initializeGeoService, resolveIPLocation, setGeoDbPath } from './geo-service.js';
|
|
15
19
|
import { detectDatabaseWithDialect } from './utils/database-detection.js';
|
|
16
20
|
import { createStudioSession, decryptSession, encryptSession, isSessionValid, STUDIO_COOKIE_NAME, } from './utils/session.js';
|
|
21
|
+
import { loadConfig } from 'c12';
|
|
17
22
|
const config = {
|
|
18
23
|
N: 16384,
|
|
19
24
|
r: 16,
|
|
@@ -933,7 +938,6 @@ 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
|
-
// If not initialized, try to initialize it
|
|
937
941
|
if (!initialized) {
|
|
938
942
|
try {
|
|
939
943
|
const { initializeEventIngestionAndHooks } = await import('./core/handler.js');
|
|
@@ -953,7 +957,34 @@ export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter
|
|
|
953
957
|
break;
|
|
954
958
|
}
|
|
955
959
|
}
|
|
956
|
-
|
|
960
|
+
const alias = getPathAliases(process.cwd()) || {};
|
|
961
|
+
const jitiOptions = {
|
|
962
|
+
debug: false,
|
|
963
|
+
transformOptions: {
|
|
964
|
+
babel: {
|
|
965
|
+
presets: [
|
|
966
|
+
[
|
|
967
|
+
babelPresetTypeScript,
|
|
968
|
+
{
|
|
969
|
+
isTSX: true,
|
|
970
|
+
allExtensions: true,
|
|
971
|
+
},
|
|
972
|
+
],
|
|
973
|
+
[babelPresetReact, { runtime: 'automatic' }],
|
|
974
|
+
],
|
|
975
|
+
},
|
|
976
|
+
},
|
|
977
|
+
extensions: ['.ts', '.js', '.tsx', '.jsx'],
|
|
978
|
+
alias,
|
|
979
|
+
interopDefault: true,
|
|
980
|
+
};
|
|
981
|
+
const { config } = await loadConfig({
|
|
982
|
+
configFile: studioConfigPath || undefined,
|
|
983
|
+
cwd: process.cwd(),
|
|
984
|
+
dotenv: true,
|
|
985
|
+
jitiOptions,
|
|
986
|
+
});
|
|
987
|
+
if (!config) {
|
|
957
988
|
const configDir = require('node:path').dirname(configPath);
|
|
958
989
|
for (const file of possibleFiles) {
|
|
959
990
|
const path = require('node:path').join(configDir, file);
|
|
@@ -963,36 +994,9 @@ export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter
|
|
|
963
994
|
}
|
|
964
995
|
}
|
|
965
996
|
}
|
|
966
|
-
if (
|
|
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
|
-
const alias = getPathAliases(process.cwd()) || {};
|
|
974
|
-
const jitiOptions = {
|
|
975
|
-
debug: false,
|
|
976
|
-
transformOptions: {
|
|
977
|
-
babel: {
|
|
978
|
-
presets: [
|
|
979
|
-
[babelPresetTypeScript, { isTSX: true, allExtensions: true }],
|
|
980
|
-
[babelPresetReact, { runtime: 'automatic' }],
|
|
981
|
-
],
|
|
982
|
-
},
|
|
983
|
-
},
|
|
984
|
-
extensions: ['.ts', '.js', '.tsx', '.jsx'],
|
|
985
|
-
alias,
|
|
986
|
-
interopDefault: true,
|
|
987
|
-
};
|
|
988
|
-
const { config } = await loadConfig({
|
|
989
|
-
configFile: studioConfigPath,
|
|
990
|
-
cwd: process.cwd(),
|
|
991
|
-
dotenv: true,
|
|
992
|
-
jitiOptions,
|
|
993
|
-
});
|
|
997
|
+
if (config) {
|
|
994
998
|
const studioConfig = config?.default || config?.config || config;
|
|
995
|
-
if (studioConfig
|
|
999
|
+
if (studioConfig.events?.enabled) {
|
|
996
1000
|
await initializeEventIngestionAndHooks(studioConfig);
|
|
997
1001
|
}
|
|
998
1002
|
}
|