@l4yercak3/cli 1.0.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/.claude/settings.local.json +18 -0
- package/.cursor/rules.md +203 -0
- package/.eslintrc.js +31 -0
- package/README.md +227 -0
- package/bin/cli.js +61 -0
- package/docs/ADDING_NEW_PROJECT_TYPE.md +156 -0
- package/docs/ARCHITECTURE_RELATIONSHIPS.md +411 -0
- package/docs/CLI_AUTHENTICATION.md +214 -0
- package/docs/DETECTOR_ARCHITECTURE.md +326 -0
- package/docs/DEVELOPMENT.md +194 -0
- package/docs/IMPLEMENTATION_PHASES.md +468 -0
- package/docs/OAUTH_CLARIFICATION.md +258 -0
- package/docs/OAUTH_SETUP_GUIDE_TEMPLATE.md +211 -0
- package/docs/PHASE_0_PROGRESS.md +120 -0
- package/docs/PHASE_1_COMPLETE.md +366 -0
- package/docs/PHASE_SUMMARY.md +149 -0
- package/docs/PLAN.md +511 -0
- package/docs/README.md +56 -0
- package/docs/STRIPE_INTEGRATION.md +447 -0
- package/docs/SUMMARY.md +230 -0
- package/docs/UPDATED_PLAN.md +447 -0
- package/package.json +53 -0
- package/src/api/backend-client.js +148 -0
- package/src/commands/login.js +146 -0
- package/src/commands/logout.js +24 -0
- package/src/commands/spread.js +364 -0
- package/src/commands/status.js +62 -0
- package/src/config/config-manager.js +205 -0
- package/src/detectors/api-client-detector.js +85 -0
- package/src/detectors/base-detector.js +77 -0
- package/src/detectors/github-detector.js +74 -0
- package/src/detectors/index.js +80 -0
- package/src/detectors/nextjs-detector.js +139 -0
- package/src/detectors/oauth-detector.js +122 -0
- package/src/detectors/registry.js +97 -0
- package/src/generators/api-client-generator.js +197 -0
- package/src/generators/env-generator.js +162 -0
- package/src/generators/gitignore-generator.js +92 -0
- package/src/generators/index.js +50 -0
- package/src/generators/nextauth-generator.js +242 -0
- package/src/generators/oauth-guide-generator.js +277 -0
- package/src/logo.js +116 -0
- package/tests/api-client-detector.test.js +214 -0
- package/tests/api-client-generator.test.js +169 -0
- package/tests/backend-client.test.js +361 -0
- package/tests/base-detector.test.js +101 -0
- package/tests/commands/login.test.js +98 -0
- package/tests/commands/logout.test.js +70 -0
- package/tests/commands/status.test.js +167 -0
- package/tests/config-manager.test.js +313 -0
- package/tests/detector-index.test.js +209 -0
- package/tests/detector-registry.test.js +93 -0
- package/tests/env-generator.test.js +278 -0
- package/tests/generators-index.test.js +215 -0
- package/tests/github-detector.test.js +145 -0
- package/tests/gitignore-generator.test.js +109 -0
- package/tests/logo.test.js +96 -0
- package/tests/nextauth-generator.test.js +231 -0
- package/tests/nextjs-detector.test.js +235 -0
- package/tests/oauth-detector.test.js +264 -0
- package/tests/oauth-guide-generator.test.js +273 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
# OAuth Automation & CLI Onboarding - Clarification
|
|
2
|
+
|
|
3
|
+
## Two Different OAuth Systems
|
|
4
|
+
|
|
5
|
+
### 1. **Backend OAuth (Platform OAuth)** ✅ Already Exists
|
|
6
|
+
**Purpose:** Platform administrators/staff connecting their Microsoft/Google accounts to the backend
|
|
7
|
+
- **Use Case:** Staff members sync their Microsoft 365 account to send emails, access calendars, etc.
|
|
8
|
+
- **Storage:** `users` table + `oauthConnections` table
|
|
9
|
+
- **Handler:** Convex backend (`convex/oauth/microsoft.ts`)
|
|
10
|
+
- **Status:** ✅ Fully implemented
|
|
11
|
+
|
|
12
|
+
**This is NOT what we're automating with the CLI.**
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
### 2. **Frontend OAuth (Customer OAuth)** 🎯 What We're Automating
|
|
17
|
+
**Purpose:** End users (customers/freelancers) logging into FRONTEND applications
|
|
18
|
+
- **Use Case:** Freelancers log into the freelancer portal with Google/Microsoft
|
|
19
|
+
- **Storage:** `objects` table with `type: "frontend_user"`
|
|
20
|
+
- **Handler:** NextAuth.js on the frontend + Backend sync endpoint
|
|
21
|
+
- **Status:** Backend ready, frontend needs OAuth app setup
|
|
22
|
+
|
|
23
|
+
**This IS what we want to automate with the CLI.**
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## The OAuth App Setup Problem
|
|
28
|
+
|
|
29
|
+
When a developer wants to add OAuth login to their frontend app, they currently need to:
|
|
30
|
+
|
|
31
|
+
1. **Go to Google Cloud Console**
|
|
32
|
+
- Create OAuth client ID
|
|
33
|
+
- Configure redirect URIs
|
|
34
|
+
- Copy Client ID and Secret
|
|
35
|
+
|
|
36
|
+
2. **Go to Microsoft Azure Portal**
|
|
37
|
+
- Register application
|
|
38
|
+
- Configure redirect URIs
|
|
39
|
+
- Create client secret
|
|
40
|
+
- Copy Client ID, Secret, and Tenant ID
|
|
41
|
+
|
|
42
|
+
3. **Add to `.env.local`**
|
|
43
|
+
```bash
|
|
44
|
+
GOOGLE_CLIENT_ID=...
|
|
45
|
+
GOOGLE_CLIENT_SECRET=...
|
|
46
|
+
AZURE_CLIENT_ID=...
|
|
47
|
+
AZURE_CLIENT_SECRET=...
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**This is manual, tedious, and error-prone.**
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## OAuth Automation Goal
|
|
55
|
+
|
|
56
|
+
**Automate steps 1-2 above** by using provider APIs to create OAuth apps programmatically.
|
|
57
|
+
|
|
58
|
+
### What We Can Automate
|
|
59
|
+
|
|
60
|
+
#### Google OAuth
|
|
61
|
+
- **API:** Google Cloud API
|
|
62
|
+
- **Can Create:** OAuth client IDs programmatically
|
|
63
|
+
- **Requires:** Google Cloud project access (user grants permission)
|
|
64
|
+
- **Result:** Client ID and Secret automatically generated
|
|
65
|
+
|
|
66
|
+
#### Microsoft OAuth
|
|
67
|
+
- **API:** Microsoft Graph API / Azure AD API
|
|
68
|
+
- **Can Create:** App registrations programmatically
|
|
69
|
+
- **Requires:** Azure AD admin access (user grants permission)
|
|
70
|
+
- **Result:** Client ID, Secret, Tenant ID automatically generated
|
|
71
|
+
|
|
72
|
+
#### GitHub OAuth
|
|
73
|
+
- **API:** GitHub API
|
|
74
|
+
- **Can Create:** OAuth apps programmatically
|
|
75
|
+
- **Requires:** GitHub account access
|
|
76
|
+
- **Result:** Client ID and Secret automatically generated
|
|
77
|
+
|
|
78
|
+
### What We Still Need User Input For
|
|
79
|
+
|
|
80
|
+
- **User's Google Cloud Project** (or create one)
|
|
81
|
+
- **User's Azure AD Tenant** (or use default)
|
|
82
|
+
- **User's GitHub Account** (for GitHub OAuth)
|
|
83
|
+
- **Permission to create OAuth apps** (one-time grant)
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## CLI-Based Onboarding Flow
|
|
88
|
+
|
|
89
|
+
### Complete Onboarding via CLI 🚀
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
1. Developer runs: npx @l4yercak3/cli spread
|
|
93
|
+
↓
|
|
94
|
+
2. CLI asks: "Do you have an account?"
|
|
95
|
+
- [ ] Yes, I'll log in
|
|
96
|
+
- [ ] No, create one for me
|
|
97
|
+
↓
|
|
98
|
+
3. If "No":
|
|
99
|
+
- CLI asks for email, name, organization name
|
|
100
|
+
- CLI calls backend: POST /api/v1/auth/create-account
|
|
101
|
+
- Backend creates:
|
|
102
|
+
- User account
|
|
103
|
+
- Organization
|
|
104
|
+
- Initial API key
|
|
105
|
+
- CLI stores session token
|
|
106
|
+
↓
|
|
107
|
+
4. CLI asks: "What features do you want?"
|
|
108
|
+
- [ ] CRM Integration
|
|
109
|
+
- [ ] OAuth Login (Google/Microsoft)
|
|
110
|
+
- [ ] Project Management
|
|
111
|
+
- [ ] Invoicing
|
|
112
|
+
↓
|
|
113
|
+
5. If OAuth selected:
|
|
114
|
+
- CLI asks: "Which providers?"
|
|
115
|
+
- [ ] Google
|
|
116
|
+
- [ ] Microsoft
|
|
117
|
+
- [ ] GitHub
|
|
118
|
+
- CLI opens browser for OAuth app creation
|
|
119
|
+
- User grants permission once
|
|
120
|
+
- CLI creates OAuth apps automatically
|
|
121
|
+
- CLI stores credentials securely
|
|
122
|
+
↓
|
|
123
|
+
6. CLI generates:
|
|
124
|
+
- API client code
|
|
125
|
+
- Environment files (with OAuth credentials pre-filled!)
|
|
126
|
+
- NextAuth.js configuration
|
|
127
|
+
- Type definitions
|
|
128
|
+
↓
|
|
129
|
+
7. Integration complete! 🎉
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Schema Endpoint Security Clarification
|
|
135
|
+
|
|
136
|
+
### What a Schema Endpoint Would Return
|
|
137
|
+
|
|
138
|
+
**NOT database access!** Just API structure/types:
|
|
139
|
+
|
|
140
|
+
```json
|
|
141
|
+
{
|
|
142
|
+
"endpoints": {
|
|
143
|
+
"/api/v1/crm/contacts": {
|
|
144
|
+
"method": "POST",
|
|
145
|
+
"request": {
|
|
146
|
+
"type": "object",
|
|
147
|
+
"properties": {
|
|
148
|
+
"firstName": { "type": "string" },
|
|
149
|
+
"lastName": { "type": "string" },
|
|
150
|
+
"email": { "type": "string" }
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
"response": {
|
|
154
|
+
"type": "object",
|
|
155
|
+
"properties": {
|
|
156
|
+
"_id": { "type": "string" },
|
|
157
|
+
"name": { "type": "string" },
|
|
158
|
+
"email": { "type": "string" }
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**This is just documentation/structure** - no actual data, no database access.
|
|
167
|
+
|
|
168
|
+
### Security Considerations
|
|
169
|
+
|
|
170
|
+
1. **Authentication Required:** Schema endpoint should require API key or session
|
|
171
|
+
2. **Read-Only:** Only returns API structure, never actual data
|
|
172
|
+
3. **Rate Limited:** Prevent abuse
|
|
173
|
+
4. **Scoped:** Only show endpoints user has access to
|
|
174
|
+
|
|
175
|
+
**It's like an OpenAPI spec** - just describes the API, doesn't access the database.
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## Updated CLI Onboarding Features
|
|
180
|
+
|
|
181
|
+
### Account Creation via CLI
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
npx @l4yercak3/cli spread
|
|
185
|
+
|
|
186
|
+
# If no account:
|
|
187
|
+
? Create new account? (y/n) y
|
|
188
|
+
? Email: user@example.com
|
|
189
|
+
? Name: John Doe
|
|
190
|
+
? Organization Name: Acme Corp
|
|
191
|
+
✅ Account created! Organization ID: org_123
|
|
192
|
+
✅ API key generated: l4y_abc123...
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**Backend Endpoint Needed:**
|
|
196
|
+
```typescript
|
|
197
|
+
POST /api/v1/auth/create-account
|
|
198
|
+
Body: {
|
|
199
|
+
email: string;
|
|
200
|
+
name: string;
|
|
201
|
+
organizationName: string;
|
|
202
|
+
}
|
|
203
|
+
Response: {
|
|
204
|
+
userId: string;
|
|
205
|
+
organizationId: string;
|
|
206
|
+
apiKey: string;
|
|
207
|
+
sessionToken: string;
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### OAuth App Creation via CLI
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
? Enable OAuth login? (y/n) y
|
|
215
|
+
? Which providers? [Google, Microsoft]
|
|
216
|
+
? Grant permission to create OAuth apps? (opens browser)
|
|
217
|
+
✅ Google OAuth app created!
|
|
218
|
+
Client ID: 123456.apps.googleusercontent.com
|
|
219
|
+
Client Secret: GOCSPX-abc123...
|
|
220
|
+
✅ Microsoft OAuth app created!
|
|
221
|
+
Client ID: abcd-1234-...
|
|
222
|
+
Client Secret: xyz~ABC...
|
|
223
|
+
✅ Credentials saved to .env.local
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
**This requires:**
|
|
227
|
+
1. User grants CLI permission to create OAuth apps (one-time)
|
|
228
|
+
2. CLI uses provider APIs to create apps
|
|
229
|
+
3. CLI stores credentials securely
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## Summary
|
|
234
|
+
|
|
235
|
+
### What We're Automating
|
|
236
|
+
|
|
237
|
+
1. ✅ **Account Creation** - Create user account + organization via CLI
|
|
238
|
+
2. ✅ **API Key Generation** - Generate API keys automatically
|
|
239
|
+
3. ✅ **OAuth App Creation** - Create OAuth apps with Google/Microsoft/GitHub APIs
|
|
240
|
+
4. ✅ **Environment Setup** - Generate `.env.local` with all credentials
|
|
241
|
+
5. ✅ **Code Generation** - Generate API client, NextAuth config, types
|
|
242
|
+
|
|
243
|
+
### What We're NOT Automating
|
|
244
|
+
|
|
245
|
+
- ❌ Backend OAuth (platform OAuth) - that's separate
|
|
246
|
+
- ❌ Database access - schema endpoint is read-only API structure
|
|
247
|
+
- ❌ User's provider accounts - they still need Google/Microsoft/GitHub accounts
|
|
248
|
+
|
|
249
|
+
### Security Notes
|
|
250
|
+
|
|
251
|
+
- **Schema Endpoint:** Read-only API structure, requires auth, no database access
|
|
252
|
+
- **OAuth Automation:** Requires user permission, one-time grant
|
|
253
|
+
- **Account Creation:** Secure endpoint, creates proper user/org structure
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
**The goal:** Make onboarding as smooth as possible, with UI as fallback if CLI fails or user gets stuck.
|
|
258
|
+
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# OAuth Setup Guide - Template
|
|
2
|
+
|
|
3
|
+
This is a template for the OAuth setup guide that the CLI will generate. It will be customized based on the user's provider choices.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# 🔐 OAuth Authentication Setup Guide
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
This guide will walk you through setting up OAuth authentication for your frontend application. You'll need to create OAuth apps with each provider and add the credentials to your `.env.local` file.
|
|
12
|
+
|
|
13
|
+
**Estimated Time:** 15-20 minutes per provider
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## ✅ Setup Checklist
|
|
18
|
+
|
|
19
|
+
- [ ] Google OAuth setup
|
|
20
|
+
- [ ] Microsoft OAuth setup
|
|
21
|
+
- [ ] GitHub OAuth setup (if selected)
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 1. Google OAuth Setup
|
|
26
|
+
|
|
27
|
+
### Step 1: Go to Google Cloud Console
|
|
28
|
+
|
|
29
|
+
1. Navigate to: https://console.cloud.google.com/
|
|
30
|
+
2. Select your project or create a new one
|
|
31
|
+
|
|
32
|
+
### Step 2: Enable Google+ API
|
|
33
|
+
|
|
34
|
+
1. Go to "APIs & Services" → "Enable APIs and Services"
|
|
35
|
+
2. Search for "Google+ API" and enable it
|
|
36
|
+
|
|
37
|
+
### Step 3: Create OAuth Client ID
|
|
38
|
+
|
|
39
|
+
1. Go to "APIs & Services" → "Credentials"
|
|
40
|
+
2. Click "Create Credentials" → "OAuth client ID"
|
|
41
|
+
3. Application type: **Web application**
|
|
42
|
+
4. Name: `{{APP_NAME}} - Frontend`
|
|
43
|
+
|
|
44
|
+
### Step 4: Configure Redirect URIs
|
|
45
|
+
|
|
46
|
+
Add these redirect URIs:
|
|
47
|
+
|
|
48
|
+
**Production:**
|
|
49
|
+
```
|
|
50
|
+
https://{{PRODUCTION_DOMAIN}}/api/auth/callback/google
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Development:**
|
|
54
|
+
```
|
|
55
|
+
http://localhost:3000/api/auth/callback/google
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Step 5: Save Credentials
|
|
59
|
+
|
|
60
|
+
1. Copy the **Client ID** and **Client Secret**
|
|
61
|
+
2. Add them to your `.env.local` file (see below)
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## 2. Microsoft Entra ID (Azure AD) Setup
|
|
66
|
+
|
|
67
|
+
### Step 1: Go to Azure Portal
|
|
68
|
+
|
|
69
|
+
1. Navigate to: https://portal.azure.com/
|
|
70
|
+
2. Go to "Microsoft Entra ID" (formerly Azure AD)
|
|
71
|
+
|
|
72
|
+
### Step 2: Register Application
|
|
73
|
+
|
|
74
|
+
1. Go to "App registrations" → "New registration"
|
|
75
|
+
2. Name: `{{APP_NAME}} - Frontend`
|
|
76
|
+
3. Supported account types: Choose based on your needs
|
|
77
|
+
4. Redirect URI: **Web**
|
|
78
|
+
|
|
79
|
+
### Step 3: Configure Redirect URIs
|
|
80
|
+
|
|
81
|
+
Add these redirect URIs:
|
|
82
|
+
|
|
83
|
+
**Production:**
|
|
84
|
+
```
|
|
85
|
+
https://{{PRODUCTION_DOMAIN}}/api/auth/callback/azure-ad
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**Development:**
|
|
89
|
+
```
|
|
90
|
+
http://localhost:3000/api/auth/callback/azure-ad
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Step 4: Create Client Secret
|
|
94
|
+
|
|
95
|
+
1. Go to "Certificates & secrets" → "New client secret"
|
|
96
|
+
2. Description: `Frontend OAuth Secret`
|
|
97
|
+
3. Expires: Choose expiration (recommend 24 months)
|
|
98
|
+
4. Copy the **Value** (not the Secret ID) - you won't see it again!
|
|
99
|
+
|
|
100
|
+
### Step 5: Save Credentials
|
|
101
|
+
|
|
102
|
+
1. Copy the **Application (client) ID**, **Directory (tenant) ID**, and **Client Secret Value**
|
|
103
|
+
2. Add them to your `.env.local` file (see below)
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## 3. GitHub OAuth Setup
|
|
108
|
+
|
|
109
|
+
### Step 1: Go to GitHub Developer Settings
|
|
110
|
+
|
|
111
|
+
1. Navigate to: https://github.com/settings/developers
|
|
112
|
+
2. Click "New OAuth App"
|
|
113
|
+
|
|
114
|
+
### Step 2: Create OAuth App
|
|
115
|
+
|
|
116
|
+
1. **Application name:** `{{APP_NAME}} - Frontend`
|
|
117
|
+
2. **Homepage URL:** `https://{{PRODUCTION_DOMAIN}}`
|
|
118
|
+
3. **Authorization callback URL:**
|
|
119
|
+
```
|
|
120
|
+
https://{{PRODUCTION_DOMAIN}}/api/auth/callback/github
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Step 3: Save Credentials
|
|
124
|
+
|
|
125
|
+
1. Copy the **Client ID**
|
|
126
|
+
2. Click "Generate a new client secret"
|
|
127
|
+
3. Copy the **Client Secret** (you won't see it again!)
|
|
128
|
+
4. Add them to your `.env.local` file (see below)
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## 4. Update Environment Variables
|
|
133
|
+
|
|
134
|
+
Add these to your `.env.local` file:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
# Google OAuth
|
|
138
|
+
GOOGLE_CLIENT_ID=your_google_client_id_here
|
|
139
|
+
GOOGLE_CLIENT_SECRET=your_google_client_secret_here
|
|
140
|
+
|
|
141
|
+
# Microsoft OAuth
|
|
142
|
+
AZURE_CLIENT_ID=your_azure_client_id_here
|
|
143
|
+
AZURE_CLIENT_SECRET=your_azure_client_secret_value_here
|
|
144
|
+
AZURE_TENANT_ID=your_azure_tenant_id_here
|
|
145
|
+
|
|
146
|
+
# GitHub OAuth (if using)
|
|
147
|
+
GITHUB_CLIENT_ID=your_github_client_id_here
|
|
148
|
+
GITHUB_CLIENT_SECRET=your_github_client_secret_here
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
**⚠️ Important:** Never commit `.env.local` to git! It's already in `.gitignore`.
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## 5. Test Your Setup
|
|
156
|
+
|
|
157
|
+
1. Start your development server: `npm run dev`
|
|
158
|
+
2. Navigate to: `http://localhost:3000/auth/signin`
|
|
159
|
+
3. Try signing in with each provider
|
|
160
|
+
4. Verify that users are created in your backend
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Troubleshooting
|
|
165
|
+
|
|
166
|
+
### Redirect URI Mismatch
|
|
167
|
+
|
|
168
|
+
**Error:** "Redirect URI mismatch"
|
|
169
|
+
|
|
170
|
+
**Solution:** Make sure the redirect URI in your OAuth app matches exactly:
|
|
171
|
+
- Check for trailing slashes
|
|
172
|
+
- Check http vs https
|
|
173
|
+
- Check localhost vs 127.0.0.1
|
|
174
|
+
|
|
175
|
+
### Invalid Client Secret
|
|
176
|
+
|
|
177
|
+
**Error:** "Invalid client secret"
|
|
178
|
+
|
|
179
|
+
**Solution:**
|
|
180
|
+
- Make sure you copied the **Value** (not Secret ID) for Azure
|
|
181
|
+
- Regenerate the secret if needed
|
|
182
|
+
- Restart your dev server after updating `.env.local`
|
|
183
|
+
|
|
184
|
+
### Provider Not Found
|
|
185
|
+
|
|
186
|
+
**Error:** "Provider not found"
|
|
187
|
+
|
|
188
|
+
**Solution:**
|
|
189
|
+
- Check that the provider is configured in `app/api/auth/[...nextauth]/route.ts`
|
|
190
|
+
- Verify environment variables are set correctly
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## Next Steps
|
|
195
|
+
|
|
196
|
+
Once OAuth is set up:
|
|
197
|
+
1. ✅ Users can sign in with their Google/Microsoft/GitHub accounts
|
|
198
|
+
2. ✅ User accounts are automatically created in your backend
|
|
199
|
+
3. ✅ Users are linked to CRM contacts
|
|
200
|
+
4. ✅ You can use protected routes and API calls
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## Video Tutorial
|
|
205
|
+
|
|
206
|
+
📹 **Coming Soon:** Step-by-step video tutorial for OAuth setup
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
**Need Help?** Check the [L4YERCAK3 Documentation](https://docs.l4yercak3.com) or contact support.
|
|
211
|
+
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Phase 0 Implementation Progress
|
|
2
|
+
|
|
3
|
+
## ✅ Completed
|
|
4
|
+
|
|
5
|
+
### Project Structure
|
|
6
|
+
- [x] Created directory structure:
|
|
7
|
+
- `src/commands/` - CLI commands
|
|
8
|
+
- `src/config/` - Configuration management
|
|
9
|
+
- `src/api/` - Backend API client
|
|
10
|
+
- `src/detectors/` - Project detection (ready for Phase 1)
|
|
11
|
+
- `src/generators/` - Code generators (ready for Phase 1)
|
|
12
|
+
|
|
13
|
+
### Configuration Management
|
|
14
|
+
- [x] `ConfigManager` class (`src/config/config-manager.js`)
|
|
15
|
+
- Stores session in `~/.l4yercak3/config.json`
|
|
16
|
+
- Handles session validation and expiration
|
|
17
|
+
- Manages organizations and settings
|
|
18
|
+
- Secure file permissions (0o600)
|
|
19
|
+
|
|
20
|
+
### Backend API Client
|
|
21
|
+
- [x] `BackendClient` class (`src/api/backend-client.js`)
|
|
22
|
+
- Handles API requests with authentication
|
|
23
|
+
- Session validation and refresh
|
|
24
|
+
- Organization management methods
|
|
25
|
+
- API key generation (ready for backend integration)
|
|
26
|
+
|
|
27
|
+
### CLI Commands
|
|
28
|
+
- [x] `login` command (`src/commands/login.js`)
|
|
29
|
+
- Opens browser for OAuth flow
|
|
30
|
+
- Starts local callback server (port 3001)
|
|
31
|
+
- Receives and stores session token
|
|
32
|
+
- Validates session with backend
|
|
33
|
+
|
|
34
|
+
- [x] `logout` command (`src/commands/logout.js`)
|
|
35
|
+
- Clears session from config
|
|
36
|
+
|
|
37
|
+
- [x] `auth status` command (`src/commands/status.js`)
|
|
38
|
+
- Shows authentication status
|
|
39
|
+
- Displays session info and expiration
|
|
40
|
+
- Validates session with backend
|
|
41
|
+
|
|
42
|
+
- [x] `spread` command (`src/commands/spread.js`)
|
|
43
|
+
- Placeholder for Phase 1 implementation
|
|
44
|
+
- Checks authentication before proceeding
|
|
45
|
+
|
|
46
|
+
### CLI Framework
|
|
47
|
+
- [x] Integrated `commander` for command parsing
|
|
48
|
+
- [x] Integrated `open` for browser opening
|
|
49
|
+
- [x] Integrated `node-fetch` for API calls
|
|
50
|
+
- [x] Updated main CLI entry point (`bin/cli.js`)
|
|
51
|
+
|
|
52
|
+
## 🚧 In Progress / Pending
|
|
53
|
+
|
|
54
|
+
### Backend Endpoints Needed
|
|
55
|
+
- [ ] `GET /auth/cli-login` - Initiate CLI OAuth flow
|
|
56
|
+
- [ ] `GET /auth/cli/callback` - Handle OAuth callback, return CLI session token
|
|
57
|
+
- [ ] `GET /api/v1/auth/cli/validate` - Validate CLI session
|
|
58
|
+
- [ ] `POST /api/v1/auth/cli/refresh` - Refresh expired session
|
|
59
|
+
- [ ] `GET /api/v1/organizations` - Get user's organizations
|
|
60
|
+
- [ ] `POST /api/v1/organizations` - Create organization
|
|
61
|
+
- [ ] `POST /api/v1/api-keys/generate` - Generate API key (or call Convex action directly)
|
|
62
|
+
|
|
63
|
+
### CLI Enhancements
|
|
64
|
+
- [ ] Handle deep link callback (`l4yercak3://auth/callback`) as alternative to local server
|
|
65
|
+
- [ ] OS keychain integration for secure token storage (macOS)
|
|
66
|
+
- [ ] Better error handling and user feedback
|
|
67
|
+
- [ ] Session refresh on expiration
|
|
68
|
+
- [ ] 2FA support during login
|
|
69
|
+
|
|
70
|
+
## 📝 Testing
|
|
71
|
+
|
|
72
|
+
### Manual Testing Checklist
|
|
73
|
+
- [ ] `l4yercak3 login` - Opens browser, receives token
|
|
74
|
+
- [ ] `l4yercak3 logout` - Clears session
|
|
75
|
+
- [ ] `l4yercak3 auth status` - Shows status correctly
|
|
76
|
+
- [ ] `l4yercak3 spread` - Requires login, shows placeholder
|
|
77
|
+
|
|
78
|
+
### Backend Integration Testing
|
|
79
|
+
- [ ] Test with real backend OAuth endpoints
|
|
80
|
+
- [ ] Test session validation
|
|
81
|
+
- [ ] Test session refresh
|
|
82
|
+
- [ ] Test organization creation
|
|
83
|
+
- [ ] Test API key generation
|
|
84
|
+
|
|
85
|
+
## 🎯 Next Steps (Phase 1)
|
|
86
|
+
|
|
87
|
+
1. **Project Detection** (`src/detectors/`)
|
|
88
|
+
- Detect Next.js projects
|
|
89
|
+
- Detect GitHub repository
|
|
90
|
+
- Detect existing API client patterns
|
|
91
|
+
|
|
92
|
+
2. **Configuration Wizard** (`src/commands/spread.js`)
|
|
93
|
+
- Interactive prompts
|
|
94
|
+
- Organization selection/creation
|
|
95
|
+
- Feature selection
|
|
96
|
+
|
|
97
|
+
3. **File Generation** (`src/generators/`)
|
|
98
|
+
- API client generation
|
|
99
|
+
- Environment file generation
|
|
100
|
+
- NextAuth.js configuration
|
|
101
|
+
|
|
102
|
+
## 📦 Dependencies Added
|
|
103
|
+
|
|
104
|
+
- `commander` - CLI command parsing
|
|
105
|
+
- `open` - Open browser for OAuth
|
|
106
|
+
- `node-fetch@2` - HTTP requests (CommonJS compatible)
|
|
107
|
+
|
|
108
|
+
## 🔒 Security Considerations
|
|
109
|
+
|
|
110
|
+
- Config file stored with 0o600 permissions (owner read/write only)
|
|
111
|
+
- Session tokens stored locally (not in git)
|
|
112
|
+
- Config directory excluded from git
|
|
113
|
+
- Session expiration checking
|
|
114
|
+
- Secure token handling
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
**Status:** Phase 0 Foundation Complete ✅
|
|
119
|
+
**Next:** Backend endpoints + Phase 1 implementation
|
|
120
|
+
|