activescott / activescott/auth

[FEATURE] @activescott/auth-adapter-hono — Hono framework adapter

Aperta
#27 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
TypeScript
Stelle
0
Fork
1
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

## Summary

Add `@activescott/auth-adapter-hono` — a Hono adapter for `@activescott/auth`. Works on Node, Cloudflare Workers, Bun, and Deno.

## Motivation

Hono is a fast, lightweight framework that runs everywhere Web standards are available. Because Hono uses standard `Request/Response`, the adapter is extremely thin — no framework-specific quirks. It's the simplest possible adapter and covers a large target audience (especially Cloudflare Workers users).

## API

Same `createAuthHandlers` surface as the React Router adapter, plus three Hono-specific exports:

```ts
import { createAuthHandlers, sendMagicLink } from '@activescott/auth-adapter-hono'
import { requireAuthMiddleware, optionalAuthMiddleware, createAuthHandler } from '@activescott/auth-adapter-hono'
```

**Catch-all auth route:**
```ts
app.all('/auth/:provider/:action', createAuthHandler(handlers))
```

**Protected route middleware:**
```ts
app.use('/dashboard/*', requireAuthMiddleware(handlers))
app.get('/dashboard', (c) => {
const user = c.get('user') as AppUser
return c.json({ user })
})
```

**Optional auth:**
```ts
app.use('/', optionalAuthMiddleware(handlers))
```

## Acceptance Criteria

- [ ] Package `@activescott/auth-adapter-hono` published
- [ ] `createAuthHandlers` — same API as React Router adapter
- [ ] `requireAuthMiddleware` — sets `c.set('user', user)` or returns 302
- [ ] `optionalAuthMiddleware` — sets `c.set('user', user | null)`, never redirects
- [ ] `createAuthHandler` — route handler factory for the catch-all auth route
- [ ] 30 tests passing (21 handler tests + 9 middleware tests)
- [ ] Zero Hono-version-specific dependencies (peer dep `hono ^4.0.0`)

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.