saafe-redirection-flow 2.0.0 → 2.2.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.
Files changed (38) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/aa-redirection-1607251826.zip +0 -0
  3. package/docs/features/account-discovery.md +803 -0
  4. package/docs/features/authentication.md +583 -0
  5. package/docs/features/consent-management.md +740 -0
  6. package/docs/features/index.md +206 -0
  7. package/docs/features/navigation-routing.md +846 -0
  8. package/docs/features/overview.md +554 -0
  9. package/docs/features/theming-internationalization.md +982 -0
  10. package/docs/index.md +1 -1
  11. package/package.json +1 -1
  12. package/src/components/AutoDiscoveryLoader.tsx +29 -0
  13. package/src/components/LinkedAccountTypeAccordion.tsx +154 -0
  14. package/src/components/alert/alert.tsx +10 -4
  15. package/src/components/modal/HelpModal.tsx +122 -0
  16. package/src/components/session/SessionTimer.tsx +20 -33
  17. package/src/components/title/AppBar.tsx +1 -1
  18. package/src/components/ui/bottom-sheet.tsx +1 -1
  19. package/src/components/ui/frosted-panel.tsx +0 -2
  20. package/src/components/ui/otp-input.tsx +38 -6
  21. package/src/hooks/use-account-discovery.ts +13 -6
  22. package/src/hooks/use-auto-discovery.ts +226 -0
  23. package/src/index.css +3 -0
  24. package/src/pages/accounts/AccountsToProceed.tsx +598 -59
  25. package/src/pages/accounts/Discover.tsx +127 -9
  26. package/src/pages/accounts/DiscoverAccount.tsx +195 -42
  27. package/src/pages/accounts/LinkSelectedAccounts.tsx +15 -9
  28. package/src/pages/accounts/OldUser.tsx +184 -79
  29. package/src/pages/accounts/link-accounts.tsx +19 -11
  30. package/src/pages/consent/ReviewConsent.tsx +19 -10
  31. package/src/pages/consent/rejected.tsx +17 -8
  32. package/src/pages/consent/success.tsx +125 -76
  33. package/src/services/api/account.service.ts +2 -2
  34. package/src/store/fip.store.ts +74 -28
  35. package/src/store/redirect.store.ts +19 -0
  36. package/src/utils/auto-discovery.ts +126 -0
  37. package/src/utils/toast-helpers.ts +5 -0
  38. package/stage-aa-2506251021.zip +0 -0
