create-fluxstack 1.19.0 → 1.20.1

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 (37) hide show
  1. package/LLMD/INDEX.md +1 -1
  2. package/LLMD/MAINTENANCE.md +197 -197
  3. package/LLMD/MIGRATION.md +44 -1
  4. package/LLMD/agent.md +20 -7
  5. package/LLMD/config/declarative-system.md +268 -268
  6. package/LLMD/config/environment-vars.md +3 -6
  7. package/LLMD/config/runtime-reload.md +401 -401
  8. package/LLMD/core/build-system.md +599 -599
  9. package/LLMD/core/framework-lifecycle.md +249 -229
  10. package/LLMD/core/plugin-system.md +154 -100
  11. package/LLMD/patterns/anti-patterns.md +397 -397
  12. package/LLMD/patterns/project-structure.md +264 -264
  13. package/LLMD/patterns/type-safety.md +61 -5
  14. package/LLMD/reference/cli-commands.md +31 -7
  15. package/LLMD/reference/plugin-hooks.md +4 -2
  16. package/LLMD/reference/troubleshooting.md +364 -364
  17. package/LLMD/resources/controllers.md +465 -465
  18. package/LLMD/resources/live-auth.md +178 -1
  19. package/LLMD/resources/live-binary-delta.md +3 -1
  20. package/LLMD/resources/live-components.md +1192 -1041
  21. package/LLMD/resources/live-logging.md +3 -1
  22. package/LLMD/resources/live-rooms.md +1 -1
  23. package/LLMD/resources/live-upload.md +228 -181
  24. package/LLMD/resources/plugins-external.md +8 -7
  25. package/LLMD/resources/rest-auth.md +290 -290
  26. package/LLMD/resources/routes-eden.md +254 -254
  27. package/app/client/.live-stubs/LiveAdminPanel.js +15 -0
  28. package/app/client/.live-stubs/LiveCounter.js +9 -0
  29. package/app/client/.live-stubs/LiveForm.js +11 -0
  30. package/app/client/.live-stubs/LiveLocalCounter.js +8 -0
  31. package/app/client/.live-stubs/LivePingPong.js +10 -0
  32. package/app/client/.live-stubs/LiveRoomChat.js +11 -0
  33. package/app/client/.live-stubs/LiveSharedCounter.js +10 -0
  34. package/app/client/.live-stubs/LiveUpload.js +15 -0
  35. package/app/server/live/auto-generated-components.ts +1 -1
  36. package/core/utils/version.ts +6 -6
  37. package/package.json +108 -108
@@ -1,6 +1,6 @@
1
1
  # Live Components Authentication
2
2
 
3
- **Version:** 1.16.0 | **Updated:** 2026-03-25
3
+ **Version:** 1.19.0 | **Updated:** 2026-04-14
4
4
 
5
5
  ## Quick Facts
6
6
 
