aiag-cli 2.2.3 → 2.3.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 +72 -37
- package/dist/cli.js +30 -2
- package/dist/cli.js.map +1 -1
- package/dist/commands/feature.d.ts +11 -0
- package/dist/commands/feature.d.ts.map +1 -0
- package/dist/commands/feature.js +153 -0
- package/dist/commands/feature.js.map +1 -0
- package/dist/commands/init.d.ts +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +29 -78
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/prd.d.ts +12 -0
- package/dist/commands/prd.d.ts.map +1 -0
- package/dist/commands/prd.js +179 -0
- package/dist/commands/prd.js.map +1 -0
- package/dist/prompts/index.d.ts +2 -0
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +2 -0
- package/dist/prompts/index.js.map +1 -1
- package/dist/prompts/prd.d.ts +28 -0
- package/dist/prompts/prd.d.ts.map +1 -0
- package/dist/prompts/prd.js +105 -0
- package/dist/prompts/prd.js.map +1 -0
- package/dist/skills/index.d.ts +12 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +12 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/skills/installer.d.ts +38 -0
- package/dist/skills/installer.d.ts.map +1 -0
- package/dist/skills/installer.js +153 -0
- package/dist/skills/installer.js.map +1 -0
- package/dist/skills/loader.d.ts +34 -0
- package/dist/skills/loader.d.ts.map +1 -0
- package/dist/skills/loader.js +134 -0
- package/dist/skills/loader.js.map +1 -0
- package/dist/skills/runner.d.ts +14 -0
- package/dist/skills/runner.d.ts.map +1 -0
- package/dist/skills/runner.js +238 -0
- package/dist/skills/runner.js.map +1 -0
- package/dist/types.d.ts +127 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/prd.d.ts +21 -0
- package/dist/utils/prd.d.ts.map +1 -1
- package/dist/utils/prd.js +69 -0
- package/dist/utils/prd.js.map +1 -1
- package/dist/utils/taskmasterConverter.d.ts +72 -0
- package/dist/utils/taskmasterConverter.d.ts.map +1 -0
- package/dist/utils/taskmasterConverter.js +401 -0
- package/dist/utils/taskmasterConverter.js.map +1 -0
- package/dist/utils/taskmasterParser.d.ts +35 -0
- package/dist/utils/taskmasterParser.d.ts.map +1 -0
- package/dist/utils/taskmasterParser.js +259 -0
- package/dist/utils/taskmasterParser.js.map +1 -0
- package/package.json +1 -1
- package/templates/skills/prd-taskmaster/.taskmaster/docs/prd.md +2571 -0
- package/templates/skills/prd-taskmaster/.taskmaster/scripts/execution-state.py +87 -0
- package/templates/skills/prd-taskmaster/.taskmaster/scripts/learn-accuracy.py +113 -0
- package/templates/skills/prd-taskmaster/.taskmaster/scripts/rollback.sh +71 -0
- package/templates/skills/prd-taskmaster/.taskmaster/scripts/security-audit.py +130 -0
- package/templates/skills/prd-taskmaster/.taskmaster/scripts/track-time.py +133 -0
- package/templates/skills/prd-taskmaster/LICENSE +21 -0
- package/templates/skills/prd-taskmaster/README.md +608 -0
- package/templates/skills/prd-taskmaster/SKILL.md +1258 -0
- package/templates/skills/prd-taskmaster/reference/taskmaster-integration-guide.md +645 -0
- package/templates/skills/prd-taskmaster/reference/validation-checklist.md +394 -0
- package/templates/skills/prd-taskmaster/scripts/setup-taskmaster.sh +112 -0
- package/templates/skills/prd-taskmaster/templates/CLAUDE.md.template +635 -0
- package/templates/skills/prd-taskmaster/templates/taskmaster-prd-comprehensive.md +983 -0
- package/templates/skills/prd-taskmaster/templates/taskmaster-prd-minimal.md +103 -0
|
@@ -0,0 +1,983 @@
|
|
|
1
|
+
# PRD: [Feature/Product Name]
|
|
2
|
+
|
|
3
|
+
**Author:** [Name]
|
|
4
|
+
**Date:** [YYYY-MM-DD]
|
|
5
|
+
**Status:** Draft | In Review | Approved
|
|
6
|
+
**Version:** 1.0
|
|
7
|
+
**Taskmaster Optimized:** Yes
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Table of Contents
|
|
12
|
+
|
|
13
|
+
1. [Executive Summary](#executive-summary)
|
|
14
|
+
2. [Problem Statement](#problem-statement)
|
|
15
|
+
3. [Goals & Success Metrics](#goals--success-metrics)
|
|
16
|
+
4. [User Stories](#user-stories)
|
|
17
|
+
5. [Functional Requirements](#functional-requirements)
|
|
18
|
+
6. [Non-Functional Requirements](#non-functional-requirements)
|
|
19
|
+
7. [Technical Considerations](#technical-considerations)
|
|
20
|
+
8. [Implementation Roadmap](#implementation-roadmap)
|
|
21
|
+
9. [Out of Scope](#out-of-scope)
|
|
22
|
+
10. [Open Questions & Risks](#open-questions--risks)
|
|
23
|
+
11. [Validation Checkpoints](#validation-checkpoints)
|
|
24
|
+
12. [Appendix: Task Breakdown Hints](#appendix-task-breakdown-hints)
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Executive Summary
|
|
29
|
+
|
|
30
|
+
[2-3 sentences: What problem are we solving + proposed solution + expected impact]
|
|
31
|
+
|
|
32
|
+
Example:
|
|
33
|
+
> Users currently cannot authenticate securely, leading to 15% account compromise rate. We're implementing two-factor authentication (2FA) via SMS and authenticator apps, which should reduce compromises to <1% within 3 months of launch.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Problem Statement
|
|
38
|
+
|
|
39
|
+
### Current Situation
|
|
40
|
+
[Describe what exists today and what's wrong with it]
|
|
41
|
+
|
|
42
|
+
### User Impact
|
|
43
|
+
- **Who is affected:** [User segment(s)]
|
|
44
|
+
- **How they're affected:** [Specific pain points]
|
|
45
|
+
- **Severity:** [Critical/High/Medium - with evidence/data]
|
|
46
|
+
|
|
47
|
+
### Business Impact
|
|
48
|
+
- **Cost of problem:** [Quantify: lost revenue, support tickets, churn]
|
|
49
|
+
- **Opportunity cost:** [What we're missing by not solving this]
|
|
50
|
+
- **Strategic importance:** [How this aligns with company goals]
|
|
51
|
+
|
|
52
|
+
### Why Solve This Now?
|
|
53
|
+
[Timing, market conditions, competitive pressure, technical readiness]
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Goals & Success Metrics
|
|
58
|
+
|
|
59
|
+
### Goal 1: [Primary Goal]
|
|
60
|
+
- **Description:** [What we're trying to achieve]
|
|
61
|
+
- **Metric:** [How we measure success]
|
|
62
|
+
- **Baseline:** [Current value with source]
|
|
63
|
+
- **Target:** [Goal value]
|
|
64
|
+
- **Timeframe:** [When we expect to achieve this]
|
|
65
|
+
- **Measurement Method:** [How we'll track: analytics, surveys, logs]
|
|
66
|
+
|
|
67
|
+
**Example:**
|
|
68
|
+
```
|
|
69
|
+
Goal: Reduce account security incidents
|
|
70
|
+
Metric: Number of compromised accounts per month
|
|
71
|
+
Baseline: 150 incidents/month (average last 6 months)
|
|
72
|
+
Target: <10 incidents/month (93% reduction)
|
|
73
|
+
Timeframe: 3 months post-launch
|
|
74
|
+
Measurement: Security incident logs + user reports
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Goal 2: [Secondary Goal]
|
|
78
|
+
- **Description:** [What we're trying to achieve]
|
|
79
|
+
- **Metric:** [How we measure success]
|
|
80
|
+
- **Baseline:** [Current value]
|
|
81
|
+
- **Target:** [Goal value]
|
|
82
|
+
- **Timeframe:** [When]
|
|
83
|
+
- **Measurement Method:** [How]
|
|
84
|
+
|
|
85
|
+
### Goal 3: [Tertiary Goal]
|
|
86
|
+
[Repeat structure]
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## User Stories
|
|
91
|
+
|
|
92
|
+
### Story 1: [Feature Name]
|
|
93
|
+
|
|
94
|
+
**As a** [user type],
|
|
95
|
+
**I want to** [action],
|
|
96
|
+
**So that I can** [benefit/outcome].
|
|
97
|
+
|
|
98
|
+
**Acceptance Criteria:**
|
|
99
|
+
- [ ] [Specific, testable criterion 1]
|
|
100
|
+
- [ ] [Specific, testable criterion 2]
|
|
101
|
+
- [ ] [Specific, testable criterion 3]
|
|
102
|
+
- [ ] [Edge case criterion]
|
|
103
|
+
- [ ] [Error handling criterion]
|
|
104
|
+
|
|
105
|
+
**Task Breakdown Hint:**
|
|
106
|
+
- Task 1.1: [Implementation step] (~4 hours)
|
|
107
|
+
- Task 1.2: [Implementation step] (~6 hours)
|
|
108
|
+
- Task 1.3: [Testing] (~2 hours)
|
|
109
|
+
|
|
110
|
+
**Dependencies:** [None | REQ-XXX | Story Y]
|
|
111
|
+
|
|
112
|
+
**Example:**
|
|
113
|
+
```
|
|
114
|
+
Story: User enables 2FA
|
|
115
|
+
|
|
116
|
+
As a registered user,
|
|
117
|
+
I want to enable two-factor authentication on my account,
|
|
118
|
+
So that I can protect my account from unauthorized access.
|
|
119
|
+
|
|
120
|
+
Acceptance Criteria:
|
|
121
|
+
- [ ] User can access 2FA setup from account settings
|
|
122
|
+
- [ ] System supports both SMS and authenticator app methods
|
|
123
|
+
- [ ] User must verify phone number before enabling SMS 2FA
|
|
124
|
+
- [ ] System generates QR code for authenticator app setup
|
|
125
|
+
- [ ] User must successfully verify 2FA code before it's fully enabled
|
|
126
|
+
- [ ] System provides backup codes (10) for account recovery
|
|
127
|
+
- [ ] User receives confirmation email when 2FA is enabled
|
|
128
|
+
|
|
129
|
+
Task Breakdown Hint:
|
|
130
|
+
- Task 1.1: Create 2FA settings UI component (4h)
|
|
131
|
+
- Task 1.2: Implement SMS verification flow (6h)
|
|
132
|
+
- Task 1.3: Implement TOTP/authenticator app flow (6h)
|
|
133
|
+
- Task 1.4: Generate and store backup codes (3h)
|
|
134
|
+
- Task 1.5: Add 2FA verification to login flow (5h)
|
|
135
|
+
- Task 1.6: Write tests for 2FA flows (4h)
|
|
136
|
+
|
|
137
|
+
Dependencies: REQ-001 (user authentication must exist)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
### Story 2: [Feature Name]
|
|
143
|
+
[Repeat structure]
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
### Story 3: [Feature Name]
|
|
148
|
+
[Repeat structure]
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Functional Requirements
|
|
153
|
+
|
|
154
|
+
### Must Have (P0) - Critical for Launch
|
|
155
|
+
|
|
156
|
+
#### REQ-001: [Requirement Title]
|
|
157
|
+
**Description:** [Detailed description of what the system must do]
|
|
158
|
+
|
|
159
|
+
**Acceptance Criteria:**
|
|
160
|
+
- [ ] [Specific, testable criterion]
|
|
161
|
+
- [ ] [Specific, testable criterion]
|
|
162
|
+
- [ ] [Specific, testable criterion]
|
|
163
|
+
|
|
164
|
+
**Technical Specification:**
|
|
165
|
+
```
|
|
166
|
+
[Code example, API spec, or detailed technical description]
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**Task Breakdown:**
|
|
170
|
+
- Implement [component]: Small (2-4h)
|
|
171
|
+
- Add [functionality]: Medium (4-8h)
|
|
172
|
+
- Test [feature]: Small (2-4h)
|
|
173
|
+
|
|
174
|
+
**Dependencies:** [None | REQ-XXX | External service Y]
|
|
175
|
+
|
|
176
|
+
**Example:**
|
|
177
|
+
```
|
|
178
|
+
REQ-001: User Authentication with 2FA
|
|
179
|
+
|
|
180
|
+
Description: System must authenticate users via username/password and require 2FA verification when enabled on the account.
|
|
181
|
+
|
|
182
|
+
Acceptance Criteria:
|
|
183
|
+
- [ ] POST /api/auth/login accepts email and password
|
|
184
|
+
- [ ] Returns JWT token if credentials valid and 2FA not enabled
|
|
185
|
+
- [ ] Returns 2FA challenge if credentials valid and 2FA enabled
|
|
186
|
+
- [ ] POST /api/auth/verify-2fa accepts 2FA code and returns JWT if valid
|
|
187
|
+
- [ ] Invalid 2FA code returns 401 with clear error message
|
|
188
|
+
- [ ] Failed attempts are rate-limited (5 attempts per 15 minutes)
|
|
189
|
+
- [ ] 2FA codes expire after 30 seconds (TOTP standard)
|
|
190
|
+
|
|
191
|
+
Technical Specification:
|
|
192
|
+
```typescript
|
|
193
|
+
// POST /api/auth/login
|
|
194
|
+
interface LoginRequest {
|
|
195
|
+
email: string;
|
|
196
|
+
password: string;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
interface LoginResponse {
|
|
200
|
+
requires2FA: boolean;
|
|
201
|
+
token?: string; // Only if 2FA not required
|
|
202
|
+
challenge?: string; // Only if 2FA required
|
|
203
|
+
expiresAt?: number;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// POST /api/auth/verify-2fa
|
|
207
|
+
interface Verify2FARequest {
|
|
208
|
+
challenge: string;
|
|
209
|
+
code: string; // 6-digit TOTP code
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
interface Verify2FAResponse {
|
|
213
|
+
token: string;
|
|
214
|
+
expiresAt: number;
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Task Breakdown:
|
|
219
|
+
- Implement login endpoint with password verification: Medium (6h)
|
|
220
|
+
- Add 2FA challenge generation logic: Small (3h)
|
|
221
|
+
- Implement 2FA verification endpoint: Medium (5h)
|
|
222
|
+
- Add rate limiting middleware: Small (2h)
|
|
223
|
+
- Write unit tests for auth flows: Medium (4h)
|
|
224
|
+
- Write integration tests: Small (3h)
|
|
225
|
+
|
|
226
|
+
Dependencies: None (can start immediately)
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
#### REQ-002: [Requirement Title]
|
|
232
|
+
[Repeat structure]
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
### Should Have (P1) - Important but Not Blocking
|
|
237
|
+
|
|
238
|
+
#### REQ-005: [Requirement Title]
|
|
239
|
+
[Repeat structure]
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
### Nice to Have (P2) - Future Enhancement
|
|
244
|
+
|
|
245
|
+
#### REQ-008: [Requirement Title]
|
|
246
|
+
[Repeat structure]
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## Non-Functional Requirements
|
|
251
|
+
|
|
252
|
+
### Performance
|
|
253
|
+
|
|
254
|
+
**Response Time:**
|
|
255
|
+
- API endpoints: < 200ms for 95th percentile
|
|
256
|
+
- Database queries: < 100ms for single-record lookups
|
|
257
|
+
- Page load time: < 2 seconds on 4G connection
|
|
258
|
+
|
|
259
|
+
**Throughput:**
|
|
260
|
+
- Handle 1,000 requests/second under normal load
|
|
261
|
+
- Scale to 5,000 requests/second during peak (with auto-scaling)
|
|
262
|
+
|
|
263
|
+
**Resource Usage:**
|
|
264
|
+
- Memory: < 512MB per server instance
|
|
265
|
+
- CPU: < 60% average utilization
|
|
266
|
+
- Database connections: < 50 per instance
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
### Security
|
|
271
|
+
|
|
272
|
+
**Authentication:**
|
|
273
|
+
- JWT tokens with 24-hour expiration
|
|
274
|
+
- Refresh tokens with 30-day expiration
|
|
275
|
+
- Secure token storage (httpOnly cookies or secure storage)
|
|
276
|
+
|
|
277
|
+
**Authorization:**
|
|
278
|
+
- Role-based access control (RBAC)
|
|
279
|
+
- Principle of least privilege
|
|
280
|
+
- Audit logging for sensitive operations
|
|
281
|
+
|
|
282
|
+
**Data Protection:**
|
|
283
|
+
- Passwords hashed with bcrypt (cost factor 12)
|
|
284
|
+
- 2FA secrets encrypted at rest (AES-256)
|
|
285
|
+
- PII encrypted in database
|
|
286
|
+
- TLS 1.3 for all connections
|
|
287
|
+
|
|
288
|
+
**Compliance:**
|
|
289
|
+
- GDPR: Right to erasure, data portability
|
|
290
|
+
- CCPA: Data disclosure requirements
|
|
291
|
+
- SOC 2: Audit logging, access controls
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
### Scalability
|
|
296
|
+
|
|
297
|
+
**User Load:**
|
|
298
|
+
- Support 100,000 active users initially
|
|
299
|
+
- Scale to 1M users within 6 months
|
|
300
|
+
- Horizontal scaling via containerization (Kubernetes)
|
|
301
|
+
|
|
302
|
+
**Data Volume:**
|
|
303
|
+
- Initial: 1GB database size
|
|
304
|
+
- Growth: ~100MB/month
|
|
305
|
+
- Retention: 7 years (compliance requirement)
|
|
306
|
+
|
|
307
|
+
**Geographic Distribution:**
|
|
308
|
+
- Primary: US-East
|
|
309
|
+
- Replicas: US-West, EU-West (future)
|
|
310
|
+
- CDN for static assets
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
### Reliability
|
|
315
|
+
|
|
316
|
+
**Uptime:**
|
|
317
|
+
- SLA: 99.9% monthly uptime (< 43 minutes downtime/month)
|
|
318
|
+
- RTO (Recovery Time Objective): < 1 hour
|
|
319
|
+
- RPO (Recovery Point Objective): < 15 minutes
|
|
320
|
+
|
|
321
|
+
**Error Handling:**
|
|
322
|
+
- Error rate: < 0.1% of requests
|
|
323
|
+
- Graceful degradation (2FA optional if service down)
|
|
324
|
+
- Circuit breaker for external dependencies
|
|
325
|
+
|
|
326
|
+
**Monitoring:**
|
|
327
|
+
- Health checks every 30 seconds
|
|
328
|
+
- Alert on error rate > 1%
|
|
329
|
+
- Dashboard for key metrics
|
|
330
|
+
|
|
331
|
+
---
|
|
332
|
+
|
|
333
|
+
### Accessibility
|
|
334
|
+
|
|
335
|
+
**Standards:**
|
|
336
|
+
- WCAG 2.1 Level AA compliance
|
|
337
|
+
- Keyboard navigation for all features
|
|
338
|
+
- Screen reader support (ARIA labels)
|
|
339
|
+
|
|
340
|
+
**Testing:**
|
|
341
|
+
- Automated accessibility testing (axe-core)
|
|
342
|
+
- Manual testing with screen readers
|
|
343
|
+
- Color contrast ratio ≥ 4.5:1
|
|
344
|
+
|
|
345
|
+
---
|
|
346
|
+
|
|
347
|
+
### Compatibility
|
|
348
|
+
|
|
349
|
+
**Browsers:**
|
|
350
|
+
- Chrome (last 2 versions)
|
|
351
|
+
- Firefox (last 2 versions)
|
|
352
|
+
- Safari (last 2 versions)
|
|
353
|
+
- Edge (last 2 versions)
|
|
354
|
+
|
|
355
|
+
**Devices:**
|
|
356
|
+
- Desktop: Windows, macOS, Linux
|
|
357
|
+
- Mobile: iOS 14+, Android 10+
|
|
358
|
+
- Tablet: iPad, Android tablets
|
|
359
|
+
|
|
360
|
+
**Responsive Design:**
|
|
361
|
+
- Breakpoints: 320px, 768px, 1024px, 1440px
|
|
362
|
+
- Mobile-first approach
|
|
363
|
+
|
|
364
|
+
---
|
|
365
|
+
|
|
366
|
+
## Technical Considerations
|
|
367
|
+
|
|
368
|
+
### System Architecture
|
|
369
|
+
|
|
370
|
+
**Current Architecture:**
|
|
371
|
+
[If existing system, describe current architecture]
|
|
372
|
+
|
|
373
|
+
**Proposed Changes:**
|
|
374
|
+
[How this feature integrates with or changes the architecture]
|
|
375
|
+
|
|
376
|
+
**Diagram:**
|
|
377
|
+
```
|
|
378
|
+
[ASCII diagram or reference to external diagram]
|
|
379
|
+
|
|
380
|
+
┌─────────┐ ┌──────────────┐ ┌──────────┐
|
|
381
|
+
│ Client │─────>│ API GW │─────>│ Auth │
|
|
382
|
+
│ │<─────│ │<─────│ Service │
|
|
383
|
+
└─────────┘ └──────────────┘ └──────────┘
|
|
384
|
+
│ │
|
|
385
|
+
v v
|
|
386
|
+
┌──────────────┐ ┌──────────┐
|
|
387
|
+
│ Database │ │ Redis │
|
|
388
|
+
│ (Users) │ │ (Sessions)
|
|
389
|
+
└──────────────┘ └──────────┘
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
**Key Components:**
|
|
393
|
+
1. **Auth Service:** Handles authentication, 2FA verification
|
|
394
|
+
2. **SMS Provider:** Twilio for SMS code delivery
|
|
395
|
+
3. **Redis:** Session storage, rate limiting
|
|
396
|
+
4. **Database:** User credentials, 2FA secrets
|
|
397
|
+
|
|
398
|
+
---
|
|
399
|
+
|
|
400
|
+
### API Specifications
|
|
401
|
+
|
|
402
|
+
#### Endpoint: Create User
|
|
403
|
+
```
|
|
404
|
+
POST /api/v1/users
|
|
405
|
+
|
|
406
|
+
Headers:
|
|
407
|
+
Content-Type: application/json
|
|
408
|
+
|
|
409
|
+
Request:
|
|
410
|
+
{
|
|
411
|
+
"email": "user@example.com",
|
|
412
|
+
"password": "SecurePass123!",
|
|
413
|
+
"profile": {
|
|
414
|
+
"firstName": "Jane",
|
|
415
|
+
"lastName": "Doe"
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
Response (201 Created):
|
|
420
|
+
{
|
|
421
|
+
"id": "uuid-1234-5678",
|
|
422
|
+
"email": "user@example.com",
|
|
423
|
+
"profile": {
|
|
424
|
+
"firstName": "Jane",
|
|
425
|
+
"lastName": "Doe"
|
|
426
|
+
},
|
|
427
|
+
"createdAt": "2025-01-15T10:30:00Z",
|
|
428
|
+
"2faEnabled": false
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
Error (400 Bad Request):
|
|
432
|
+
{
|
|
433
|
+
"error": "INVALID_EMAIL",
|
|
434
|
+
"message": "Email format is invalid",
|
|
435
|
+
"field": "email"
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
Error (409 Conflict):
|
|
439
|
+
{
|
|
440
|
+
"error": "EMAIL_EXISTS",
|
|
441
|
+
"message": "User with this email already exists"
|
|
442
|
+
}
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
#### Endpoint: Enable 2FA
|
|
446
|
+
```
|
|
447
|
+
POST /api/v1/users/me/2fa/enable
|
|
448
|
+
|
|
449
|
+
Headers:
|
|
450
|
+
Authorization: Bearer {jwt_token}
|
|
451
|
+
Content-Type: application/json
|
|
452
|
+
|
|
453
|
+
Request:
|
|
454
|
+
{
|
|
455
|
+
"method": "totp", // or "sms"
|
|
456
|
+
"phoneNumber": "+1234567890" // required if method=sms
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
Response (200 OK):
|
|
460
|
+
{
|
|
461
|
+
"method": "totp",
|
|
462
|
+
"secret": "BASE32ENCODEDSECRET",
|
|
463
|
+
"qrCode": "data:image/png;base64,...",
|
|
464
|
+
"backupCodes": [
|
|
465
|
+
"1234-5678-9012",
|
|
466
|
+
"2345-6789-0123",
|
|
467
|
+
...
|
|
468
|
+
]
|
|
469
|
+
}
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
[Add more endpoints as needed]
|
|
473
|
+
|
|
474
|
+
---
|
|
475
|
+
|
|
476
|
+
### Database Schema
|
|
477
|
+
|
|
478
|
+
**New Tables:**
|
|
479
|
+
|
|
480
|
+
```sql
|
|
481
|
+
-- 2FA configuration table
|
|
482
|
+
CREATE TABLE user_2fa (
|
|
483
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
484
|
+
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
485
|
+
method VARCHAR(10) NOT NULL CHECK (method IN ('sms', 'totp')),
|
|
486
|
+
secret_encrypted VARCHAR(255) NOT NULL, -- Encrypted 2FA secret
|
|
487
|
+
phone_number VARCHAR(20), -- For SMS method
|
|
488
|
+
enabled BOOLEAN DEFAULT false,
|
|
489
|
+
verified_at TIMESTAMP,
|
|
490
|
+
created_at TIMESTAMP DEFAULT NOW(),
|
|
491
|
+
updated_at TIMESTAMP DEFAULT NOW(),
|
|
492
|
+
UNIQUE(user_id)
|
|
493
|
+
);
|
|
494
|
+
|
|
495
|
+
CREATE INDEX idx_user_2fa_user_id ON user_2fa(user_id);
|
|
496
|
+
|
|
497
|
+
-- Backup codes table
|
|
498
|
+
CREATE TABLE backup_codes (
|
|
499
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
500
|
+
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
501
|
+
code_hash VARCHAR(255) NOT NULL, -- bcrypt hash of code
|
|
502
|
+
used_at TIMESTAMP,
|
|
503
|
+
created_at TIMESTAMP DEFAULT NOW()
|
|
504
|
+
);
|
|
505
|
+
|
|
506
|
+
CREATE INDEX idx_backup_codes_user_id ON backup_codes(user_id);
|
|
507
|
+
CREATE INDEX idx_backup_codes_used ON backup_codes(used_at) WHERE used_at IS NULL;
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
**Modified Tables:**
|
|
511
|
+
|
|
512
|
+
```sql
|
|
513
|
+
-- Add 2FA tracking to users table
|
|
514
|
+
ALTER TABLE users ADD COLUMN two_factor_enabled BOOLEAN DEFAULT false;
|
|
515
|
+
ALTER TABLE users ADD COLUMN last_2fa_verified_at TIMESTAMP;
|
|
516
|
+
|
|
517
|
+
CREATE INDEX idx_users_2fa_enabled ON users(two_factor_enabled);
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
---
|
|
521
|
+
|
|
522
|
+
### Technology Stack
|
|
523
|
+
|
|
524
|
+
**Frontend:**
|
|
525
|
+
- [Framework: React, Vue, etc.]
|
|
526
|
+
- [State management: Redux, Vuex, etc.]
|
|
527
|
+
- [UI Library: Material-UI, Tailwind, etc.]
|
|
528
|
+
|
|
529
|
+
**Backend:**
|
|
530
|
+
- [Runtime: Node.js, Python, etc.]
|
|
531
|
+
- [Framework: Express, FastAPI, etc.]
|
|
532
|
+
- [ORM: Prisma, SQLAlchemy, etc.]
|
|
533
|
+
|
|
534
|
+
**Database:**
|
|
535
|
+
- [Primary: PostgreSQL, MySQL, etc.]
|
|
536
|
+
- [Cache: Redis, Memcached]
|
|
537
|
+
|
|
538
|
+
**Infrastructure:**
|
|
539
|
+
- [Cloud: AWS, GCP, Azure]
|
|
540
|
+
- [Container: Docker, Kubernetes]
|
|
541
|
+
- [CI/CD: GitHub Actions, Jenkins, etc.]
|
|
542
|
+
|
|
543
|
+
---
|
|
544
|
+
|
|
545
|
+
### External Dependencies
|
|
546
|
+
|
|
547
|
+
**Third-Party Services:**
|
|
548
|
+
1. **Twilio (SMS):**
|
|
549
|
+
- Purpose: Send 2FA codes via SMS
|
|
550
|
+
- API: https://www.twilio.com/docs/sms
|
|
551
|
+
- Rate Limits: 100 messages/second
|
|
552
|
+
- Fallback: If down, disable SMS 2FA temporarily
|
|
553
|
+
|
|
554
|
+
2. **[Service Name]:**
|
|
555
|
+
- Purpose: [What it does]
|
|
556
|
+
- Integration: [How we integrate]
|
|
557
|
+
- Failure handling: [What happens if it fails]
|
|
558
|
+
|
|
559
|
+
**Internal Dependencies:**
|
|
560
|
+
- **User Service:** Must exist (provides user authentication)
|
|
561
|
+
- **Email Service:** For 2FA setup notifications
|
|
562
|
+
- **Analytics Service:** For tracking 2FA adoption
|
|
563
|
+
|
|
564
|
+
---
|
|
565
|
+
|
|
566
|
+
### Migration Strategy
|
|
567
|
+
|
|
568
|
+
**For Existing Systems:**
|
|
569
|
+
|
|
570
|
+
1. **Phase 1: Deploy Schema Changes**
|
|
571
|
+
```bash
|
|
572
|
+
# Run migration (zero-downtime)
|
|
573
|
+
npm run migrate:up
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
2. **Phase 2: Deploy Code (Feature Flag Disabled)**
|
|
577
|
+
- Deploy new code with 2FA feature flag OFF
|
|
578
|
+
- Verify no regressions
|
|
579
|
+
|
|
580
|
+
3. **Phase 3: Enable for Beta Users**
|
|
581
|
+
- Enable feature flag for 5% of users
|
|
582
|
+
- Monitor metrics and errors
|
|
583
|
+
|
|
584
|
+
4. **Phase 4: Gradual Rollout**
|
|
585
|
+
- 25% → 50% → 100% over 2 weeks
|
|
586
|
+
- Monitor each phase
|
|
587
|
+
|
|
588
|
+
5. **Phase 5: Encourage Adoption**
|
|
589
|
+
- Email campaign to remaining users
|
|
590
|
+
- In-app prompts to enable 2FA
|
|
591
|
+
|
|
592
|
+
**Rollback Plan:**
|
|
593
|
+
- Disable feature flag immediately
|
|
594
|
+
- No database rollback needed (backward compatible)
|
|
595
|
+
|
|
596
|
+
---
|
|
597
|
+
|
|
598
|
+
### Testing Strategy
|
|
599
|
+
|
|
600
|
+
**Unit Tests:**
|
|
601
|
+
- Test coverage: > 80%
|
|
602
|
+
- Key areas:
|
|
603
|
+
- 2FA code generation and validation
|
|
604
|
+
- Token creation and verification
|
|
605
|
+
- Error handling
|
|
606
|
+
|
|
607
|
+
**Integration Tests:**
|
|
608
|
+
- Full authentication flows:
|
|
609
|
+
- Login without 2FA
|
|
610
|
+
- Login with 2FA (SMS)
|
|
611
|
+
- Login with 2FA (TOTP)
|
|
612
|
+
- Backup code usage
|
|
613
|
+
- Rate limiting
|
|
614
|
+
|
|
615
|
+
**E2E Tests:**
|
|
616
|
+
- User journeys:
|
|
617
|
+
- New user enables 2FA
|
|
618
|
+
- Existing user adds 2FA
|
|
619
|
+
- User loses device, uses backup code
|
|
620
|
+
- User disables 2FA
|
|
621
|
+
|
|
622
|
+
**Performance Tests:**
|
|
623
|
+
- Load test: 1000 concurrent logins
|
|
624
|
+
- Stress test: 5000 requests/second
|
|
625
|
+
- Endurance test: 24-hour sustained load
|
|
626
|
+
|
|
627
|
+
**Security Tests:**
|
|
628
|
+
- Penetration testing
|
|
629
|
+
- OWASP Top 10 validation
|
|
630
|
+
- Brute force protection testing
|
|
631
|
+
|
|
632
|
+
---
|
|
633
|
+
|
|
634
|
+
## Implementation Roadmap
|
|
635
|
+
|
|
636
|
+
### Phase 1: Foundation (Week 1-2)
|
|
637
|
+
**Goal:** Database, basic API structure, 2FA code generation
|
|
638
|
+
|
|
639
|
+
**Tasks:**
|
|
640
|
+
- [x] Task 1.1: Create database schema (REQ-001)
|
|
641
|
+
- Complexity: Small (3h)
|
|
642
|
+
- Dependencies: None
|
|
643
|
+
- Owner: Backend team
|
|
644
|
+
|
|
645
|
+
- [x] Task 1.2: Implement 2FA secret generation (REQ-002)
|
|
646
|
+
- Complexity: Small (2h)
|
|
647
|
+
- Dependencies: Task 1.1
|
|
648
|
+
- Owner: Backend team
|
|
649
|
+
|
|
650
|
+
- [x] Task 1.3: Implement TOTP validation logic (REQ-003)
|
|
651
|
+
- Complexity: Medium (5h)
|
|
652
|
+
- Dependencies: Task 1.2
|
|
653
|
+
- Owner: Backend team
|
|
654
|
+
|
|
655
|
+
**Validation Checkpoint:** Can generate and validate TOTP codes
|
|
656
|
+
|
|
657
|
+
---
|
|
658
|
+
|
|
659
|
+
### Phase 2: Core Features (Week 3-4)
|
|
660
|
+
**Goal:** Enable 2FA setup, login verification
|
|
661
|
+
|
|
662
|
+
**Tasks:**
|
|
663
|
+
- [ ] Task 2.1: Build 2FA setup UI (REQ-004)
|
|
664
|
+
- Complexity: Medium (8h)
|
|
665
|
+
- Dependencies: Phase 1 complete
|
|
666
|
+
- Owner: Frontend team
|
|
667
|
+
|
|
668
|
+
- [ ] Task 2.2: Implement enable 2FA API endpoint (REQ-005)
|
|
669
|
+
- Complexity: Medium (6h)
|
|
670
|
+
- Dependencies: Phase 1 complete
|
|
671
|
+
- Owner: Backend team
|
|
672
|
+
|
|
673
|
+
- [ ] Task 2.3: Add 2FA verification to login flow (REQ-006)
|
|
674
|
+
- Complexity: Large (10h)
|
|
675
|
+
- Dependencies: Task 2.2
|
|
676
|
+
- Owner: Full-stack team
|
|
677
|
+
|
|
678
|
+
- [ ] Task 2.4: Generate and store backup codes (REQ-007)
|
|
679
|
+
- Complexity: Small (4h)
|
|
680
|
+
- Dependencies: Task 2.2
|
|
681
|
+
- Owner: Backend team
|
|
682
|
+
|
|
683
|
+
**Validation Checkpoint:** Users can enable 2FA and use it to login
|
|
684
|
+
|
|
685
|
+
---
|
|
686
|
+
|
|
687
|
+
### Phase 3: SMS Support (Week 5)
|
|
688
|
+
**Goal:** Add SMS 2FA method
|
|
689
|
+
|
|
690
|
+
**Tasks:**
|
|
691
|
+
- [ ] Task 3.1: Integrate Twilio API (REQ-008)
|
|
692
|
+
- Complexity: Medium (6h)
|
|
693
|
+
- Dependencies: Phase 2 complete
|
|
694
|
+
- Owner: Backend team
|
|
695
|
+
|
|
696
|
+
- [ ] Task 3.2: Implement SMS code delivery (REQ-009)
|
|
697
|
+
- Complexity: Medium (5h)
|
|
698
|
+
- Dependencies: Task 3.1
|
|
699
|
+
- Owner: Backend team
|
|
700
|
+
|
|
701
|
+
- [ ] Task 3.3: Add SMS option to 2FA setup UI (REQ-010)
|
|
702
|
+
- Complexity: Small (4h)
|
|
703
|
+
- Dependencies: Task 3.1
|
|
704
|
+
- Owner: Frontend team
|
|
705
|
+
|
|
706
|
+
**Validation Checkpoint:** Users can enable and use SMS 2FA
|
|
707
|
+
|
|
708
|
+
---
|
|
709
|
+
|
|
710
|
+
### Phase 4: Testing & Polish (Week 6)
|
|
711
|
+
**Goal:** Comprehensive testing, bug fixes, performance optimization
|
|
712
|
+
|
|
713
|
+
**Tasks:**
|
|
714
|
+
- [ ] Task 4.1: Write comprehensive test suite
|
|
715
|
+
- Complexity: Large (12h)
|
|
716
|
+
- Dependencies: Phase 3 complete
|
|
717
|
+
- Owner: QA team
|
|
718
|
+
|
|
719
|
+
- [ ] Task 4.2: Performance testing and optimization
|
|
720
|
+
- Complexity: Medium (8h)
|
|
721
|
+
- Dependencies: Task 4.1
|
|
722
|
+
- Owner: Backend team
|
|
723
|
+
|
|
724
|
+
- [ ] Task 4.3: Security audit and penetration testing
|
|
725
|
+
- Complexity: Large (16h)
|
|
726
|
+
- Dependencies: Task 4.1
|
|
727
|
+
- Owner: Security team
|
|
728
|
+
|
|
729
|
+
- [ ] Task 4.4: Bug fixes from testing
|
|
730
|
+
- Complexity: Variable
|
|
731
|
+
- Dependencies: Tasks 4.1-4.3
|
|
732
|
+
- Owner: All teams
|
|
733
|
+
|
|
734
|
+
**Validation Checkpoint:** All tests passing, no critical bugs
|
|
735
|
+
|
|
736
|
+
---
|
|
737
|
+
|
|
738
|
+
### Phase 5: Deployment & Rollout (Week 7-8)
|
|
739
|
+
**Goal:** Gradual rollout to production
|
|
740
|
+
|
|
741
|
+
**Tasks:**
|
|
742
|
+
- [ ] Task 5.1: Deploy to staging
|
|
743
|
+
- [ ] Task 5.2: Enable for 5% of users (beta)
|
|
744
|
+
- [ ] Task 5.3: Monitor and adjust
|
|
745
|
+
- [ ] Task 5.4: Rollout to 25% of users
|
|
746
|
+
- [ ] Task 5.5: Rollout to 50% of users
|
|
747
|
+
- [ ] Task 5.6: Rollout to 100% of users
|
|
748
|
+
- [ ] Task 5.7: Launch communication campaign
|
|
749
|
+
|
|
750
|
+
**Validation Checkpoint:** Successful production deployment, metrics improving
|
|
751
|
+
|
|
752
|
+
---
|
|
753
|
+
|
|
754
|
+
### Task Dependencies Visualization
|
|
755
|
+
|
|
756
|
+
```
|
|
757
|
+
Phase 1 (Foundation):
|
|
758
|
+
1.1 (Schema) → 1.2 (Secret Gen) → 1.3 (TOTP Validation)
|
|
759
|
+
|
|
760
|
+
Phase 2 (Core Features):
|
|
761
|
+
1.3 → 2.2 (Enable API) → 2.3 (Login Verification)
|
|
762
|
+
1.3 → 2.1 (Setup UI)
|
|
763
|
+
2.2 → 2.4 (Backup Codes)
|
|
764
|
+
|
|
765
|
+
Phase 3 (SMS):
|
|
766
|
+
2.2 → 3.1 (Twilio) → 3.2 (SMS Delivery)
|
|
767
|
+
3.1 → 3.3 (SMS UI)
|
|
768
|
+
|
|
769
|
+
Phase 4 (Testing):
|
|
770
|
+
Phase 3 → 4.1 (Tests) → 4.2 (Performance) & 4.3 (Security) → 4.4 (Fixes)
|
|
771
|
+
|
|
772
|
+
Phase 5 (Deployment):
|
|
773
|
+
Phase 4 → 5.1 → 5.2 → 5.3 → 5.4 → 5.5 → 5.6 → 5.7
|
|
774
|
+
|
|
775
|
+
Critical Path: 1.1 → 1.2 → 1.3 → 2.2 → 2.3 → 3.1 → 3.2 → 4.1 → 4.4 → 5.7
|
|
776
|
+
```
|
|
777
|
+
|
|
778
|
+
---
|
|
779
|
+
|
|
780
|
+
### Effort Estimation
|
|
781
|
+
|
|
782
|
+
**Total Estimated Effort:**
|
|
783
|
+
- Phase 1: 10 hours
|
|
784
|
+
- Phase 2: 28 hours
|
|
785
|
+
- Phase 3: 15 hours
|
|
786
|
+
- Phase 4: 36 hours
|
|
787
|
+
- Phase 5: 20 hours (includes monitoring)
|
|
788
|
+
- **Total: ~109 hours** (~3 weeks with 2-person team)
|
|
789
|
+
|
|
790
|
+
**Risk Buffer:** +20% (22 hours) for unknowns
|
|
791
|
+
**Final Estimate:** ~130 hours (~4 weeks)
|
|
792
|
+
|
|
793
|
+
---
|
|
794
|
+
|
|
795
|
+
## Out of Scope
|
|
796
|
+
|
|
797
|
+
Explicitly NOT included in this release:
|
|
798
|
+
|
|
799
|
+
1. **Biometric Authentication** (fingerprint, Face ID)
|
|
800
|
+
- Reason: Different security model, requires mobile app
|
|
801
|
+
- Future: Consider for v2.0
|
|
802
|
+
|
|
803
|
+
2. **Hardware Security Keys** (YubiKey, etc.)
|
|
804
|
+
- Reason: Low user demand (< 5% requested)
|
|
805
|
+
- Future: Evaluate after 2FA adoption metrics
|
|
806
|
+
|
|
807
|
+
3. **Multi-Device 2FA Management**
|
|
808
|
+
- Reason: Complexity, can add later
|
|
809
|
+
- Workaround: Users can disable and re-enable to change device
|
|
810
|
+
|
|
811
|
+
4. **2FA Recovery Without Backup Codes**
|
|
812
|
+
- Reason: Security risk
|
|
813
|
+
- Users must save backup codes or contact support
|
|
814
|
+
|
|
815
|
+
5. **Admin-Enforced 2FA**
|
|
816
|
+
- Reason: Optional for v1.0
|
|
817
|
+
- Future: Add organization-level policies in v2.0
|
|
818
|
+
|
|
819
|
+
---
|
|
820
|
+
|
|
821
|
+
## Open Questions & Risks
|
|
822
|
+
|
|
823
|
+
### Open Questions
|
|
824
|
+
|
|
825
|
+
#### Q1: Should we require 2FA for all admin users?
|
|
826
|
+
- **Current Status:** Optional for all users
|
|
827
|
+
- **Options:** (A) Keep optional, (B) Require for admins only, (C) Require for all users
|
|
828
|
+
- **Owner:** Product team
|
|
829
|
+
- **Deadline:** Week 2 (before Phase 2 starts)
|
|
830
|
+
- **Impact:** Medium (affects UI flow and enforcement logic)
|
|
831
|
+
|
|
832
|
+
#### Q2: What's the SMS provider SLA and cost?
|
|
833
|
+
- **Current Status:** Researching Twilio alternatives
|
|
834
|
+
- **Options:** (A) Twilio, (B) AWS SNS, (C) Vonage
|
|
835
|
+
- **Owner:** DevOps team
|
|
836
|
+
- **Deadline:** Week 4 (before Phase 3)
|
|
837
|
+
- **Impact:** Low (implementation similar across providers)
|
|
838
|
+
|
|
839
|
+
#### Q3: Should we support international phone numbers for SMS?
|
|
840
|
+
- **Current Status:** Twilio supports it, but adds cost
|
|
841
|
+
- **Options:** (A) US only, (B) All countries, (C) Tier 1 countries only
|
|
842
|
+
- **Owner:** Business team (cost analysis)
|
|
843
|
+
- **Deadline:** Week 4
|
|
844
|
+
- **Impact:** Medium (affects user experience for international users)
|
|
845
|
+
|
|
846
|
+
---
|
|
847
|
+
|
|
848
|
+
### Risks & Mitigation
|
|
849
|
+
|
|
850
|
+
| Risk | Likelihood | Impact | Severity | Mitigation | Contingency |
|
|
851
|
+
|------|------------|--------|----------|------------|-------------|
|
|
852
|
+
| SMS delivery failures | High | High | **Critical** | Use reliable provider (Twilio), implement retry logic | Fall back to TOTP, provide clear error messages |
|
|
853
|
+
| Users lose 2FA device and backup codes | Medium | High | **High** | Educate users about backup codes, support recovery process | Manual verification by support team |
|
|
854
|
+
| Performance degradation on login | Low | Medium | **Medium** | Load testing, caching, optimize DB queries | Feature flag to disable temporarily |
|
|
855
|
+
| Security vulnerability discovered | Low | Critical | **High** | Security audit, pen testing, follow OWASP best practices | Patch immediately, coordinate disclosure |
|
|
856
|
+
| Low adoption rate (< 20%) | Medium | Medium | **Medium** | In-app prompts, email campaign, incentivize adoption | Gather feedback, improve UX |
|
|
857
|
+
|
|
858
|
+
---
|
|
859
|
+
|
|
860
|
+
## Validation Checkpoints
|
|
861
|
+
|
|
862
|
+
### Checkpoint 1: End of Phase 1
|
|
863
|
+
**Criteria:**
|
|
864
|
+
- [ ] Database schema deployed to staging
|
|
865
|
+
- [ ] TOTP generation and validation working
|
|
866
|
+
- [ ] Unit tests passing (> 80% coverage for new code)
|
|
867
|
+
|
|
868
|
+
**If Failed:** Revisit schema design, fix validation logic before continuing
|
|
869
|
+
|
|
870
|
+
---
|
|
871
|
+
|
|
872
|
+
### Checkpoint 2: End of Phase 2
|
|
873
|
+
**Criteria:**
|
|
874
|
+
- [ ] Users can enable 2FA via UI
|
|
875
|
+
- [ ] Login flow requires 2FA verification
|
|
876
|
+
- [ ] Backup codes generated and functional
|
|
877
|
+
- [ ] Integration tests passing
|
|
878
|
+
|
|
879
|
+
**If Failed:** Address UX issues, fix login flow bugs, don't proceed to SMS
|
|
880
|
+
|
|
881
|
+
---
|
|
882
|
+
|
|
883
|
+
### Checkpoint 3: End of Phase 3
|
|
884
|
+
**Criteria:**
|
|
885
|
+
- [ ] SMS codes delivered successfully (> 95% success rate)
|
|
886
|
+
- [ ] Users can choose TOTP or SMS method
|
|
887
|
+
- [ ] All features working in staging
|
|
888
|
+
|
|
889
|
+
**If Failed:** Debug SMS integration, consider alternative provider
|
|
890
|
+
|
|
891
|
+
---
|
|
892
|
+
|
|
893
|
+
### Checkpoint 4: End of Phase 4
|
|
894
|
+
**Criteria:**
|
|
895
|
+
- [ ] All tests passing (unit, integration, E2E)
|
|
896
|
+
- [ ] Performance benchmarks met (< 200ms p95)
|
|
897
|
+
- [ ] Security audit complete with no critical findings
|
|
898
|
+
- [ ] Zero known critical bugs
|
|
899
|
+
|
|
900
|
+
**If Failed:** Fix bugs and re-test before deployment
|
|
901
|
+
|
|
902
|
+
---
|
|
903
|
+
|
|
904
|
+
### Checkpoint 5: Production Rollout
|
|
905
|
+
**Criteria (at each rollout stage):**
|
|
906
|
+
- [ ] Error rate < 0.1%
|
|
907
|
+
- [ ] No degradation in login success rate
|
|
908
|
+
- [ ] 2FA verification success rate > 95%
|
|
909
|
+
- [ ] No increase in support tickets
|
|
910
|
+
|
|
911
|
+
**If Failed:** Rollback, investigate issues, fix before next stage
|
|
912
|
+
|
|
913
|
+
---
|
|
914
|
+
|
|
915
|
+
## Appendix: Task Breakdown Hints
|
|
916
|
+
|
|
917
|
+
### Suggested Taskmaster Task Structure
|
|
918
|
+
|
|
919
|
+
**Setup & Infrastructure (3 tasks, ~10 hours)**
|
|
920
|
+
1. Database migration for 2FA tables (3h)
|
|
921
|
+
2. Set up environment variables and secrets (2h)
|
|
922
|
+
3. Configure SMS provider (Twilio) integration (5h)
|
|
923
|
+
|
|
924
|
+
**Backend Implementation (8 tasks, ~45 hours)**
|
|
925
|
+
4. Implement TOTP secret generation (2h)
|
|
926
|
+
5. Implement TOTP code validation (5h)
|
|
927
|
+
6. Build enable 2FA API endpoint (6h)
|
|
928
|
+
7. Build verify 2FA API endpoint (5h)
|
|
929
|
+
8. Implement backup code generation (4h)
|
|
930
|
+
9. Add 2FA verification to login flow (10h)
|
|
931
|
+
10. Implement SMS code delivery (5h)
|
|
932
|
+
11. Add rate limiting middleware (3h)
|
|
933
|
+
12. Build disable 2FA API endpoint (5h)
|
|
934
|
+
|
|
935
|
+
**Frontend Implementation (6 tasks, ~30 hours)**
|
|
936
|
+
13. Create 2FA setup page UI (8h)
|
|
937
|
+
14. Build QR code display component (3h)
|
|
938
|
+
15. Create SMS phone verification flow (6h)
|
|
939
|
+
16. Add 2FA verification step to login (6h)
|
|
940
|
+
17. Build backup codes display/download (4h)
|
|
941
|
+
18. Add 2FA management to account settings (3h)
|
|
942
|
+
|
|
943
|
+
**Testing (5 tasks, ~24 hours)**
|
|
944
|
+
19. Write unit tests for backend logic (8h)
|
|
945
|
+
20. Write integration tests for API endpoints (6h)
|
|
946
|
+
21. Write E2E tests for user flows (6h)
|
|
947
|
+
22. Performance testing (4h)
|
|
948
|
+
|
|
949
|
+
**Documentation & Deployment (4 tasks, ~10 hours)**
|
|
950
|
+
23. Write API documentation (3h)
|
|
951
|
+
24. Create user guide for 2FA setup (2h)
|
|
952
|
+
25. Deploy to staging (2h)
|
|
953
|
+
26. Production rollout and monitoring (3h)
|
|
954
|
+
|
|
955
|
+
**Total: 26 tasks, ~119 hours**
|
|
956
|
+
|
|
957
|
+
### Parallelizable Tasks
|
|
958
|
+
|
|
959
|
+
**Can work in parallel:**
|
|
960
|
+
- Backend tasks (4-12) and Frontend tasks (13-18) can run concurrently
|
|
961
|
+
- Testing tasks (19-21) can run concurrently once implementation done
|
|
962
|
+
- Documentation (23-24) can start during testing phase
|
|
963
|
+
|
|
964
|
+
**Must be sequential:**
|
|
965
|
+
- Setup (1-3) → Implementation (4-18) → Testing (19-22) → Deployment (23-26)
|
|
966
|
+
|
|
967
|
+
### Critical Path Tasks
|
|
968
|
+
1. Database migration (1)
|
|
969
|
+
2. TOTP generation (4)
|
|
970
|
+
3. TOTP validation (5)
|
|
971
|
+
4. Enable 2FA endpoint (6)
|
|
972
|
+
5. Verify 2FA endpoint (7)
|
|
973
|
+
6. Add 2FA to login (9)
|
|
974
|
+
7. Testing (19-22)
|
|
975
|
+
8. Deployment (25-26)
|
|
976
|
+
|
|
977
|
+
**Critical path duration:** ~55 hours (~2 weeks with full-time dev)
|
|
978
|
+
|
|
979
|
+
---
|
|
980
|
+
|
|
981
|
+
**End of PRD**
|
|
982
|
+
|
|
983
|
+
*This PRD is optimized for taskmaster AI task generation. All requirements include task breakdown hints, complexity estimates, and dependency mapping to enable effective automated task planning.*
|