@cloudauth/cloud-auth 0.1.0 → 0.1.1
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.
- package/README.md +128 -0
- package/package.json +12 -3
package/README.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# CloudAuth
|
|
2
|
+
|
|
3
|
+
**Lightweight OAuth-only authentication for TypeScript apps.**
|
|
4
|
+
|
|
5
|
+
No passwords. No dashboard. No bloat. Just providers, users, sessions, and extensibility.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { cloudAuth } from "@cloudauth/cloud-auth"
|
|
9
|
+
import { google, github } from "@cloudauth/cloud-auth/providers"
|
|
10
|
+
import { drizzleAdapter } from "@cloudauth/cloud-auth/adapters/drizzle"
|
|
11
|
+
|
|
12
|
+
export const auth = cloudAuth({
|
|
13
|
+
appName: "My App",
|
|
14
|
+
baseURL: "https://app.example.com",
|
|
15
|
+
providers: [google({ clientId, clientSecret })],
|
|
16
|
+
database: drizzleAdapter(db),
|
|
17
|
+
security: { secret: process.env.AUTH_SECRET },
|
|
18
|
+
})
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
- **OAuth/OIDC only** — Google, GitHub, generic OAuth, generic OIDC
|
|
24
|
+
- **Authorization Code Flow with PKCE** — industry standard security
|
|
25
|
+
- **Secure sessions** — HTTP-only cookies, HMAC-signed, rolling expiration
|
|
26
|
+
- **TypeScript-first** — strict types with full inference
|
|
27
|
+
- **Framework-agnostic** — Hono integration built-in (Express, Next.js coming)
|
|
28
|
+
- **Drizzle ORM** — SQLite, Postgres, D1 support via adapter
|
|
29
|
+
- **Pluggable** — hooks system, additional fields, custom adapters
|
|
30
|
+
- **No admin dashboard** — you own your UI
|
|
31
|
+
- **No password management** — no hashing, no reset flows, no breach checks
|
|
32
|
+
|
|
33
|
+
## Quick Start
|
|
34
|
+
|
|
35
|
+
### 1. Install
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pnpm add @cloudauth/cloud-auth drizzle-orm @libsql/client
|
|
39
|
+
pnpm add -D drizzle-kit
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### 2. Set up auth
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
// src/auth.ts
|
|
46
|
+
import { cloudAuth } from "@cloudauth/cloud-auth"
|
|
47
|
+
import { google } from "@cloudauth/cloud-auth/providers"
|
|
48
|
+
import { drizzleAdapter } from "@cloudauth/cloud-auth/adapters/drizzle"
|
|
49
|
+
import { drizzle } from "drizzle-orm/libsql"
|
|
50
|
+
import { createClient } from "@libsql/client"
|
|
51
|
+
|
|
52
|
+
const client = createClient({ url: "file:./data.db" })
|
|
53
|
+
const db = drizzle(client)
|
|
54
|
+
|
|
55
|
+
export const auth = cloudAuth({
|
|
56
|
+
appName: "My App",
|
|
57
|
+
baseURL: "http://localhost:3000",
|
|
58
|
+
providers: [
|
|
59
|
+
google({
|
|
60
|
+
clientId: process.env.GOOGLE_CLIENT_ID!,
|
|
61
|
+
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
|
|
62
|
+
}),
|
|
63
|
+
],
|
|
64
|
+
database: drizzleAdapter(db),
|
|
65
|
+
session: { expiresIn: 60 * 60 * 24 * 30 },
|
|
66
|
+
security: { secret: process.env.AUTH_SECRET! },
|
|
67
|
+
})
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### 3. Add auth routes (Hono)
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import { Hono } from "hono"
|
|
74
|
+
import { authHandler, requireAuth } from "@cloudauth/cloud-auth/hono"
|
|
75
|
+
import { auth } from "./auth"
|
|
76
|
+
|
|
77
|
+
const app = new Hono()
|
|
78
|
+
app.route("/auth", authHandler(auth))
|
|
79
|
+
|
|
80
|
+
app.get("/dashboard", requireAuth(auth), (c) => {
|
|
81
|
+
const session = c.get("session")
|
|
82
|
+
return c.json({ user: session.user })
|
|
83
|
+
})
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 4. Set environment variables
|
|
87
|
+
|
|
88
|
+
```env
|
|
89
|
+
AUTH_SECRET=your-secret-at-least-32-characters-long
|
|
90
|
+
BASE_URL=http://localhost:3000
|
|
91
|
+
GOOGLE_CLIENT_ID=...
|
|
92
|
+
GOOGLE_CLIENT_SECRET=...
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Why CloudAuth?
|
|
96
|
+
|
|
97
|
+
Better Auth is excellent but broad. CloudAuth is intentionally narrow:
|
|
98
|
+
|
|
99
|
+
| Feature | Better Auth | CloudAuth |
|
|
100
|
+
|---|---|---|
|
|
101
|
+
| OAuth/OIDC | ✅ | ✅ |
|
|
102
|
+
| Email/Password | ✅ | ❌ |
|
|
103
|
+
| Magic Links | ✅ | ❌ |
|
|
104
|
+
| MFA/2FA | ✅ | ❌ |
|
|
105
|
+
| Built-in RBAC | ✅ | ❌ |
|
|
106
|
+
| Admin Dashboard | ✅ | ❌ |
|
|
107
|
+
| SAML SSO | ✅ | ❌ |
|
|
108
|
+
| Schema size | ~15 tables | **4 tables** |
|
|
109
|
+
| TypeScript inference | ✅ | ✅ |
|
|
110
|
+
|
|
111
|
+
## Package Architecture
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
@cloudauth/cloud-auth — Core: config, auth engine, utilities
|
|
115
|
+
@cloudauth/cloud-auth/providers — Provider implementations
|
|
116
|
+
@cloudauth/cloud-auth/adapters/drizzle — Drizzle ORM adapter
|
|
117
|
+
@cloudauth/cloud-auth/hono — Hono framework integration
|
|
118
|
+
@cloudauth/cloud-auth/client — Browser client SDK
|
|
119
|
+
@cloudauth/cloud-auth/client/react — React bindings
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Status
|
|
123
|
+
|
|
124
|
+
Alpha — under active development. All phases are being built in sequence.
|
|
125
|
+
|
|
126
|
+
## License
|
|
127
|
+
|
|
128
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudauth/cloud-auth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Lightweight OAuth-only authentication for TypeScript apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
"@cloudauth/providers": "0.1.0",
|
|
53
53
|
"@cloudauth/core": "0.1.0",
|
|
54
54
|
"@cloudauth/adapter-drizzle": "0.1.0",
|
|
55
|
-
"@cloudauth/
|
|
55
|
+
"@cloudauth/integration-hono": "0.1.0",
|
|
56
56
|
"@cloudauth/cli": "0.1.0",
|
|
57
|
-
"@cloudauth/
|
|
57
|
+
"@cloudauth/client": "0.1.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@libsql/client": "^0.17.0"
|
|
@@ -68,6 +68,15 @@
|
|
|
68
68
|
"node": ">=20.0.0"
|
|
69
69
|
},
|
|
70
70
|
"license": "MIT",
|
|
71
|
+
"author": "Javed Quadri",
|
|
72
|
+
"repository": {
|
|
73
|
+
"type": "git",
|
|
74
|
+
"url": "git+https://github.com/javedquadri/cloudauth.git"
|
|
75
|
+
},
|
|
76
|
+
"homepage": "https://github.com/javedquadri/cloudauth#readme",
|
|
77
|
+
"bugs": {
|
|
78
|
+
"url": "https://github.com/javedquadri/cloudauth/issues"
|
|
79
|
+
},
|
|
71
80
|
"keywords": [
|
|
72
81
|
"authentication",
|
|
73
82
|
"oauth",
|