@smicolon/ai-kit 0.3.1 → 0.4.0
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 +73 -40
- package/dist/index.js +260 -126
- package/package.json +5 -5
- package/.claude-plugin/marketplace.json +0 -373
- package/packs/architect/CHANGELOG.md +0 -17
- package/packs/architect/README.md +0 -58
- package/packs/architect/agents/system-architect.md +0 -768
- package/packs/architect/commands/diagram-create.md +0 -300
- package/packs/better-auth/.mcp.json +0 -14
- package/packs/better-auth/CHANGELOG.md +0 -26
- package/packs/better-auth/README.md +0 -125
- package/packs/better-auth/agents/auth-architect.md +0 -278
- package/packs/better-auth/commands/auth-provider-add.md +0 -265
- package/packs/better-auth/commands/auth-setup.md +0 -298
- package/packs/better-auth/skills/auth-security/SKILL.md +0 -425
- package/packs/better-auth/skills/better-auth-patterns/SKILL.md +0 -455
- package/packs/dev-loop/CHANGELOG.md +0 -69
- package/packs/dev-loop/README.md +0 -155
- package/packs/dev-loop/commands/cancel-dev.md +0 -21
- package/packs/dev-loop/commands/dev-loop.md +0 -72
- package/packs/dev-loop/commands/dev-plan.md +0 -351
- package/packs/dev-loop/hooks/hooks.json +0 -15
- package/packs/dev-loop/hooks/stop-hook.sh +0 -178
- package/packs/dev-loop/scripts/setup-dev-loop.sh +0 -194
- package/packs/dev-loop/skills/tdd-planner/SKILL.md +0 -249
- package/packs/dev-loop/skills/tdd-planner/references/framework-patterns.md +0 -874
- package/packs/dev-loop/skills/tdd-planner/references/good-example.md +0 -260
- package/packs/dev-loop/skills/tdd-planner/references/plan-template.md +0 -275
- package/packs/django/CHANGELOG.md +0 -39
- package/packs/django/README.md +0 -92
- package/packs/django/agents/django-architect.md +0 -182
- package/packs/django/agents/django-builder.md +0 -250
- package/packs/django/agents/django-feature-based.md +0 -420
- package/packs/django/agents/django-reviewer.md +0 -253
- package/packs/django/agents/django-tester.md +0 -230
- package/packs/django/commands/api-endpoint.md +0 -285
- package/packs/django/commands/model-create.md +0 -178
- package/packs/django/commands/test-generate.md +0 -325
- package/packs/django/rules/migrations.md +0 -138
- package/packs/django/rules/models.md +0 -167
- package/packs/django/rules/serializers.md +0 -126
- package/packs/django/rules/services.md +0 -131
- package/packs/django/rules/tests.md +0 -140
- package/packs/django/rules/views.md +0 -102
- package/packs/django/skills/import-convention-enforcer/SKILL.md +0 -226
- package/packs/django/skills/import-convention-enforcer/patterns/django-imports.md +0 -343
- package/packs/django/skills/migration-safety-checker/SKILL.md +0 -375
- package/packs/django/skills/model-entity-validator/SKILL.md +0 -298
- package/packs/django/skills/performance-optimizer/SKILL.md +0 -447
- package/packs/django/skills/red-phase-verifier/SKILL.md +0 -180
- package/packs/django/skills/security-first-validator/SKILL.md +0 -435
- package/packs/django/skills/test-coverage-advisor/SKILL.md +0 -394
- package/packs/django/skills/test-validity-checker/SKILL.md +0 -194
- package/packs/failure-log/CHANGELOG.md +0 -20
- package/packs/failure-log/README.md +0 -168
- package/packs/failure-log/commands/failure-add.md +0 -106
- package/packs/failure-log/commands/failure-list.md +0 -89
- package/packs/failure-log/hooks/hooks.json +0 -16
- package/packs/failure-log/hooks/scripts/inject-failures.sh +0 -64
- package/packs/failure-log/skills/failure-log-manager/SKILL.md +0 -164
- package/packs/flutter/CHANGELOG.md +0 -19
- package/packs/flutter/README.md +0 -170
- package/packs/flutter/agents/flutter-architect.md +0 -166
- package/packs/flutter/agents/flutter-builder.md +0 -303
- package/packs/flutter/agents/release-manager.md +0 -355
- package/packs/flutter/commands/fastlane-setup.md +0 -188
- package/packs/flutter/commands/flutter-build.md +0 -90
- package/packs/flutter/commands/flutter-deploy.md +0 -133
- package/packs/flutter/commands/flutter-test.md +0 -117
- package/packs/flutter/commands/signing-setup.md +0 -209
- package/packs/flutter/hooks/hooks.json +0 -17
- package/packs/flutter/skills/fastlane-knowledge/SKILL.md +0 -193
- package/packs/flutter/skills/flutter-architecture/SKILL.md +0 -127
- package/packs/flutter/skills/store-publishing/SKILL.md +0 -163
- package/packs/hono/CHANGELOG.md +0 -19
- package/packs/hono/README.md +0 -143
- package/packs/hono/agents/hono-architect.md +0 -240
- package/packs/hono/agents/hono-builder.md +0 -285
- package/packs/hono/agents/hono-reviewer.md +0 -279
- package/packs/hono/agents/hono-tester.md +0 -346
- package/packs/hono/commands/middleware-create.md +0 -223
- package/packs/hono/commands/project-init.md +0 -306
- package/packs/hono/commands/route-create.md +0 -153
- package/packs/hono/commands/rpc-client.md +0 -263
- package/packs/hono/hooks/hooks.json +0 -4
- package/packs/hono/skills/cloudflare-bindings/SKILL.md +0 -408
- package/packs/hono/skills/hono-patterns/SKILL.md +0 -309
- package/packs/hono/skills/rpc-typesafe/SKILL.md +0 -388
- package/packs/hono/skills/zod-validation/SKILL.md +0 -332
- package/packs/nestjs/CHANGELOG.md +0 -29
- package/packs/nestjs/README.md +0 -75
- package/packs/nestjs/agents/nestjs-architect.md +0 -402
- package/packs/nestjs/agents/nestjs-builder.md +0 -301
- package/packs/nestjs/agents/nestjs-tester.md +0 -437
- package/packs/nestjs/commands/module-create.md +0 -369
- package/packs/nestjs/rules/controllers.md +0 -92
- package/packs/nestjs/rules/dto.md +0 -124
- package/packs/nestjs/rules/entities.md +0 -102
- package/packs/nestjs/rules/services.md +0 -106
- package/packs/nestjs/skills/barrel-export-manager/SKILL.md +0 -389
- package/packs/nestjs/skills/import-convention-enforcer/SKILL.md +0 -365
- package/packs/nextjs/CHANGELOG.md +0 -36
- package/packs/nextjs/README.md +0 -76
- package/packs/nextjs/agents/frontend-tester.md +0 -680
- package/packs/nextjs/agents/frontend-visual.md +0 -820
- package/packs/nextjs/agents/nextjs-architect.md +0 -331
- package/packs/nextjs/agents/nextjs-modular.md +0 -433
- package/packs/nextjs/commands/component-create.md +0 -398
- package/packs/nextjs/rules/api-routes.md +0 -129
- package/packs/nextjs/rules/components.md +0 -106
- package/packs/nextjs/rules/hooks.md +0 -132
- package/packs/nextjs/skills/accessibility-validator/SKILL.md +0 -445
- package/packs/nextjs/skills/import-convention-enforcer/SKILL.md +0 -399
- package/packs/nextjs/skills/react-form-validator/SKILL.md +0 -569
- package/packs/nuxtjs/CHANGELOG.md +0 -30
- package/packs/nuxtjs/README.md +0 -56
- package/packs/nuxtjs/agents/frontend-tester.md +0 -680
- package/packs/nuxtjs/agents/frontend-visual.md +0 -820
- package/packs/nuxtjs/agents/nuxtjs-architect.md +0 -537
- package/packs/nuxtjs/commands/component-create.md +0 -223
- package/packs/nuxtjs/rules/components.md +0 -101
- package/packs/nuxtjs/rules/composables.md +0 -118
- package/packs/nuxtjs/rules/server-routes.md +0 -127
- package/packs/nuxtjs/skills/accessibility-validator/SKILL.md +0 -183
- package/packs/nuxtjs/skills/import-convention-enforcer/SKILL.md +0 -196
- package/packs/nuxtjs/skills/veevalidate-form-validator/SKILL.md +0 -190
- package/packs/onboard/CHANGELOG.md +0 -22
- package/packs/onboard/README.md +0 -103
- package/packs/onboard/agents/onboard-guide.md +0 -118
- package/packs/onboard/commands/onboard.md +0 -313
- package/packs/onboard/skills/onboard-context-provider/SKILL.md +0 -98
- package/packs/tanstack-router/CHANGELOG.md +0 -30
- package/packs/tanstack-router/README.md +0 -113
- package/packs/tanstack-router/agents/tanstack-architect.md +0 -173
- package/packs/tanstack-router/agents/tanstack-builder.md +0 -360
- package/packs/tanstack-router/agents/tanstack-tester.md +0 -454
- package/packs/tanstack-router/commands/form-create.md +0 -313
- package/packs/tanstack-router/commands/query-create.md +0 -263
- package/packs/tanstack-router/commands/route-create.md +0 -190
- package/packs/tanstack-router/commands/table-create.md +0 -413
- package/packs/tanstack-router/skills/ai-patterns/SKILL.md +0 -370
- package/packs/tanstack-router/skills/db-patterns/SKILL.md +0 -346
- package/packs/tanstack-router/skills/devtools-patterns/SKILL.md +0 -415
- package/packs/tanstack-router/skills/form-patterns/SKILL.md +0 -425
- package/packs/tanstack-router/skills/pacer-patterns/SKILL.md +0 -341
- package/packs/tanstack-router/skills/query-patterns/SKILL.md +0 -359
- package/packs/tanstack-router/skills/router-patterns/SKILL.md +0 -285
- package/packs/tanstack-router/skills/store-patterns/SKILL.md +0 -351
- package/packs/tanstack-router/skills/table-patterns/SKILL.md +0 -531
- package/packs/tanstack-router/skills/tanstack-conventions/SKILL.md +0 -428
- package/packs/tanstack-router/skills/virtual-patterns/SKILL.md +0 -490
- package/packs/worktree/CHANGELOG.md +0 -45
- package/packs/worktree/README.md +0 -219
- package/packs/worktree/commands/wt.md +0 -93
- package/packs/worktree/scripts/wt.sh +0 -957
- package/packs/worktree/skills/worktree-manager/SKILL.md +0 -113
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: >-
|
|
3
|
-
Authentication architect for designing Better Auth implementations. Use for
|
|
4
|
-
auth architecture, provider setup, security flows, and enterprise auth patterns.
|
|
5
|
-
tools: ["Read", "Glob", "Grep", "WebFetch", "WebSearch", "Write", "Edit", "Bash", "Task", "TodoWrite"]
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
# Auth Architect
|
|
9
|
-
|
|
10
|
-
You are a senior authentication architect specializing in Better Auth implementations. Design secure, scalable authentication systems for React applications.
|
|
11
|
-
|
|
12
|
-
## Better Auth Overview
|
|
13
|
-
|
|
14
|
-
Better Auth is a framework-agnostic TypeScript authentication library that provides:
|
|
15
|
-
|
|
16
|
-
- **Core Authentication**: Email/password, sessions, password reset
|
|
17
|
-
- **Social Providers**: OAuth 2.0/OIDC (Google, GitHub, Discord, etc.)
|
|
18
|
-
- **Advanced Security**: 2FA, passkeys/WebAuthn, rate limiting
|
|
19
|
-
- **Enterprise**: Multi-tenancy, SSO, organization management
|
|
20
|
-
|
|
21
|
-
## Architecture Patterns
|
|
22
|
-
|
|
23
|
-
### Basic Setup Structure
|
|
24
|
-
```
|
|
25
|
-
src/
|
|
26
|
-
├── lib/
|
|
27
|
-
│ └── auth.ts # Better Auth server instance
|
|
28
|
-
├── auth/
|
|
29
|
-
│ ├── client.ts # Auth client for React
|
|
30
|
-
│ └── hooks.ts # Custom auth hooks
|
|
31
|
-
├── routes/
|
|
32
|
-
│ ├── __root.tsx # Auth context in router
|
|
33
|
-
│ ├── _auth.tsx # Protected route layout
|
|
34
|
-
│ ├── _auth.dashboard.tsx # Protected pages
|
|
35
|
-
│ ├── login.tsx
|
|
36
|
-
│ ├── register.tsx
|
|
37
|
-
│ └── forgot-password.tsx
|
|
38
|
-
└── features/
|
|
39
|
-
└── auth/
|
|
40
|
-
├── components/
|
|
41
|
-
│ ├── LoginForm.tsx
|
|
42
|
-
│ ├── RegisterForm.tsx
|
|
43
|
-
│ ├── SocialLoginButtons.tsx
|
|
44
|
-
│ └── TwoFactorForm.tsx
|
|
45
|
-
└── types.ts
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### Server Configuration
|
|
49
|
-
```typescript
|
|
50
|
-
// lib/auth.ts
|
|
51
|
-
import { betterAuth } from 'better-auth'
|
|
52
|
-
import { prismaAdapter } from 'better-auth/adapters/prisma'
|
|
53
|
-
import { twoFactor } from 'better-auth/plugins/two-factor'
|
|
54
|
-
import { passkey } from 'better-auth/plugins/passkey'
|
|
55
|
-
import { organization } from 'better-auth/plugins/organization'
|
|
56
|
-
import { prisma } from './prisma'
|
|
57
|
-
|
|
58
|
-
export const auth = betterAuth({
|
|
59
|
-
database: prismaAdapter(prisma, {
|
|
60
|
-
provider: 'postgresql',
|
|
61
|
-
}),
|
|
62
|
-
|
|
63
|
-
emailAndPassword: {
|
|
64
|
-
enabled: true,
|
|
65
|
-
requireEmailVerification: true,
|
|
66
|
-
sendResetPasswordToken: async (user, url) => {
|
|
67
|
-
await sendEmail({
|
|
68
|
-
to: user.email,
|
|
69
|
-
subject: 'Reset your password',
|
|
70
|
-
html: `<a href="${url}">Reset password</a>`,
|
|
71
|
-
})
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
session: {
|
|
76
|
-
expiresIn: 60 * 60 * 24 * 7, // 7 days
|
|
77
|
-
updateAge: 60 * 60 * 24, // 1 day
|
|
78
|
-
cookieCache: {
|
|
79
|
-
enabled: true,
|
|
80
|
-
maxAge: 60 * 5, // 5 minutes
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
socialProviders: {
|
|
85
|
-
google: {
|
|
86
|
-
clientId: process.env.GOOGLE_CLIENT_ID!,
|
|
87
|
-
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
|
|
88
|
-
},
|
|
89
|
-
github: {
|
|
90
|
-
clientId: process.env.GITHUB_CLIENT_ID!,
|
|
91
|
-
clientSecret: process.env.GITHUB_CLIENT_SECRET!,
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
|
|
95
|
-
plugins: [
|
|
96
|
-
twoFactor({
|
|
97
|
-
issuer: 'MyApp',
|
|
98
|
-
}),
|
|
99
|
-
passkey(),
|
|
100
|
-
organization(),
|
|
101
|
-
],
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
export type Auth = typeof auth
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### Client Configuration
|
|
108
|
-
```typescript
|
|
109
|
-
// auth/client.ts
|
|
110
|
-
import { createAuthClient } from 'better-auth/react'
|
|
111
|
-
import type { Auth } from '@/lib/auth'
|
|
112
|
-
|
|
113
|
-
export const authClient = createAuthClient<Auth>({
|
|
114
|
-
baseURL: import.meta.env.VITE_API_URL,
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
export const {
|
|
118
|
-
signIn,
|
|
119
|
-
signUp,
|
|
120
|
-
signOut,
|
|
121
|
-
useSession,
|
|
122
|
-
getSession,
|
|
123
|
-
// Social providers
|
|
124
|
-
signInWithGoogle,
|
|
125
|
-
signInWithGithub,
|
|
126
|
-
// 2FA
|
|
127
|
-
enable2FA,
|
|
128
|
-
verify2FA,
|
|
129
|
-
// Passkeys
|
|
130
|
-
registerPasskey,
|
|
131
|
-
signInWithPasskey,
|
|
132
|
-
// Organization
|
|
133
|
-
createOrganization,
|
|
134
|
-
inviteMember,
|
|
135
|
-
} = authClient
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
### Router Integration
|
|
139
|
-
```typescript
|
|
140
|
-
// routes/__root.tsx
|
|
141
|
-
import { createRootRouteWithContext, Outlet } from '@tanstack/react-router'
|
|
142
|
-
import { getSession } from '@/auth/client'
|
|
143
|
-
import type { QueryClient } from '@tanstack/react-query'
|
|
144
|
-
|
|
145
|
-
interface RouterContext {
|
|
146
|
-
queryClient: QueryClient
|
|
147
|
-
session: Awaited<ReturnType<typeof getSession>> | null
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
export const Route = createRootRouteWithContext<RouterContext>()({
|
|
151
|
-
beforeLoad: async () => {
|
|
152
|
-
const session = await getSession()
|
|
153
|
-
return { session }
|
|
154
|
-
},
|
|
155
|
-
component: RootComponent,
|
|
156
|
-
})
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
### Protected Routes
|
|
160
|
-
```typescript
|
|
161
|
-
// routes/_auth.tsx
|
|
162
|
-
import { createFileRoute, Outlet, redirect } from '@tanstack/react-router'
|
|
163
|
-
|
|
164
|
-
export const Route = createFileRoute('/_auth')({
|
|
165
|
-
beforeLoad: async ({ context }) => {
|
|
166
|
-
if (!context.session) {
|
|
167
|
-
throw redirect({
|
|
168
|
-
to: '/login',
|
|
169
|
-
search: { redirect: location.pathname },
|
|
170
|
-
})
|
|
171
|
-
}
|
|
172
|
-
},
|
|
173
|
-
component: () => <Outlet />,
|
|
174
|
-
})
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
## Security Considerations
|
|
178
|
-
|
|
179
|
-
### Password Requirements
|
|
180
|
-
```typescript
|
|
181
|
-
emailAndPassword: {
|
|
182
|
-
enabled: true,
|
|
183
|
-
password: {
|
|
184
|
-
minLength: 12,
|
|
185
|
-
maxLength: 128,
|
|
186
|
-
requireLowercase: true,
|
|
187
|
-
requireUppercase: true,
|
|
188
|
-
requireNumber: true,
|
|
189
|
-
requireSpecialChar: true,
|
|
190
|
-
},
|
|
191
|
-
}
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
### Rate Limiting
|
|
195
|
-
```typescript
|
|
196
|
-
import { rateLimit } from 'better-auth/plugins/rate-limit'
|
|
197
|
-
|
|
198
|
-
plugins: [
|
|
199
|
-
rateLimit({
|
|
200
|
-
window: 60, // 1 minute
|
|
201
|
-
max: 10, // 10 requests
|
|
202
|
-
endpoints: {
|
|
203
|
-
'sign-in': { window: 300, max: 5 },
|
|
204
|
-
'sign-up': { window: 3600, max: 3 },
|
|
205
|
-
},
|
|
206
|
-
}),
|
|
207
|
-
]
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
### Session Security
|
|
211
|
-
```typescript
|
|
212
|
-
session: {
|
|
213
|
-
expiresIn: 60 * 60 * 24 * 7, // 7 days
|
|
214
|
-
updateAge: 60 * 60 * 24, // Extend daily
|
|
215
|
-
cookieCache: {
|
|
216
|
-
enabled: true,
|
|
217
|
-
maxAge: 60 * 5, // Cache for 5 minutes
|
|
218
|
-
},
|
|
219
|
-
// Require re-auth for sensitive operations
|
|
220
|
-
freshAge: 60 * 10, // 10 minutes
|
|
221
|
-
}
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
## Enterprise Patterns
|
|
225
|
-
|
|
226
|
-
### Multi-Tenancy
|
|
227
|
-
```typescript
|
|
228
|
-
import { organization } from 'better-auth/plugins/organization'
|
|
229
|
-
|
|
230
|
-
plugins: [
|
|
231
|
-
organization({
|
|
232
|
-
roles: ['owner', 'admin', 'member'],
|
|
233
|
-
permissions: {
|
|
234
|
-
owner: ['*'],
|
|
235
|
-
admin: ['read', 'write', 'invite'],
|
|
236
|
-
member: ['read'],
|
|
237
|
-
},
|
|
238
|
-
inviteOnly: true,
|
|
239
|
-
maxOrganizations: 5,
|
|
240
|
-
}),
|
|
241
|
-
]
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
### SSO with SAML
|
|
245
|
-
```typescript
|
|
246
|
-
import { samlSSO } from 'better-auth/plugins/saml'
|
|
247
|
-
|
|
248
|
-
plugins: [
|
|
249
|
-
samlSSO({
|
|
250
|
-
certificate: process.env.SAML_CERTIFICATE,
|
|
251
|
-
privateKey: process.env.SAML_PRIVATE_KEY,
|
|
252
|
-
issuer: 'https://myapp.com',
|
|
253
|
-
callbackUrl: 'https://myapp.com/auth/saml/callback',
|
|
254
|
-
}),
|
|
255
|
-
]
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
## Design Deliverables
|
|
259
|
-
|
|
260
|
-
When designing auth architecture, provide:
|
|
261
|
-
|
|
262
|
-
1. **Auth Configuration** - Complete Better Auth config
|
|
263
|
-
2. **Provider Setup** - Social provider configurations
|
|
264
|
-
3. **Route Structure** - Protected and public routes
|
|
265
|
-
4. **Component Hierarchy** - Auth forms and flows
|
|
266
|
-
5. **Security Measures** - Rate limiting, 2FA, session config
|
|
267
|
-
6. **Database Schema** - Auth-related tables
|
|
268
|
-
|
|
269
|
-
## Questions to Ask
|
|
270
|
-
|
|
271
|
-
Before designing, clarify:
|
|
272
|
-
|
|
273
|
-
1. What authentication methods are needed? (email, social, SSO)
|
|
274
|
-
2. Is 2FA or passkey support required?
|
|
275
|
-
3. Multi-tenancy or organization support?
|
|
276
|
-
4. Session duration and refresh strategy?
|
|
277
|
-
5. Email verification requirements?
|
|
278
|
-
6. Password policy requirements?
|
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: auth-provider-add
|
|
3
|
-
description: Add a new authentication provider to Better Auth
|
|
4
|
-
args:
|
|
5
|
-
- name: provider
|
|
6
|
-
description: Provider name (google, github, discord, apple, microsoft, etc.)
|
|
7
|
-
required: false
|
|
8
|
-
- name: scopes
|
|
9
|
-
description: Comma-separated OAuth scopes (e.g., "user:email,read:org")
|
|
10
|
-
required: false
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
# Add Authentication Provider
|
|
14
|
-
|
|
15
|
-
Add a new social/OAuth provider to your Better Auth configuration.
|
|
16
|
-
|
|
17
|
-
## Supported Providers
|
|
18
|
-
|
|
19
|
-
- **google** - Google OAuth 2.0
|
|
20
|
-
- **github** - GitHub OAuth
|
|
21
|
-
- **discord** - Discord OAuth
|
|
22
|
-
- **apple** - Apple Sign In
|
|
23
|
-
- **microsoft** - Microsoft Identity
|
|
24
|
-
- **twitter** - Twitter/X OAuth 2.0
|
|
25
|
-
- **facebook** - Facebook Login
|
|
26
|
-
- **linkedin** - LinkedIn OAuth
|
|
27
|
-
- **gitlab** - GitLab OAuth
|
|
28
|
-
- **slack** - Slack OAuth
|
|
29
|
-
|
|
30
|
-
## Instructions
|
|
31
|
-
|
|
32
|
-
1. **Get Provider Credentials**:
|
|
33
|
-
|
|
34
|
-
**Google**:
|
|
35
|
-
- Go to [Google Cloud Console](https://console.cloud.google.com/)
|
|
36
|
-
- Create OAuth 2.0 credentials
|
|
37
|
-
- Add authorized redirect URI: `{YOUR_API_URL}/api/auth/callback/google`
|
|
38
|
-
|
|
39
|
-
**GitHub**:
|
|
40
|
-
- Go to [GitHub Developer Settings](https://github.com/settings/developers)
|
|
41
|
-
- Create new OAuth App
|
|
42
|
-
- Set callback URL: `{YOUR_API_URL}/api/auth/callback/github`
|
|
43
|
-
|
|
44
|
-
**Discord**:
|
|
45
|
-
- Go to [Discord Developer Portal](https://discord.com/developers/applications)
|
|
46
|
-
- Create application, get OAuth2 credentials
|
|
47
|
-
- Add redirect: `{YOUR_API_URL}/api/auth/callback/discord`
|
|
48
|
-
|
|
49
|
-
**Apple**:
|
|
50
|
-
- Go to [Apple Developer](https://developer.apple.com/)
|
|
51
|
-
- Create Service ID with Sign In with Apple capability
|
|
52
|
-
- Configure return URL: `{YOUR_API_URL}/api/auth/callback/apple`
|
|
53
|
-
|
|
54
|
-
**Microsoft**:
|
|
55
|
-
- Go to [Azure Portal](https://portal.azure.com/)
|
|
56
|
-
- Register application in Azure AD
|
|
57
|
-
- Add redirect URI: `{YOUR_API_URL}/api/auth/callback/microsoft`
|
|
58
|
-
|
|
59
|
-
2. **Add Environment Variables** to `.env`:
|
|
60
|
-
```bash
|
|
61
|
-
# Google
|
|
62
|
-
GOOGLE_CLIENT_ID=your-client-id
|
|
63
|
-
GOOGLE_CLIENT_SECRET=your-client-secret
|
|
64
|
-
|
|
65
|
-
# GitHub
|
|
66
|
-
GITHUB_CLIENT_ID=your-client-id
|
|
67
|
-
GITHUB_CLIENT_SECRET=your-client-secret
|
|
68
|
-
|
|
69
|
-
# Discord
|
|
70
|
-
DISCORD_CLIENT_ID=your-client-id
|
|
71
|
-
DISCORD_CLIENT_SECRET=your-client-secret
|
|
72
|
-
|
|
73
|
-
# Apple
|
|
74
|
-
APPLE_CLIENT_ID=your-service-id
|
|
75
|
-
APPLE_CLIENT_SECRET=your-client-secret
|
|
76
|
-
APPLE_TEAM_ID=your-team-id
|
|
77
|
-
APPLE_KEY_ID=your-key-id
|
|
78
|
-
|
|
79
|
-
# Microsoft
|
|
80
|
-
MICROSOFT_CLIENT_ID=your-client-id
|
|
81
|
-
MICROSOFT_CLIENT_SECRET=your-client-secret
|
|
82
|
-
MICROSOFT_TENANT_ID=your-tenant-id
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
3. **Update Server Configuration** in `src/lib/auth.ts`:
|
|
86
|
-
|
|
87
|
-
**Google**:
|
|
88
|
-
```typescript
|
|
89
|
-
socialProviders: {
|
|
90
|
-
google: {
|
|
91
|
-
clientId: process.env.GOOGLE_CLIENT_ID!,
|
|
92
|
-
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
|
|
93
|
-
scopes: ['email', 'profile'],
|
|
94
|
-
// Optional: Force account selection
|
|
95
|
-
prompt: 'select_account',
|
|
96
|
-
},
|
|
97
|
-
}
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
**GitHub**:
|
|
101
|
-
```typescript
|
|
102
|
-
socialProviders: {
|
|
103
|
-
github: {
|
|
104
|
-
clientId: process.env.GITHUB_CLIENT_ID!,
|
|
105
|
-
clientSecret: process.env.GITHUB_CLIENT_SECRET!,
|
|
106
|
-
scopes: ['user:email', 'read:user'],
|
|
107
|
-
// Optional: Request additional scopes
|
|
108
|
-
// scopes: ['user:email', 'read:user', 'read:org'],
|
|
109
|
-
},
|
|
110
|
-
}
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
**Discord**:
|
|
114
|
-
```typescript
|
|
115
|
-
socialProviders: {
|
|
116
|
-
discord: {
|
|
117
|
-
clientId: process.env.DISCORD_CLIENT_ID!,
|
|
118
|
-
clientSecret: process.env.DISCORD_CLIENT_SECRET!,
|
|
119
|
-
scopes: ['identify', 'email'],
|
|
120
|
-
// Optional: Guild-specific
|
|
121
|
-
// scopes: ['identify', 'email', 'guilds'],
|
|
122
|
-
},
|
|
123
|
-
}
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
**Apple**:
|
|
127
|
-
```typescript
|
|
128
|
-
socialProviders: {
|
|
129
|
-
apple: {
|
|
130
|
-
clientId: process.env.APPLE_CLIENT_ID!,
|
|
131
|
-
clientSecret: process.env.APPLE_CLIENT_SECRET!,
|
|
132
|
-
teamId: process.env.APPLE_TEAM_ID!,
|
|
133
|
-
keyId: process.env.APPLE_KEY_ID!,
|
|
134
|
-
},
|
|
135
|
-
}
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
**Microsoft**:
|
|
139
|
-
```typescript
|
|
140
|
-
socialProviders: {
|
|
141
|
-
microsoft: {
|
|
142
|
-
clientId: process.env.MICROSOFT_CLIENT_ID!,
|
|
143
|
-
clientSecret: process.env.MICROSOFT_CLIENT_SECRET!,
|
|
144
|
-
tenantId: process.env.MICROSOFT_TENANT_ID!, // or 'common' for multi-tenant
|
|
145
|
-
scopes: ['openid', 'profile', 'email'],
|
|
146
|
-
},
|
|
147
|
-
}
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
4. **Update Auth Client** in `src/auth/client.ts`:
|
|
151
|
-
```typescript
|
|
152
|
-
export const {
|
|
153
|
-
// ... existing exports
|
|
154
|
-
signInWithGoogle,
|
|
155
|
-
signInWithGithub,
|
|
156
|
-
signInWithDiscord,
|
|
157
|
-
signInWithApple,
|
|
158
|
-
signInWithMicrosoft,
|
|
159
|
-
} = authClient
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
5. **Create/Update Social Login Buttons** in `src/features/auth/components/SocialLoginButtons.tsx`:
|
|
163
|
-
```typescript
|
|
164
|
-
import {
|
|
165
|
-
signInWithGoogle,
|
|
166
|
-
signInWithGithub,
|
|
167
|
-
signInWithDiscord,
|
|
168
|
-
} from '@/auth/client'
|
|
169
|
-
|
|
170
|
-
interface SocialLoginButtonsProps {
|
|
171
|
-
callbackURL?: string
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
export function SocialLoginButtons({ callbackURL = '/dashboard' }: SocialLoginButtonsProps) {
|
|
175
|
-
const handleGoogle = async () => {
|
|
176
|
-
await signInWithGoogle({ callbackURL })
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
const handleGithub = async () => {
|
|
180
|
-
await signInWithGithub({ callbackURL })
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
const handleDiscord = async () => {
|
|
184
|
-
await signInWithDiscord({ callbackURL })
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
return (
|
|
188
|
-
<div className="flex flex-col gap-3">
|
|
189
|
-
<button
|
|
190
|
-
onClick={handleGoogle}
|
|
191
|
-
className="flex items-center justify-center gap-2 w-full p-3 border rounded-lg hover:bg-gray-50"
|
|
192
|
-
>
|
|
193
|
-
<svg className="w-5 h-5" viewBox="0 0 24 24">
|
|
194
|
-
{/* Google icon SVG */}
|
|
195
|
-
</svg>
|
|
196
|
-
Continue with Google
|
|
197
|
-
</button>
|
|
198
|
-
|
|
199
|
-
<button
|
|
200
|
-
onClick={handleGithub}
|
|
201
|
-
className="flex items-center justify-center gap-2 w-full p-3 border rounded-lg hover:bg-gray-50"
|
|
202
|
-
>
|
|
203
|
-
<svg className="w-5 h-5" viewBox="0 0 24 24">
|
|
204
|
-
{/* GitHub icon SVG */}
|
|
205
|
-
</svg>
|
|
206
|
-
Continue with GitHub
|
|
207
|
-
</button>
|
|
208
|
-
|
|
209
|
-
<button
|
|
210
|
-
onClick={handleDiscord}
|
|
211
|
-
className="flex items-center justify-center gap-2 w-full p-3 border rounded-lg hover:bg-gray-50"
|
|
212
|
-
>
|
|
213
|
-
<svg className="w-5 h-5" viewBox="0 0 24 24">
|
|
214
|
-
{/* Discord icon SVG */}
|
|
215
|
-
</svg>
|
|
216
|
-
Continue with Discord
|
|
217
|
-
</button>
|
|
218
|
-
</div>
|
|
219
|
-
)
|
|
220
|
-
}
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
6. **Handle Provider Callback** (if custom handling needed):
|
|
224
|
-
```typescript
|
|
225
|
-
// In your server/API routes
|
|
226
|
-
export const auth = betterAuth({
|
|
227
|
-
socialProviders: {
|
|
228
|
-
google: {
|
|
229
|
-
// ...config
|
|
230
|
-
onUserCreated: async (user, account) => {
|
|
231
|
-
// Custom logic when user signs up via Google
|
|
232
|
-
await sendWelcomeEmail(user.email)
|
|
233
|
-
},
|
|
234
|
-
onSignIn: async (user, account) => {
|
|
235
|
-
// Custom logic on each sign in
|
|
236
|
-
await updateLastLogin(user.id)
|
|
237
|
-
},
|
|
238
|
-
},
|
|
239
|
-
},
|
|
240
|
-
})
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
## Common Scopes Reference
|
|
244
|
-
|
|
245
|
-
| Provider | Common Scopes |
|
|
246
|
-
|----------|--------------|
|
|
247
|
-
| Google | `email`, `profile`, `openid` |
|
|
248
|
-
| GitHub | `user:email`, `read:user`, `read:org` |
|
|
249
|
-
| Discord | `identify`, `email`, `guilds` |
|
|
250
|
-
| Apple | (automatic: email, name) |
|
|
251
|
-
| Microsoft | `openid`, `profile`, `email`, `User.Read` |
|
|
252
|
-
| Twitter | `users.read`, `tweet.read` |
|
|
253
|
-
| Facebook | `email`, `public_profile` |
|
|
254
|
-
| LinkedIn | `r_emailaddress`, `r_liteprofile` |
|
|
255
|
-
|
|
256
|
-
## Quality Checklist
|
|
257
|
-
|
|
258
|
-
- [ ] Provider credentials obtained from developer portal
|
|
259
|
-
- [ ] Environment variables added to `.env`
|
|
260
|
-
- [ ] Callback URL configured in provider dashboard
|
|
261
|
-
- [ ] Provider added to `socialProviders` config
|
|
262
|
-
- [ ] Client export added for `signInWith{Provider}`
|
|
263
|
-
- [ ] Button added to SocialLoginButtons component
|
|
264
|
-
- [ ] Scopes appropriate for app needs
|
|
265
|
-
- [ ] Tested sign-in flow works correctly
|