@@ -321,6 +321,73 @@ if (panel.$error?.includes('AUTH_DENIED')) {
321
321
 
322
322
  ## Auth Providers
323
323
 
324
+ ### DevAuthProvider (Used in FluxStack App)
325
+
326
+ The FluxStack app ships with a `DevAuthProvider` for development/testing. It accepts hardcoded tokens and maps them to pre-defined users with roles and permissions. Registered in `app/server/index.ts`.
327
+
328
+ **File:** `app/server/auth/DevAuthProvider.ts`
329
+
330
+ ```typescript
331
+ import type { LiveAuthProvider, LiveAuthCredentials, LiveAuthContext } from '@fluxstack/live'
332
+ import { AuthenticatedContext } from '@fluxstack/live'
333
+
334
+ const DEV_USERS: Record<string, DevUser> = {
335
+ 'admin-token': {
336
+ id: 'admin-1',
337
+ name: 'Admin User',
338
+ roles: ['admin', 'user'],
339
+ permissions: ['users.read', 'users.write', 'users.delete', 'chat.read', 'chat.write', 'chat.admin'],
340
+ },
341
+ 'user-token': {
342
+ id: 'user-1',
343
+ name: 'Regular User',
344
+ roles: ['user'],
345
+ permissions: ['chat.read', 'chat.write'],
346
+ },
347
+ 'mod-token': {
348
+ id: 'mod-1',
349
+ name: 'Moderator',
350
+ roles: ['moderator', 'user'],
351
+ permissions: ['chat.read', 'chat.write', 'chat.moderate'],
352
+ },
353
+ }
354
+
355
+ export class DevAuthProvider implements LiveAuthProvider {
356
+ readonly name = 'dev'
357
+
358
+ async authenticate(credentials: LiveAuthCredentials): Promise<LiveAuthContext | null> {
359
+ const token = credentials.token as string
360
+ if (!token) return null
361
+ const user = DEV_USERS[token]
362
+ if (!user) return null
363
+ return new AuthenticatedContext({
364
+ id: user.id,
365
+ name: user.name,
366
+ roles: user.roles,
367
+ permissions: user.permissions,
368
+ }, token)
369
+ }
370
+ }
371
+ ```
372
+
373
+ **Registration** (`app/server/index.ts`):
374
+
375
+ ```typescript
376
+ import { DevAuthProvider } from "./auth/DevAuthProvider"
377
+ registerAuthProvider(new DevAuthProvider())
378
+ ```
379
+
380
+ **Client usage** (authenticate with a dev token):
381
+
382
+ ```tsx
383
+ const { authenticate } = useLiveComponents()
384
+ await authenticate({ token: 'admin-token' }) // admin with all permissions
385
+ await authenticate({ token: 'user-token' }) // regular user
386
+ await authenticate({ token: 'mod-token' }) // moderator
387
+ ```
388
+
389
+ > **WARNING:** DevAuthProvider is for development only. Never use in production.
390
+
324
391
  ### Creating a Custom Provider
325
392
 
326
393
  ```typescript
@@ -456,6 +523,116 @@ type LiveActionAuthMap = Record<string, LiveActionAuth>
456
523
  - Trust client-side auth checks alone
457
524
  - Expose tokens in error messages
458
525
 
526
+ ## Real Examples from FluxStack App
527
+
528
+ The FluxStack app includes two real auth-protected Live Components that demonstrate the patterns described above.
529
+
530
+ ### LiveProtectedChat (`app/server/live/LiveProtectedChat.ts`)
531
+
532
+ Requires authentication to mount. Uses per-action auth for admin operations.
533
+
534
+ ```typescript
535
+ export class LiveProtectedChat extends LiveComponent<ProtectedChatState> {
536
+ static componentName = 'LiveProtectedChat'
537
+ static publicActions = ['join', 'sendMessage', 'deleteMessage', 'clearMessages', 'getAuthInfo'] as const
538
+
539
+ // Component-level: requires authentication (any authenticated user)
540
+ static auth: LiveComponentAuth = {
541
+ required: true,
542
+ }
543
+
544
+ // Action-level: deleteMessage requires 'chat.admin' permission, clearMessages requires 'admin' role
545
+ static actionAuth: LiveActionAuthMap = {
546
+ deleteMessage: { permissions: ['chat.admin'] },
547
+ clearMessages: { roles: ['admin'] },
548
+ }
549
+
550
+ // Uses $auth in actions to identify user and check roles
551
+ async join(payload: { room: string }) {
552
+ this.$room(payload.room).join()
553
+ const userId = this.$auth.session?.id || this.userId || 'anonymous'
554
+ const isAdmin = this.$auth.hasRole('admin')
555
+ this.setState({ currentUser: userId, isAdmin })
556
+ return { success: true, userId, isAdmin }
557
+ }
558
+
559
+ async sendMessage(payload: { text: string }) {
560
+ const message = {
561
+ id: Date.now(),
562
+ userId: this.$auth.session?.id || this.userId || 'unknown',
563
+ text: payload.text.trim(),
564
+ timestamp: Date.now(),
565
+ isAdmin: this.$auth.hasRole('admin'),
566
+ }
567
+ // ...
568
+ }
569
+ }
570
+ ```
571
+
572
+ ### LiveAdminPanel (`app/server/live/LiveAdminPanel.ts`)
573
+
574
+ Requires authentication AND `admin` role to mount. Uses per-action permissions and audit trail.
575
+
576
+ ```typescript
577
+ export class LiveAdminPanel extends LiveComponent<AdminPanelState> {
578
+ static componentName = 'LiveAdminPanel'
579
+ static publicActions = ['getAuthInfo', 'init', 'listUsers', 'addUser', 'deleteUser', 'clearAudit'] as const
580
+
581
+ // Component-level: requires auth + admin role
582
+ static auth: LiveComponentAuth = {
583
+ required: true,
584
+ roles: ['admin'],
585
+ }
586
+
587
+ // Action-level: deleteUser requires 'users.delete' permission
588
+ static actionAuth: LiveActionAuthMap = {
589
+ deleteUser: { permissions: ['users.delete'] },
590
+ clearAudit: { roles: ['admin'] },
591
+ }
592
+
593
+ // Populates state with auth info on init
594
+ async init() {
595
+ this.setState({
596
+ currentUser: this.$auth.session?.id || null,
597
+ currentRoles: this.$auth.session?.roles || [],
598
+ isAdmin: this.$auth.hasRole('admin'),
599
+ })
600
+ this.addAudit('LOGIN', this.$auth.session?.id || 'unknown')
601
+ return { success: true }
602
+ }
603
+
604
+ // Audit trail using $auth.session
605
+ async deleteUser(payload: { userId: string }) {
606
+ const user = this.state.users.find(u => u.id === payload.userId)
607
+ if (!user) throw new Error('User not found')
608
+ this.setState({ users: this.state.users.filter(u => u.id !== payload.userId) })
609
+ this.addAudit('DELETE_USER', this.$auth.session?.id || 'unknown', user.name)
610
+ return { success: true }
611
+ }
612
+ }
613
+ ```
614
+
615
+ ### Testing Auth with DevAuthProvider
616
+
617
+ To test these components in the browser:
618
+
619
+ ```tsx
620
+ // 1. Authenticate as admin (has all permissions)
621
+ await authenticate({ token: 'admin-token' })
622
+ // LiveProtectedChat: mount allowed, all actions allowed
623
+ // LiveAdminPanel: mount allowed, all actions allowed
624
+
625
+ // 2. Authenticate as regular user
626
+ await authenticate({ token: 'user-token' })
627
+ // LiveProtectedChat: mount allowed, but deleteMessage/clearMessages denied
628
+ // LiveAdminPanel: mount DENIED (no 'admin' role)
629
+
630
+ // 3. Authenticate as moderator
631
+ await authenticate({ token: 'mod-token' })
632
+ // LiveProtectedChat: mount allowed, deleteMessage denied (no 'chat.admin'), clearMessages denied (no 'admin' role)
633
+ // LiveAdminPanel: mount DENIED (no 'admin' role)
634
+ ```
635
+
459
636
  ## Related
460
637
 
461
638
  - [Live Components](./live-components.md) - Base component documentation
@@ -1,6 +1,8 @@
1
1
  # Binary Delta (High-Frequency State Sync)
2
2
 
3
- **Version:** 1.14.0 | **Updated:** 2025-03-09
3
+ **Version:** 1.19.0 | **Updated:** 2026-04-14
4
+
5
+ > **Nota:** Este recurso (`sendBinaryDelta`) est\u00e1 dispon\u00edvel no `@fluxstack/live` mas n\u00e3o \u00e9 usado nos componentes de exemplo do FluxStack app.
4
6
 
5
7
  ## Overview
6
8