better-auth-studio 1.0.24-beta.1 → 1.0.25
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/routes.d.ts.map +1 -1
- package/dist/routes.js +54 -93
- package/dist/routes.js.map +1 -1
- package/package.json +1 -1
- package/public/assets/main-6TIapMhx.css +1 -0
- package/public/assets/{main-D7saZxpB.js → main-pxCVb0ea.js} +42 -42
- package/public/index.html +2 -2
- package/public/assets/main-Ba9FD9p1.css +0 -1
package/dist/routes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,MAAM,EAAE,MAAM,SAAS,CAAC;AAY9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA+C9C,wBAAsB,oBAAoB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,MAAM,EAAE,MAAM,SAAS,CAAC;AAY9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA+C9C,wBAAsB,oBAAoB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CA+I/E;AAwBD,wBAAgB,YAAY,CAC1B,UAAU,EAAE,UAAU,EACtB,UAAU,CAAC,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAk0FR"}
|
package/dist/routes.js
CHANGED
|
@@ -79,7 +79,7 @@ export async function safeImportAuthConfig(authConfigPath) {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
const jiti = createJiti(import.meta.url, {
|
|
82
|
-
debug: true,
|
|
82
|
+
debug: true,
|
|
83
83
|
fsCache: true,
|
|
84
84
|
moduleCache: true,
|
|
85
85
|
interopDefault: true,
|
|
@@ -119,17 +119,7 @@ export async function safeImportAuthConfig(authConfigPath) {
|
|
|
119
119
|
}
|
|
120
120
|
currentDir = dirname(currentDir);
|
|
121
121
|
}
|
|
122
|
-
resolvedContent =
|
|
123
|
-
user: { findMany: () => [], create: () => ({}), update: () => ({}), delete: () => ({}) },
|
|
124
|
-
session: { findMany: () => [], create: () => ({}), update: () => ({}), delete: () => ({}) },
|
|
125
|
-
account: { findMany: () => [], create: () => ({}), update: () => ({}), delete: () => ({}) },
|
|
126
|
-
verification: { findMany: () => [], create: () => ({}), update: () => ({}), delete: () => ({}) },
|
|
127
|
-
organization: { findMany: () => [], create: () => ({}), update: () => ({}), delete: () => ({}) },
|
|
128
|
-
member: { findMany: () => [], create: () => ({}), update: () => ({}), delete: () => ({}) },
|
|
129
|
-
invitation: { findMany: () => [], create: () => ({}), update: () => ({}), delete: () => ({}) },
|
|
130
|
-
team: { findMany: () => [], create: () => ({}), update: () => ({}), delete: () => ({}) },
|
|
131
|
-
teamMember: { findMany: () => [], create: () => ({}), update: () => ({}), delete: () => ({}) }
|
|
132
|
-
};`);
|
|
122
|
+
resolvedContent = '';
|
|
133
123
|
resolvedContent = resolvedContent.replace(/import\s+([^"']*)\s+from\s+["']\.\/[^"']*["'];/g, '// Ignored local import');
|
|
134
124
|
resolvedContent = resolvedContent.replace(/import\s+{\s*magicLink\s*}\s+from\s+["']\.\/magic-link["'];/g, `const magicLink = () => ({ id: 'magic-link', name: 'Magic Link' });`);
|
|
135
125
|
if (nodeModulesPath) {
|
|
@@ -138,8 +128,8 @@ export async function safeImportAuthConfig(authConfigPath) {
|
|
|
138
128
|
let commonJsContent = resolvedContent
|
|
139
129
|
.replace(/export\s+const\s+(\w+)\s*=/g, 'const $1 =')
|
|
140
130
|
.replace(/export\s+default\s+/g, 'module.exports = ')
|
|
141
|
-
.replace(/export\s+type\s+.*$/gm, '// $&')
|
|
142
|
-
.replace(/import\s+type\s+.*$/gm, '// $&');
|
|
131
|
+
.replace(/export\s+type\s+.*$/gm, '// $&')
|
|
132
|
+
.replace(/import\s+type\s+.*$/gm, '// $&');
|
|
143
133
|
if (!commonJsContent.includes('module.exports')) {
|
|
144
134
|
commonJsContent += '\nmodule.exports = { auth };';
|
|
145
135
|
}
|
|
@@ -170,7 +160,7 @@ export async function safeImportAuthConfig(authConfigPath) {
|
|
|
170
160
|
}
|
|
171
161
|
catch (resolveError) {
|
|
172
162
|
console.error('Import resolution also failed:', resolveError);
|
|
173
|
-
throw importError;
|
|
163
|
+
throw importError;
|
|
174
164
|
}
|
|
175
165
|
}
|
|
176
166
|
}
|
|
@@ -178,7 +168,7 @@ async function findAuthConfigPath() {
|
|
|
178
168
|
const { join, dirname } = await import('path');
|
|
179
169
|
const { existsSync } = await import('fs');
|
|
180
170
|
const possiblePaths = [
|
|
181
|
-
'auth.js',
|
|
171
|
+
'auth.js',
|
|
182
172
|
'auth.ts',
|
|
183
173
|
'src/auth.js',
|
|
184
174
|
'src/auth.ts',
|
|
@@ -1558,22 +1548,18 @@ export function createRoutes(authConfig, configPath, geoDbPath) {
|
|
|
1558
1548
|
},
|
|
1559
1549
|
},
|
|
1560
1550
|
};
|
|
1561
|
-
// Function to generate schema based on selected plugins
|
|
1562
1551
|
function generateSchema(selectedPlugins) {
|
|
1563
1552
|
const schema = { tables: [] };
|
|
1564
|
-
// Start with base tables (deep clone to avoid mutations)
|
|
1565
1553
|
const baseTables = Object.values(BASE_SCHEMA).map((table) => ({
|
|
1566
1554
|
...table,
|
|
1567
1555
|
fields: [...table.fields],
|
|
1568
1556
|
relationships: [...table.relationships],
|
|
1569
1557
|
}));
|
|
1570
1558
|
schema.tables.push(...baseTables);
|
|
1571
|
-
// Apply plugin extensions
|
|
1572
1559
|
selectedPlugins.forEach((pluginName) => {
|
|
1573
1560
|
const plugin = PLUGIN_SCHEMAS[pluginName];
|
|
1574
1561
|
if (!plugin)
|
|
1575
1562
|
return;
|
|
1576
|
-
// Add plugin-specific tables
|
|
1577
1563
|
if (plugin.tables) {
|
|
1578
1564
|
Object.values(plugin.tables).forEach((table) => {
|
|
1579
1565
|
schema.tables.push({
|
|
@@ -1583,17 +1569,14 @@ export function createRoutes(authConfig, configPath, geoDbPath) {
|
|
|
1583
1569
|
});
|
|
1584
1570
|
});
|
|
1585
1571
|
}
|
|
1586
|
-
// Extend existing tables (with duplicate prevention)
|
|
1587
1572
|
if ('userExtensions' in plugin && plugin.userExtensions) {
|
|
1588
1573
|
const userTable = schema.tables.find((t) => t.name === 'user');
|
|
1589
1574
|
if (userTable && 'fields' in plugin.userExtensions) {
|
|
1590
|
-
// Add fields only if they don't already exist
|
|
1591
1575
|
(plugin.userExtensions.fields || []).forEach((field) => {
|
|
1592
1576
|
if (!userTable.fields.some((f) => f.name === field.name)) {
|
|
1593
1577
|
userTable.fields.push(field);
|
|
1594
1578
|
}
|
|
1595
1579
|
});
|
|
1596
|
-
// Add relationships only if they don't already exist
|
|
1597
1580
|
(plugin.userExtensions.relationships || []).forEach((rel) => {
|
|
1598
1581
|
if (!userTable.relationships.some((r) => r.target === rel.target && r.field === rel.field && r.type === rel.type)) {
|
|
1599
1582
|
userTable.relationships.push(rel);
|
|
@@ -1604,13 +1587,11 @@ export function createRoutes(authConfig, configPath, geoDbPath) {
|
|
|
1604
1587
|
if ('sessionExtensions' in plugin && plugin.sessionExtensions) {
|
|
1605
1588
|
const sessionTable = schema.tables.find((t) => t.name === 'session');
|
|
1606
1589
|
if (sessionTable && 'fields' in plugin.sessionExtensions) {
|
|
1607
|
-
// Add fields only if they don't already exist
|
|
1608
1590
|
(plugin.sessionExtensions.fields || []).forEach((field) => {
|
|
1609
1591
|
if (!sessionTable.fields.some((f) => f.name === field.name)) {
|
|
1610
1592
|
sessionTable.fields.push(field);
|
|
1611
1593
|
}
|
|
1612
1594
|
});
|
|
1613
|
-
// Add relationships only if they don't already exist
|
|
1614
1595
|
(plugin.sessionExtensions.relationships || []).forEach((rel) => {
|
|
1615
1596
|
if (!sessionTable.relationships.some((r) => r.target === rel.target && r.field === rel.field && r.type === rel.type)) {
|
|
1616
1597
|
sessionTable.relationships.push(rel);
|
|
@@ -1621,7 +1602,6 @@ export function createRoutes(authConfig, configPath, geoDbPath) {
|
|
|
1621
1602
|
if ('organizationExtensions' in plugin && plugin.organizationExtensions) {
|
|
1622
1603
|
const orgTable = schema.tables.find((t) => t.name === 'organization');
|
|
1623
1604
|
if (orgTable) {
|
|
1624
|
-
// Add relationships only if they don't already exist
|
|
1625
1605
|
(plugin.organizationExtensions.relationships || []).forEach((rel) => {
|
|
1626
1606
|
if (!orgTable.relationships.some((r) => r.target === rel.target && r.field === rel.field && r.type === rel.type)) {
|
|
1627
1607
|
orgTable.relationships.push(rel);
|
|
@@ -1673,45 +1653,36 @@ export function createRoutes(authConfig, configPath, geoDbPath) {
|
|
|
1673
1653
|
});
|
|
1674
1654
|
}
|
|
1675
1655
|
try {
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
}
|
|
1680
|
-
catch (importError) {
|
|
1681
|
-
// Fallback: read file content directly
|
|
1682
|
-
const content = readFileSync(authConfigPath, 'utf-8');
|
|
1683
|
-
authModule = {
|
|
1684
|
-
auth: {
|
|
1685
|
-
options: {
|
|
1686
|
-
_content: content,
|
|
1687
|
-
plugins: [],
|
|
1688
|
-
},
|
|
1689
|
-
},
|
|
1690
|
-
};
|
|
1691
|
-
}
|
|
1692
|
-
const auth = authModule.auth || authModule.default;
|
|
1693
|
-
if (!auth) {
|
|
1694
|
-
return res.json({
|
|
1695
|
-
enabled: false,
|
|
1696
|
-
error: 'No auth export found',
|
|
1697
|
-
configPath: authConfigPath,
|
|
1698
|
-
});
|
|
1699
|
-
}
|
|
1700
|
-
const organizationPlugin = auth.options?.plugins?.find((plugin) => plugin.id === 'organization');
|
|
1701
|
-
const teamOptions = organizationPlugin.options.teams;
|
|
1702
|
-
const teamsEnabled = teamOptions?.enabled;
|
|
1703
|
-
res.json({
|
|
1704
|
-
enabled: teamsEnabled,
|
|
1656
|
+
const { getConfig } = await import('./config.js');
|
|
1657
|
+
const betterAuthConfig = await getConfig({
|
|
1658
|
+
cwd: process.cwd(),
|
|
1705
1659
|
configPath: authConfigPath,
|
|
1706
|
-
|
|
1660
|
+
shouldThrowOnError: false,
|
|
1707
1661
|
});
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1662
|
+
if (betterAuthConfig) {
|
|
1663
|
+
const plugins = betterAuthConfig.plugins || [];
|
|
1664
|
+
const organizationPlugin = plugins.find((plugin) => plugin.id === 'organization');
|
|
1665
|
+
if (organizationPlugin) {
|
|
1666
|
+
const teamsEnabled = organizationPlugin.options?.teams?.enabled === true;
|
|
1667
|
+
return res.json({
|
|
1668
|
+
enabled: teamsEnabled,
|
|
1669
|
+
configPath: authConfigPath,
|
|
1670
|
+
organizationPlugin: organizationPlugin || null,
|
|
1671
|
+
});
|
|
1672
|
+
}
|
|
1673
|
+
else {
|
|
1674
|
+
return res.json({
|
|
1675
|
+
enabled: false,
|
|
1676
|
+
configPath: authConfigPath,
|
|
1677
|
+
organizationPlugin: null,
|
|
1678
|
+
error: 'Organization plugin not found',
|
|
1679
|
+
});
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1711
1682
|
try {
|
|
1712
1683
|
const { readFileSync } = await import('fs');
|
|
1713
1684
|
const content = readFileSync(authConfigPath, 'utf-8');
|
|
1714
|
-
const { extractBetterAuthConfig } = await import('./config');
|
|
1685
|
+
const { extractBetterAuthConfig } = await import('./config.js');
|
|
1715
1686
|
const config = extractBetterAuthConfig(content);
|
|
1716
1687
|
if (config && config.plugins) {
|
|
1717
1688
|
const organizationPlugin = config.plugins.find((plugin) => plugin.id === 'organization');
|
|
@@ -1729,10 +1700,14 @@ export function createRoutes(authConfig, configPath, geoDbPath) {
|
|
|
1729
1700
|
}
|
|
1730
1701
|
res.json({
|
|
1731
1702
|
enabled: false,
|
|
1732
|
-
error: 'Failed to load auth config -
|
|
1703
|
+
error: 'Failed to load auth config - getConfig failed and regex extraction unavailable',
|
|
1733
1704
|
configPath: authConfigPath,
|
|
1734
1705
|
});
|
|
1735
1706
|
}
|
|
1707
|
+
catch (error) {
|
|
1708
|
+
console.error('Error checking teams plugin:', error);
|
|
1709
|
+
res.status(500).json({ error: 'Failed to check teams status' });
|
|
1710
|
+
}
|
|
1736
1711
|
}
|
|
1737
1712
|
catch (error) {
|
|
1738
1713
|
console.error('Error checking teams status:', error);
|
|
@@ -2364,44 +2339,26 @@ export function createRoutes(authConfig, configPath, geoDbPath) {
|
|
|
2364
2339
|
});
|
|
2365
2340
|
}
|
|
2366
2341
|
try {
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
_content: content,
|
|
2377
|
-
plugins: [],
|
|
2378
|
-
},
|
|
2379
|
-
},
|
|
2380
|
-
};
|
|
2381
|
-
}
|
|
2382
|
-
const auth = authModule.auth || authModule.default;
|
|
2383
|
-
if (!auth) {
|
|
2342
|
+
const { getConfig } = await import('./config.js');
|
|
2343
|
+
const betterAuthConfig = await getConfig({
|
|
2344
|
+
cwd: process.cwd(),
|
|
2345
|
+
configPath: authConfigPath,
|
|
2346
|
+
shouldThrowOnError: false,
|
|
2347
|
+
});
|
|
2348
|
+
if (betterAuthConfig) {
|
|
2349
|
+
const plugins = betterAuthConfig?.plugins || [];
|
|
2350
|
+
const hasOrganizationPlugin = plugins.find((plugin) => plugin.id === 'organization');
|
|
2384
2351
|
return res.json({
|
|
2385
|
-
enabled:
|
|
2386
|
-
error: 'No auth export found',
|
|
2352
|
+
enabled: !!hasOrganizationPlugin,
|
|
2387
2353
|
configPath: authConfigPath,
|
|
2354
|
+
availablePlugins: plugins.map((p) => p.id) || [],
|
|
2355
|
+
organizationPlugin: hasOrganizationPlugin || null,
|
|
2388
2356
|
});
|
|
2389
2357
|
}
|
|
2390
|
-
const plugins = auth.options?.plugins || [];
|
|
2391
|
-
const hasOrganizationPlugin = plugins.find((plugin) => plugin.id === 'organization');
|
|
2392
|
-
res.json({
|
|
2393
|
-
enabled: !!hasOrganizationPlugin,
|
|
2394
|
-
configPath: authConfigPath,
|
|
2395
|
-
availablePlugins: plugins.map((p) => p.id) || [],
|
|
2396
|
-
organizationPlugin: hasOrganizationPlugin || null,
|
|
2397
|
-
});
|
|
2398
|
-
}
|
|
2399
|
-
catch (error) {
|
|
2400
|
-
console.error('Error checking organization plugin:', error);
|
|
2401
2358
|
try {
|
|
2402
2359
|
const { readFileSync } = await import('fs');
|
|
2403
2360
|
const content = readFileSync(authConfigPath, 'utf-8');
|
|
2404
|
-
const { extractBetterAuthConfig } = await import('./config');
|
|
2361
|
+
const { extractBetterAuthConfig } = await import('./config.js');
|
|
2405
2362
|
const config = extractBetterAuthConfig(content);
|
|
2406
2363
|
if (config && config.plugins) {
|
|
2407
2364
|
const hasOrganizationPlugin = config.plugins.find((plugin) => plugin.id === 'organization');
|
|
@@ -2419,10 +2376,14 @@ export function createRoutes(authConfig, configPath, geoDbPath) {
|
|
|
2419
2376
|
}
|
|
2420
2377
|
res.json({
|
|
2421
2378
|
enabled: false,
|
|
2422
|
-
error: 'Failed to load auth config -
|
|
2379
|
+
error: 'Failed to load auth config - getConfig failed and regex extraction unavailable',
|
|
2423
2380
|
configPath: authConfigPath,
|
|
2424
2381
|
});
|
|
2425
2382
|
}
|
|
2383
|
+
catch (error) {
|
|
2384
|
+
console.error('Error checking organization plugin:', error);
|
|
2385
|
+
res.status(500).json({ error: 'Failed to check plugin status' });
|
|
2386
|
+
}
|
|
2426
2387
|
}
|
|
2427
2388
|
catch (error) {
|
|
2428
2389
|
console.error('Error checking plugin status:', error);
|