|
23 | 23 |
|
24 | 24 | builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); |
25 | 25 |
|
26 | | -// Register diagnostics service - only available in DEBUG builds |
| 26 | +// ============================================================================ |
| 27 | +// SECURITY NOTE: Diagnostics are DEBUG-only and expose full state snapshots |
| 28 | +// Never ship diagnostic features to production |
| 29 | +// ============================================================================ |
27 | 30 | #if DEBUG |
28 | 31 | builder.Services.AddStoreDiagnostics(); |
29 | 32 | #endif |
|
46 | 49 |
|
47 | 50 | // ============================================================================ |
48 | 51 | // Counter Store - Basic example with DevTools and Logging |
| 52 | +// SECURITY: WithDefaults() includes DevTools - only use in DEBUG builds |
| 53 | +// For production, use .WithLogging() instead |
49 | 54 | // ============================================================================ |
50 | 55 | builder.Services.AddStore( |
51 | 56 | new CounterState(0), |
|
92 | 97 | // Shopping Cart Store - Demonstrates persistence with LocalStorage |
93 | 98 | // State survives page refreshes and browser restarts |
94 | 99 | // WithPersistence automatically loads and saves state - no manual hydration needed! |
| 100 | +// SECURITY: For production with sensitive data, use TransformOnSave to exclude |
| 101 | +// sensitive fields and add IStateValidator to validate hydrated state |
95 | 102 | // ============================================================================ |
96 | 103 | builder.Services.AddStore( |
97 | 104 | ShoppingCartState.Empty, |
|
185 | 192 | // ============================================================================ |
186 | 193 | // Tab Sync Demo Store - Demonstrates cross-tab synchronization |
187 | 194 | // Real-time state sync across browser tabs using BroadcastChannel |
| 195 | +// SECURITY: For production with sensitive data, enable message signing: |
| 196 | +// .EnableMessageSigning() |
| 197 | +// .RequireValidSignature(true) |
| 198 | +// .MaxMessageAgeSeconds(30) |
| 199 | +// .ValidateTimestamp(true) |
188 | 200 | // ============================================================================ |
189 | 201 | builder.Services.AddStore( |
190 | 202 | TabSyncDemoState.Initial, |
|
207 | 219 | // ============================================================================ |
208 | 220 | // Security Demo Store - Demonstrates sensitive data filtering |
209 | 221 | // Properties marked with [SensitiveData] are filtered from DevTools |
| 222 | +// SECURITY BEST PRACTICE: Always mark passwords, tokens, API keys, and PII |
| 223 | +// with [SensitiveData] attribute to prevent exposure in DevTools/logs |
| 224 | +// Example: [property: SensitiveData] string Password |
210 | 225 | // ============================================================================ |
211 | 226 | builder.Services.AddStore( |
212 | 227 | SecurityDemoState.Initial, |
|
0 commit comments