A modular authentication library for Val Town with support for multiple OAuth providers.
This implementation provides a complete GitHub OAuth 2.0 flow with the following features:
auth/
โโโ core/
โ โโโ types.ts # TypeScript interfaces
โ โโโ signer.ts # JWT signing/verification
โ โโโ adapters.ts # Auth provider implementations
โโโ hono/
โ โโโ createMiddleware.ts # Middleware factory
โ โโโ github.ts # GitHub-specific routes
โโโ react/
โ โโโ createHook.ts # React hook factory
โ โโโ createComponents.ts # Component factory
โ โโโ github.tsx # GitHub components
โโโ index.ts # Main exports
Environment Variables
GITHUB_CLIENT_ID=your_github_client_id GITHUB_CLIENT_SECRET=your_github_client_secret JWT_SECRET=your_secure_jwt_secret
GitHub OAuth App Configuration
https://your-domain.com/auth/github/callback
user:email
, read:user
import { Hono } from "hono";
import { createGitHubAuthRoutes, githubAuthMiddleware } from "./auth/hono/github.ts";
const app = new Hono();
// Add auth routes
const authRoutes = createGitHubAuthRoutes();
app.route("/", authRoutes);
// Protect API routes
app.get("/api/me", githubAuthMiddleware, (c) => {
const user = c.get("user");
return c.json(user);
});
These will be implemented in future steps.
Run the main.tsx file to see a working demonstration of the GitHub OAuth flow with a beautiful UI built using React and TailwindCSS.