better-auth-studio 1.0.49-beta.8 → 1.0.49

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.
@@ -1 +1 @@
1
- {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAOA,OAAO,EAA+B,MAAM,EAAE,MAAM,SAAS,CAAC;AAS9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA8D9C,wBAAsB,oBAAoB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CA8I/E;AAwBD,wBAAgB,YAAY,CAC1B,UAAU,EAAE,UAAU,EACtB,UAAU,CAAC,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAgiKR"}
1
+ {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAOA,OAAO,EAA+B,MAAM,EAAE,MAAM,SAAS,CAAC;AAS9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA8D9C,wBAAsB,oBAAoB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CA8I/E;AAwBD,wBAAgB,YAAY,CAC1B,UAAU,EAAE,UAAU,EACtB,UAAU,CAAC,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CA8jKR"}
package/dist/routes.js CHANGED
@@ -1284,15 +1284,34 @@ export function createRoutes(authConfig, configPath, geoDbPath) {
1284
1284
  const basePathRaw = authConfig.basePath || '/api/auth';
1285
1285
  const basePath = basePathRaw === '/' ? '' : basePathRaw.startsWith('/') ? basePathRaw : `/${basePathRaw}`;
1286
1286
  const endpointChecks = [
1287
- { label: 'Sign In', method: 'OPTIONS', path: '/sign-in/email' },
1288
- { label: 'Sign Up', method: 'OPTIONS', path: '/sign-up/email' },
1287
+ {
1288
+ label: 'Sign In',
1289
+ method: 'POST',
1290
+ path: '/sign-in/email',
1291
+ body: JSON.stringify({
1292
+ email: `test-${Date.now()}@example.com`,
1293
+ password: 'test-password-123',
1294
+ }),
1295
+ },
1296
+ {
1297
+ label: 'Get Session',
1298
+ method: 'GET',
1299
+ path: '/get-session',
1300
+ },
1289
1301
  ];
1290
1302
  const checks = await Promise.all(endpointChecks.map(async (check) => {
1291
1303
  const targetUrl = `${baseUrl}${basePath}${check.path}`;
1292
1304
  try {
1293
- const response = await fetch(targetUrl, {
1305
+ const fetchOptions = {
1294
1306
  method: check.method,
1295
- });
1307
+ headers: {
1308
+ 'Content-Type': 'application/json',
1309
+ },
1310
+ };
1311
+ if (check.method === 'POST' && check.body) {
1312
+ fetchOptions.body = check.body;
1313
+ }
1314
+ const response = await fetch(targetUrl, fetchOptions);
1296
1315
  const ok = response.status < 500 && response.status !== 404 && response.status !== 302;
1297
1316
  if (!ok) {
1298
1317
  return {
@@ -4493,7 +4512,7 @@ export function createRoutes(authConfig, configPath, geoDbPath) {
4493
4512
  if (provider.toLowerCase() === 'google') {
4494
4513
  try {
4495
4514
  const tokenInfoUrl = `https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=test`;
4496
- const isValidClientIdFormat = /^[\d\w\-]+\.apps\.googleusercontent\.com$|^\d+$/.test(clientId);
4515
+ const isValidClientIdFormat = /^[\d\w-]+\.apps\.googleusercontent\.com$|^\d+$/.test(clientId);
4497
4516
  if (!isValidClientIdFormat) {
4498
4517
  return res.json({
4499
4518
  success: false,
@@ -4598,9 +4617,7 @@ export function createRoutes(authConfig, configPath, geoDbPath) {
4598
4617
  const secretLength = typeof length === 'number' && length >= 16 && length <= 128 ? length : 32;
4599
4618
  const secretFormat = format === 'base64' ? 'base64' : 'hex';
4600
4619
  const secretBytes = randomBytes(secretLength);
4601
- const secret = secretFormat === 'hex'
4602
- ? secretBytes.toString('hex')
4603
- : secretBytes.toString('base64');
4620
+ const secret = secretFormat === 'hex' ? secretBytes.toString('hex') : secretBytes.toString('base64');
4604
4621
  const entropy = secretLength * 8; // bits of entropy
4605
4622
  res.json({
4606
4623
  success: true,
@@ -4630,8 +4647,8 @@ export function createRoutes(authConfig, configPath, geoDbPath) {
4630
4647
  const envPath = join(process.cwd(), '.env');
4631
4648
  const envLocalPath = join(process.cwd(), '.env.local');
4632
4649
  // Try .env.local first, then .env
4633
- let targetPath = existsSync(envLocalPath) ? envLocalPath : envPath;
4634
- let envContent = existsSync(targetPath) ? readFileSync(targetPath, 'utf-8') : '';
4650
+ const targetPath = existsSync(envLocalPath) ? envLocalPath : envPath;
4651
+ const envContent = existsSync(targetPath) ? readFileSync(targetPath, 'utf-8') : '';
4635
4652
  // Generate environment variable names
4636
4653
  const providerUpper = provider.toUpperCase();
4637
4654
  const clientIdKey = `${providerUpper}_CLIENT_ID`;
@@ -4678,8 +4695,8 @@ export function createRoutes(authConfig, configPath, geoDbPath) {
4678
4695
  }
4679
4696
  const envPath = join(process.cwd(), '.env');
4680
4697
  const envLocalPath = join(process.cwd(), '.env.local');
4681
- let targetPath = existsSync(envLocalPath) ? envLocalPath : envPath;
4682
- let envContent = existsSync(targetPath) ? readFileSync(targetPath, 'utf-8') : '';
4698
+ const targetPath = existsSync(envLocalPath) ? envLocalPath : envPath;
4699
+ const envContent = existsSync(targetPath) ? readFileSync(targetPath, 'utf-8') : '';
4683
4700
  const envLines = envContent.split('\n');
4684
4701
  const envMap = new Map();
4685
4702
  const newLines = [];
@@ -4722,8 +4739,11 @@ export function createRoutes(authConfig, configPath, geoDbPath) {
4722
4739
  while (newLines.length > 0 && !newLines[newLines.length - 1].trim()) {
4723
4740
  newLines.pop();
4724
4741
  }
4725
- if (newLines.length > 0 && newLines[newLines.length - 1] && !newLines[newLines.length - 1].endsWith('\n')) {
4726
- if (!newLines[newLines.length - 1].endsWith('\r\n') && !newLines[newLines.length - 1].endsWith('\n')) {
4742
+ if (newLines.length > 0 &&
4743
+ newLines[newLines.length - 1] &&
4744
+ !newLines[newLines.length - 1].endsWith('\n')) {
4745
+ if (!newLines[newLines.length - 1].endsWith('\r\n') &&
4746
+ !newLines[newLines.length - 1].endsWith('\n')) {
4727
4747
  newLines.push('');
4728
4748
  }
4729
4749
  }