import { Router } from 'express';
const router = Router();
// OAuth Authorization Server Metadata
router.get('/oauth-authorization-server', (req, res) => {
const baseUrl = `${req.protocol}://${req.get('host')}`;
res.json({
issuer: baseUrl,
authorization_endpoint: `${baseUrl}/auth/authorize`,
token_endpoint: `${baseUrl}/auth/token`,
token_endpoint_auth_methods_supported: ['none'],
response_types_supported: ['code'],
grant_types_supported: ['authorization_code'],
code_challenge_methods_supported: ['S256'],
});
});
// Protected Resource Metadata
router.get('/oauth-protected-resource', (req, res) => {
const baseUrl = `${req.protocol}://${req.get('host')}`;
res.json({
resource: baseUrl,
authorization_servers: [`${baseUrl}`],
});
});
export const discoveryRouter = router;