@@ -0,0 +1,554 @@
1
+ # SAAFE Redirection Flow - Feature Documentation Overview
2
+
3
+ ## Introduction
4
+
5
+ This document provides a comprehensive overview of all features and modules in the SAAFE Redirection Flow application. Each feature has been carefully designed to work together to create a seamless, secure, and user-friendly account linking experience.
6
+
7
+ ## Feature Module Index
8
+
9
+ ### Core Features
10
+
11
+ 1. **[Authentication Module](./authentication.md)**
12
+ - User authentication and session management
13
+ - OTP verification and security
14
+ - Platform-specific authentication flows
15
+
16
+ 2. **[Account Discovery Module](./account-discovery.md)**
17
+ - Financial Institution Provider (FIP) management
18
+ - Auto-discovery of user accounts
19
+ - Manual account selection and linking
20
+
21
+ 3. **[Consent Management Module](./consent-management.md)**
22
+ - Data sharing consent workflows
23
+ - Regulatory compliance (GDPR, RBI)
24
+ - Consent review and approval processes
25
+
26
+ 4. **[Navigation and Routing Module](./navigation-routing.md)**
27
+ - Step-based navigation system
28
+ - Dynamic routing based on user state
29
+ - Platform-specific navigation behaviors
30
+
31
+ 5. **[Theming and Internationalization Module](./theming-internationalization.md)**
32
+ - Multi-theme support (light, dark, system)
33
+ - Multi-language support (7 languages)
34
+ - RTL (Right-to-Left) language support
35
+
36
+ ## Architecture Overview
37
+
38
+ ### System Architecture
39
+
40
+ ```mermaid
41
+ graph TB
42
+ subgraph "User Interface Layer"
43
+ A[Authentication] --> B[Account Discovery]
44
+ B --> C[Consent Management]
45
+ C --> D[Success/Rejection]
46
+ end
47
+
48
+ subgraph "Core Services Layer"
49
+ E[Navigation & Routing]
50
+ F[State Management]
51
+ G[API Integration]
52
+ H[Error Handling]
53
+ end
54
+
55
+ subgraph "Platform & Presentation Layer"
56
+ I[Theming System]
57
+ J[Internationalization]
58
+ K[Platform Detection]
59
+ L[Analytics & Tracking]
60
+ end
61
+
62
+ subgraph "External Integrations"
63
+ M[Financial Institution APIs]
64
+ N[PostHog Analytics]
65
+ O[SDK Integration]
66
+ end
67
+
68
+ A -.-> E
69
+ B -.-> F
70
+ C -.-> G
71
+ D -.-> H
72
+
73
+ E --> I
74
+ F --> J
75
+ G --> K
76
+ H --> L
77
+
78
+ G --> M
79
+ L --> N
80
+ K --> O
81
+ ```
82
+
83
+ ### Data Flow Architecture
84
+
85
+ ```mermaid
86
+ sequenceDiagram
87
+ participant User
88
+ participant Auth as Authentication
89
+ participant Discovery as Account Discovery
90
+ participant Consent as Consent Management
91
+ participant API as Backend APIs
92
+ participant Analytics as Analytics
93
+
94
+ User->>Auth: Login with credentials
95
+ Auth->>API: Validate credentials
96
+ API-->>Auth: Authentication token
97
+ Auth->>Analytics: Track login event
98
+
99
+ Auth->>Discovery: Navigate to discovery
100
+ Discovery->>API: Fetch available FIPs
101
+ API-->>Discovery: FIP list with categories
102
+ Discovery->>Analytics: Track FIP selections
103
+
104
+ User->>Discovery: Select accounts to link
105
+ Discovery->>Consent: Submit selected accounts
106
+ Consent->>API: Prepare consent data
107
+ API-->>Consent: Consent details
108
+
109
+ User->>Consent: Approve/Reject consent
110
+ Consent->>API: Submit consent decision
111
+ API-->>Consent: Final status
112
+ Consent->>Analytics: Track completion
113
+ ```
114
+
115
+ ## Feature Integration Matrix
116
+
117
+ ### How Features Work Together
118
+
119
+ | Feature | Authentication | Account Discovery | Consent Management | Navigation | Theming/i18n |
120
+ |---------|---------------|------------------|-------------------|------------|-------------|
121
+ | **Authentication** | ➖ | Provides session for discovery | Validates user for consent | Controls routing after login | Respects language/theme preferences |
122
+ | **Account Discovery** | Requires authentication | ➖ | Prepares accounts for consent | Manages discovery flow steps | Displays in user's language |
123
+ | **Consent Management** | Validates session | Uses discovered accounts | ➖ | Final flow destination | Compliance with regional regulations |
124
+ | **Navigation** | Guards protected routes | Manages discovery steps | Routes to consent review | ➖ | Adapts to platform/language |
125
+ | **Theming/i18n** | Styled login interface | Localized FIP names | Translated consent terms | Themed navigation | ➖ |
126
+
127
+ ## User Journey Integration
128
+
129
+ ### Complete Flow Integration
130
+
131
+ ```mermaid
132
+ graph LR
133
+ A[App Load] --> B[URL Decode]
134
+ B --> C[Theme Init]
135
+ C --> D[Language Init]
136
+ D --> E[Authentication]
137
+
138
+ E --> F{Auth Success?}
139
+ F -->|Yes| G[Account Discovery]
140
+ F -->|No| H[Error Handling]
141
+
142
+ G --> I[FIP Selection]
143
+ I --> J[Account Discovery]
144
+ J --> K[Account Selection]
145
+
146
+ K --> L[Consent Review]
147
+ L --> M{Consent Decision}
148
+ M -->|Approve| N[Success]
149
+ M -->|Reject| O[Rejection]
150
+
151
+ N --> P[Analytics]
152
+ O --> P
153
+ H --> P
154
+ ```
155
+
156
+ ### State Management Integration
157
+
158
+ **Global State Flow**:
159
+ ```typescript
160
+ // Combined state from all modules
161
+ interface GlobalAppState {
162
+ // Authentication state
163
+ auth: {
164
+ isAuthenticated: boolean;
165
+ user: User | null;
166
+ sessionToken: string | null;
167
+ };
168
+
169
+ // Discovery state
170
+ fip: {
171
+ categories: string[];
172
+ selectedAccounts: AccountToLink[];
173
+ discoveryResults: AutoDiscoveryResponse;
174
+ };
175
+
176
+ // Consent state
177
+ consent: {
178
+ consentData: ConsentData | null;
179
+ userDecision: ConsentDecision | null;
180
+ };
181
+
182
+ // Navigation state
183
+ navigation: {
184
+ currentStep: number;
185
+ completedSteps: number[];
186
+ isBlocked: boolean;
187
+ };
188
+
189
+ // Theme/Language state
190
+ ui: {
191
+ theme: Theme;
192
+ language: string;
193
+ isRTL: boolean;
194
+ };
195
+ }
196
+ ```
197
+
198
+ ## Platform-Specific Integrations
199
+
200
+ ### Mobile Platform Integration
201
+
202
+ **WebView Optimization**:
203
+ - Authentication: Touch-optimized login forms
204
+ - Discovery: Swipe gestures for FIP browsing
205
+ - Consent: Bottom sheet for document display
206
+ - Navigation: Hardware back button handling
207
+ - Theming: Respect system dark mode
208
+
209
+ ### Web Platform Integration
210
+
211
+ **Browser Optimization**:
212
+ - Authentication: Keyboard navigation support
213
+ - Discovery: Advanced filtering and search
214
+ - Consent: New tab document opening
215
+ - Navigation: Browser history management
216
+ - Theming: CSS media query responsive design
217
+
218
+ ### SDK Integration Points
219
+
220
+ **Communication Channels**:
221
+ ```typescript
222
+ // PostMessage API for SDK communication
223
+ interface SDKMessagePayload {
224
+ type: 'AUTH_SUCCESS' | 'ACCOUNTS_LINKED' | 'CONSENT_APPROVED' | 'ERROR';
225
+ data: {
226
+ sessionId?: string;
227
+ linkedAccounts?: AccountToLink[];
228
+ consentId?: string;
229
+ error?: ErrorDetails;
230
+ };
231
+ timestamp: string;
232
+ }
233
+
234
+ // Send result to parent application
235
+ const notifyParentApp = (payload: SDKMessagePayload) => {
236
+ if (window.parent !== window) {
237
+ window.parent.postMessage(payload, '*');
238
+ }
239
+ };
240
+ ```
241
+
242
+ ## Security Integration
243
+
244
+ ### Cross-Module Security
245
+
246
+ **Security Measures Applied Across Features**:
247
+
248
+ 1. **Authentication Security**
249
+ - Session token validation
250
+ - Automatic token refresh
251
+ - Secure credential transmission
252
+
253
+ 2. **Data Protection**
254
+ - Encrypted URL parameters
255
+ - Secure API communication
256
+ - PII data handling
257
+
258
+ 3. **Navigation Security**
259
+ - Route protection
260
+ - Session timeout handling
261
+ - CSRF protection
262
+
263
+ 4. **Consent Security**
264
+ - Cryptographic signatures
265
+ - Audit trail maintenance
266
+ - Regulatory compliance
267
+
268
+ ## Performance Integration
269
+
270
+ ### Optimization Strategies
271
+
272
+ **Cross-Module Performance**:
273
+
274
+ 1. **Loading Optimization**
275
+ - Progressive loading of features
276
+ - Lazy loading of translations
277
+ - Component code splitting
278
+
279
+ 2. **Caching Strategy**
280
+ - FIP data caching
281
+ - Translation caching
282
+ - Theme preference caching
283
+ - Session state persistence
284
+
285
+ 3. **Bundle Optimization**
286
+ - Tree shaking unused code
287
+ - Dynamic imports for features
288
+ - Minimized asset loading
289
+
290
+ ## Analytics Integration
291
+
292
+ ### Comprehensive Tracking
293
+
294
+ **Cross-Feature Analytics**:
295
+ ```typescript
296
+ // Unified analytics events across features
297
+ const ANALYTICS_EVENTS = {
298
+ // Authentication events
299
+ AUTH_STARTED: 'auth_started',
300
+ AUTH_SUCCESS: 'auth_success',
301
+ AUTH_FAILED: 'auth_failed',
302
+
303
+ // Discovery events
304
+ DISCOVERY_STARTED: 'discovery_started',
305
+ FIP_SELECTED: 'fip_selected',
306
+ ACCOUNTS_DISCOVERED: 'accounts_discovered',
307
+
308
+ // Consent events
309
+ CONSENT_REVIEWED: 'consent_reviewed',
310
+ CONSENT_APPROVED: 'consent_approved',
311
+ CONSENT_REJECTED: 'consent_rejected',
312
+
313
+ // Navigation events
314
+ STEP_COMPLETED: 'step_completed',
315
+ FLOW_ABANDONED: 'flow_abandoned',
316
+
317
+ // UI events
318
+ THEME_CHANGED: 'theme_changed',
319
+ LANGUAGE_CHANGED: 'language_changed'
320
+ };
321
+ ```
322
+
323
+ ## Error Handling Integration
324
+
325
+ ### Unified Error Management
326
+
327
+ **Cross-Module Error Handling**:
328
+ ```typescript
329
+ // Global error handling strategy
330
+ interface AppError {
331
+ module: 'AUTH' | 'DISCOVERY' | 'CONSENT' | 'NAVIGATION' | 'UI';
332
+ type: string;
333
+ message: string;
334
+ details?: any;
335
+ recoverable: boolean;
336
+ userMessage: string;
337
+ }
338
+
339
+ const handleGlobalError = (error: AppError) => {
340
+ // Log error for monitoring
341
+ logError(error);
342
+
343
+ // Track error analytics
344
+ trackEvent('ERROR_OCCURRED', {
345
+ module: error.module,
346
+ type: error.type,
347
+ recoverable: error.recoverable
348
+ });
349
+
350
+ // Show user-friendly message
351
+ if (error.recoverable) {
352
+ showToast(error.userMessage, 'error');
353
+ } else {
354
+ showErrorPage(error.userMessage);
355
+ }
356
+
357
+ // Attempt recovery if possible
358
+ if (error.recoverable) {
359
+ attemptErrorRecovery(error);
360
+ }
361
+ };
362
+ ```
363
+
364
+ ## Testing Integration
365
+
366
+ ### Cross-Module Testing Strategy
367
+
368
+ **Integration Testing Approach**:
369
+
370
+ 1. **End-to-End Flow Tests**
371
+ - Complete user journey testing
372
+ - Cross-feature interaction testing
373
+ - Platform-specific flow testing
374
+
375
+ 2. **Integration Tests**
376
+ - API integration testing
377
+ - State management testing
378
+ - Component interaction testing
379
+
380
+ 3. **Unit Tests**
381
+ - Individual feature testing
382
+ - Hook and utility testing
383
+ - Component behavior testing
384
+
385
+ **Test Configuration**:
386
+ ```typescript
387
+ // Unified test setup
388
+ const setupIntegrationTest = () => {
389
+ const mockProviders = (
390
+ <QueryProvider>
391
+ <ThemeProvider>
392
+ <LanguageProvider>
393
+ <RTLProvider>
394
+ <NavigationBlockProvider>
395
+ <AuthProvider>
396
+ <Router>
397
+ <App />
398
+ </Router>
399
+ </AuthProvider>
400
+ </NavigationBlockProvider>
401
+ </RTLProvider>
402
+ </LanguageProvider>
403
+ </ThemeProvider>
404
+ </QueryProvider>
405
+ );
406
+
407
+ return render(mockProviders);
408
+ };
409
+ ```
410
+
411
+ ## Configuration Integration
412
+
413
+ ### Unified Configuration Management
414
+
415
+ **Environment-Specific Configuration**:
416
+ ```typescript
417
+ // Centralized configuration
418
+ interface AppConfig {
419
+ // API configuration
420
+ api: {
421
+ baseUrl: string;
422
+ timeout: number;
423
+ retryAttempts: number;
424
+ };
425
+
426
+ // Authentication configuration
427
+ auth: {
428
+ sessionDuration: number;
429
+ refreshThreshold: number;
430
+ otpLength: number;
431
+ };
432
+
433
+ // Discovery configuration
434
+ discovery: {
435
+ maxConcurrentDiscoveries: number;
436
+ discoveryTimeout: number;
437
+ cacheTimeout: number;
438
+ };
439
+
440
+ // UI configuration
441
+ ui: {
442
+ defaultTheme: Theme;
443
+ defaultLanguage: string;
444
+ enableAnimations: boolean;
445
+ };
446
+
447
+ // Analytics configuration
448
+ analytics: {
449
+ enabled: boolean;
450
+ trackingId: string;
451
+ sampleRate: number;
452
+ };
453
+ }
454
+
455
+ // Environment-specific configs
456
+ const getConfig = (): AppConfig => {
457
+ const env = import.meta.env.VITE_MODE;
458
+
459
+ switch (env) {
460
+ case 'production':
461
+ return PRODUCTION_CONFIG;
462
+ case 'stage':
463
+ return STAGE_CONFIG;
464
+ case 'sandbox':
465
+ return SANDBOX_CONFIG;
466
+ default:
467
+ return DEVELOPMENT_CONFIG;
468
+ }
469
+ };
470
+ ```
471
+
472
+ ## Deployment Integration
473
+
474
+ ### Multi-Environment Strategy
475
+
476
+ **Environment-Specific Features**:
477
+
478
+ | Environment | Authentication | Discovery | Consent | Analytics | Debug |
479
+ |-------------|---------------|-----------|---------|-----------|--------|
480
+ | **Production** | Full security | All FIPs | Full compliance | Enabled | Disabled |
481
+ | **Stage** | Test credentials | Limited FIPs | Test consent | Enabled | Limited |
482
+ | **Sandbox** | Mock auth | Mock FIPs | Mock consent | Disabled | Enabled |
483
+ | **Development** | Local auth | Local FIPs | Local consent | Disabled | Full |
484
+
485
+ **Build Configuration**:
486
+ ```typescript
487
+ // Feature flags per environment
488
+ const FEATURE_FLAGS = {
489
+ production: {
490
+ enableMockAuth: false,
491
+ enableDebugMode: false,
492
+ enableTestFips: false,
493
+ enableAnalytics: true
494
+ },
495
+ sandbox: {
496
+ enableMockAuth: true,
497
+ enableDebugMode: true,
498
+ enableTestFips: true,
499
+ enableAnalytics: false
500
+ }
501
+ };
502
+ ```
503
+
504
+ ## Future Roadmap Integration
505
+
506
+ ### Planned Cross-Module Enhancements
507
+
508
+ **Phase 1: Enhanced User Experience**
509
+ - Voice navigation across all modules
510
+ - AI-powered account recommendations
511
+ - Real-time collaboration features
512
+ - Advanced accessibility improvements
513
+
514
+ **Phase 2: Advanced Security**
515
+ - Biometric authentication integration
516
+ - Zero-trust security model
517
+ - Advanced fraud detection
518
+ - Blockchain consent records
519
+
520
+ **Phase 3: Intelligence and Automation**
521
+ - Machine learning optimization
522
+ - Predictive user flows
523
+ - Automated compliance checking
524
+ - Smart error recovery
525
+
526
+ **Phase 4: Ecosystem Integration**
527
+ - Open banking standard compliance
528
+ - Third-party app ecosystem
529
+ - API marketplace integration
530
+ - White-label solutions
531
+
532
+ ## Conclusion
533
+
534
+ The SAAFE Redirection Flow represents a sophisticated integration of multiple feature modules working together to create a comprehensive account linking solution. Each module is designed with clear boundaries and well-defined interfaces, allowing for independent development while maintaining seamless integration.
535
+
536
+ The modular architecture ensures:
537
+ - **Scalability**: Easy addition of new features
538
+ - **Maintainability**: Clear separation of concerns
539
+ - **Testability**: Independent and integration testing
540
+ - **Flexibility**: Platform and environment adaptability
541
+ - **Reliability**: Robust error handling and recovery
542
+
543
+ This documentation serves as a guide for developers, architects, and stakeholders to understand how the various components work together to deliver a world-class account linking experience.
544
+
545
+ ## Additional Resources
546
+
547
+ - **[Architecture Documentation](../architecture.md)** - Technical architecture details
548
+ - **[Component Library](../components.md)** - UI component documentation
549
+ - **[SDK Integration Guide](../sdk-integration.md)** - Integration instructions
550
+ - **[API Documentation](../api-reference.md)** - API endpoint specifications
551
+ - **[Deployment Guide](../DEPLOYMENT_WORKFLOW.md)** - Deployment procedures
552
+ - **[Testing Guide](../testing-strategy.md)** - Testing methodologies
553
+
554
+ For specific implementation details, refer to the individual feature module documentation linked above.