better-auth-studio 1.0.49-beta.1 → 1.0.49-beta.3

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,CA8uJR"}
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,CAq2JR"}
package/dist/routes.js CHANGED
@@ -4487,6 +4487,117 @@ export function createRoutes(authConfig, configPath, geoDbPath) {
4487
4487
  });
4488
4488
  }
4489
4489
  });
4490
+ router.post('/api/tools/test-oauth-credentials', async (req, res) => {
4491
+ try {
4492
+ const { provider, clientId, clientSecret, redirectURI } = req.body || {};
4493
+ if (!provider || !clientId || !clientSecret) {
4494
+ return res.status(400).json({
4495
+ success: false,
4496
+ message: 'Provider, Client ID, and Client Secret are required',
4497
+ });
4498
+ }
4499
+ if (provider.toLowerCase() === 'google') {
4500
+ try {
4501
+ const tokenInfoUrl = `https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=test`;
4502
+ const isValidClientIdFormat = /^[\d\w\-]+\.apps\.googleusercontent\.com$|^\d+$/.test(clientId);
4503
+ if (!isValidClientIdFormat) {
4504
+ return res.json({
4505
+ success: false,
4506
+ message: 'Invalid Google Client ID format',
4507
+ details: {
4508
+ provider: 'google',
4509
+ clientIdFormat: 'Should end with .apps.googleusercontent.com or be numeric',
4510
+ },
4511
+ });
4512
+ }
4513
+ const discoveryUrl = 'https://accounts.google.com/.well-known/openid-configuration';
4514
+ const discoveryResponse = await fetch(discoveryUrl);
4515
+ if (!discoveryResponse.ok) {
4516
+ return res.json({
4517
+ success: false,
4518
+ message: 'Unable to reach Google OAuth service',
4519
+ details: {
4520
+ provider: 'google',
4521
+ error: 'Network error',
4522
+ },
4523
+ });
4524
+ }
4525
+ if (redirectURI) {
4526
+ try {
4527
+ new URL(redirectURI);
4528
+ }
4529
+ catch {
4530
+ return res.json({
4531
+ success: false,
4532
+ message: 'Invalid Redirect URI format',
4533
+ details: {
4534
+ provider: 'google',
4535
+ redirectURI: redirectURI,
4536
+ },
4537
+ });
4538
+ }
4539
+ }
4540
+ return res.json({
4541
+ success: true,
4542
+ message: 'Google OAuth credentials format is valid',
4543
+ details: {
4544
+ provider: 'google',
4545
+ clientId: clientId.substring(0, 20) + '...',
4546
+ redirectURI: redirectURI || 'Not configured',
4547
+ note: 'Credentials format validated. Test with actual OAuth flow to confirm.',
4548
+ },
4549
+ });
4550
+ }
4551
+ catch (error) {
4552
+ return res.json({
4553
+ success: false,
4554
+ message: 'Failed to validate Google OAuth credentials',
4555
+ details: {
4556
+ provider: 'google',
4557
+ error: error instanceof Error ? error.message : 'Unknown error',
4558
+ },
4559
+ });
4560
+ }
4561
+ }
4562
+ if (!clientId.trim() || !clientSecret.trim()) {
4563
+ return res.json({
4564
+ success: false,
4565
+ message: 'Client ID and Secret cannot be empty',
4566
+ });
4567
+ }
4568
+ if (redirectURI) {
4569
+ try {
4570
+ new URL(redirectURI);
4571
+ }
4572
+ catch {
4573
+ return res.json({
4574
+ success: false,
4575
+ message: 'Invalid Redirect URI format',
4576
+ details: {
4577
+ provider: provider,
4578
+ redirectURI: redirectURI,
4579
+ },
4580
+ });
4581
+ }
4582
+ }
4583
+ return res.json({
4584
+ success: true,
4585
+ message: `${provider} OAuth credentials format is valid`,
4586
+ details: {
4587
+ provider: provider,
4588
+ clientId: clientId.substring(0, 20) + '...',
4589
+ redirectURI: redirectURI || 'Not configured',
4590
+ note: 'Credentials format validated. Test with actual OAuth flow to confirm.',
4591
+ },
4592
+ });
4593
+ }
4594
+ catch (error) {
4595
+ res.status(500).json({
4596
+ success: false,
4597
+ message: error instanceof Error ? error.message : 'Failed to test OAuth credentials',
4598
+ });
4599
+ }
4600
+ });
4490
4601
  return router;
4491
4602
  }
4492
4603
  //# sourceMappingURL=routes.js.map