better-auth-studio 1.0.79-beta.27 → 1.0.79-beta.29
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/data.js +0 -5
- package/dist/data.js.map +1 -1
- package/dist/public/assets/{main-B68uy0QR.js → main-QUIVxdLh.js} +119 -119
- package/dist/public/index.html +1 -1
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +49 -15
- package/dist/routes.js.map +1 -1
- package/package.json +1 -1
- package/public/assets/{main-B68uy0QR.js → main-QUIVxdLh.js} +119 -119
- 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-QUIVxdLh.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/main-C0mBl_hH.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
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":"AAgBA,OAAO,EAA+B,MAAM,EAAE,MAAM,SAAS,CAAC;AAS9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAK9C,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,CAm7LR;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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createHmac, randomBytes } from 'node:crypto';
|
|
2
2
|
import { existsSync, readFileSync, writeFileSync, } from 'node:fs';
|
|
3
3
|
import { dirname, join } from 'node:path';
|
|
4
|
+
import { createRequire } from 'module';
|
|
4
5
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
5
6
|
// @ts-expect-error
|
|
6
7
|
import { hex } from '@better-auth/utils/hex';
|
|
@@ -57,8 +58,24 @@ function getStudioVersion() {
|
|
|
57
58
|
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
|
|
58
59
|
return packageJson.version || '1.0.0';
|
|
59
60
|
}
|
|
61
|
+
const nodeModulesPath = join(process.cwd(), 'node_modules/better-auth-studio/package.json');
|
|
62
|
+
if (existsSync(nodeModulesPath)) {
|
|
63
|
+
const packageJson = JSON.parse(readFileSync(nodeModulesPath, 'utf-8'));
|
|
64
|
+
return packageJson.version || '1.0.0';
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
const require = createRequire(import.meta.url);
|
|
68
|
+
const resolvedPath = require.resolve('better-auth-studio/package.json');
|
|
69
|
+
if (existsSync(resolvedPath)) {
|
|
70
|
+
const packageJson = JSON.parse(readFileSync(resolvedPath, 'utf-8'));
|
|
71
|
+
return packageJson.version || '1.0.0';
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (_resolveError) {
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch (_error) {
|
|
60
78
|
}
|
|
61
|
-
catch (_error) { }
|
|
62
79
|
return '1.0.0';
|
|
63
80
|
}
|
|
64
81
|
function _resolveModuleWithExtensions(id, parent) {
|
|
@@ -809,6 +826,23 @@ export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter
|
|
|
809
826
|
}
|
|
810
827
|
}
|
|
811
828
|
catch (_error) { }
|
|
829
|
+
// Get studio version - try local first, then npm as fallback
|
|
830
|
+
let studioVersion = getStudioVersion();
|
|
831
|
+
if (studioVersion === '1.0.0') {
|
|
832
|
+
// Fallback: try to fetch from npm registry
|
|
833
|
+
try {
|
|
834
|
+
const response = await fetch('https://registry.npmjs.org/better-auth-studio/latest', {
|
|
835
|
+
signal: AbortSignal.timeout(2000), // 2 second timeout
|
|
836
|
+
});
|
|
837
|
+
if (response.ok) {
|
|
838
|
+
const data = (await response.json());
|
|
839
|
+
studioVersion = data.version || '1.0.0';
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
catch (_npmError) {
|
|
843
|
+
// Ignore npm fetch errors, use default
|
|
844
|
+
}
|
|
845
|
+
}
|
|
812
846
|
if (databaseType === 'unknown' && !isSelfHosted) {
|
|
813
847
|
const authConfigPath = configPath || (await findAuthConfigPath());
|
|
814
848
|
if (authConfigPath) {
|
|
@@ -885,7 +919,7 @@ export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter
|
|
|
885
919
|
disabledPaths: effectiveConfig.disabledPaths || [],
|
|
886
920
|
telemetry: effectiveConfig.telemetry,
|
|
887
921
|
studio: {
|
|
888
|
-
version:
|
|
922
|
+
version: studioVersion,
|
|
889
923
|
nodeVersion: process.version,
|
|
890
924
|
platform: process.platform,
|
|
891
925
|
uptime: process.uptime(),
|
|
@@ -2396,7 +2430,8 @@ export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter
|
|
|
2396
2430
|
else if (organizationPlugin.config?.teams?.enabled === true) {
|
|
2397
2431
|
teamsEnabled = true;
|
|
2398
2432
|
}
|
|
2399
|
-
else if (organizationPlugin.options?.teams &&
|
|
2433
|
+
else if (organizationPlugin.options?.teams &&
|
|
2434
|
+
typeof organizationPlugin.options.teams === 'object') {
|
|
2400
2435
|
teamsEnabled = organizationPlugin.options.teams.enabled === true;
|
|
2401
2436
|
}
|
|
2402
2437
|
else if (organizationPlugin.teams && typeof organizationPlugin.teams === 'object') {
|
|
@@ -2779,14 +2814,14 @@ export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter
|
|
|
2779
2814
|
return res.status(500).json({
|
|
2780
2815
|
success: false,
|
|
2781
2816
|
error: 'Auth adapter not available',
|
|
2782
|
-
teams: []
|
|
2817
|
+
teams: [],
|
|
2783
2818
|
});
|
|
2784
2819
|
}
|
|
2785
2820
|
if (typeof adapter.findMany !== 'function') {
|
|
2786
2821
|
return res.status(500).json({
|
|
2787
2822
|
success: false,
|
|
2788
2823
|
error: 'Adapter findMany method not available',
|
|
2789
|
-
teams: []
|
|
2824
|
+
teams: [],
|
|
2790
2825
|
});
|
|
2791
2826
|
}
|
|
2792
2827
|
try {
|
|
@@ -2845,21 +2880,18 @@ export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter
|
|
|
2845
2880
|
return res.json({ success: true, teams: validTeams });
|
|
2846
2881
|
}
|
|
2847
2882
|
catch (error) {
|
|
2848
|
-
// Log the error for debugging but return empty array
|
|
2849
|
-
console.error('[Studio] Error fetching teams:', error?.message || error);
|
|
2850
2883
|
return res.json({
|
|
2851
2884
|
success: true,
|
|
2852
2885
|
teams: [],
|
|
2853
|
-
error: error?.message || 'Failed to fetch teams'
|
|
2886
|
+
error: error?.message || 'Failed to fetch teams',
|
|
2854
2887
|
});
|
|
2855
2888
|
}
|
|
2856
2889
|
}
|
|
2857
2890
|
catch (error) {
|
|
2858
|
-
console.error('[Studio] Error in /api/organizations/:orgId/teams:', error?.message || error);
|
|
2859
2891
|
res.status(500).json({
|
|
2860
2892
|
success: false,
|
|
2861
2893
|
error: 'Failed to fetch teams',
|
|
2862
|
-
message: error?.message || 'Unknown error'
|
|
2894
|
+
message: error?.message || 'Unknown error',
|
|
2863
2895
|
});
|
|
2864
2896
|
}
|
|
2865
2897
|
});
|
|
@@ -2885,7 +2917,7 @@ export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter
|
|
|
2885
2917
|
if (!adapter.create) {
|
|
2886
2918
|
return res.status(500).json({ error: 'Adapter create method not available' });
|
|
2887
2919
|
}
|
|
2888
|
-
await adapter.create({
|
|
2920
|
+
const teamResult = await adapter.create({
|
|
2889
2921
|
model: 'team',
|
|
2890
2922
|
data: {
|
|
2891
2923
|
name: teamData.name,
|
|
@@ -2894,6 +2926,9 @@ export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter
|
|
|
2894
2926
|
updatedAt: teamData.updatedAt,
|
|
2895
2927
|
},
|
|
2896
2928
|
});
|
|
2929
|
+
if (!teamResult) {
|
|
2930
|
+
return res.status(500).json({ error: 'Failed to create team' });
|
|
2931
|
+
}
|
|
2897
2932
|
res.json({ success: true, team });
|
|
2898
2933
|
}
|
|
2899
2934
|
catch (_error) {
|
|
@@ -2986,7 +3021,7 @@ export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter
|
|
|
2986
3021
|
existingMember = existing && existing.length > 0 ? existing[0] : null;
|
|
2987
3022
|
}
|
|
2988
3023
|
catch (_findError) {
|
|
2989
|
-
// if where clause isn't working.
|
|
3024
|
+
// if where clause isn't working.
|
|
2990
3025
|
try {
|
|
2991
3026
|
const allMembers = await adapter.findMany({
|
|
2992
3027
|
model: 'teamMember',
|
|
@@ -2994,8 +3029,7 @@ export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter
|
|
|
2994
3029
|
});
|
|
2995
3030
|
existingMember = (allMembers || []).find((m) => m.teamId === teamId && m.userId === userId);
|
|
2996
3031
|
}
|
|
2997
|
-
catch (_fallbackError) {
|
|
2998
|
-
}
|
|
3032
|
+
catch (_fallbackError) { }
|
|
2999
3033
|
}
|
|
3000
3034
|
}
|
|
3001
3035
|
if (existingMember) {
|
|
@@ -3039,7 +3073,7 @@ export function createRoutes(authConfig, configPath, geoDbPath, preloadedAdapter
|
|
|
3039
3073
|
res.status(500).json({
|
|
3040
3074
|
success: false,
|
|
3041
3075
|
error: 'Failed to add team members',
|
|
3042
|
-
message: error?.message || 'Unknown error'
|
|
3076
|
+
message: error?.message || 'Unknown error',
|
|
3043
3077
|
});
|
|
3044
3078
|
}
|
|
3045
3079
|
});
|