create-fluxstack 1.18.1 → 1.20.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/CHANGELOG.md +132 -0
- package/LLMD/INDEX.md +1 -1
- package/LLMD/MAINTENANCE.md +197 -197
- package/LLMD/MIGRATION.md +44 -1
- package/LLMD/agent.md +20 -7
- package/LLMD/config/declarative-system.md +268 -268
- package/LLMD/config/environment-vars.md +3 -6
- package/LLMD/config/runtime-reload.md +401 -401
- package/LLMD/core/build-system.md +599 -599
- package/LLMD/core/framework-lifecycle.md +249 -229
- package/LLMD/core/plugin-system.md +154 -100
- package/LLMD/patterns/anti-patterns.md +397 -397
- package/LLMD/patterns/project-structure.md +264 -264
- package/LLMD/patterns/type-safety.md +61 -5
- package/LLMD/reference/cli-commands.md +31 -7
- package/LLMD/reference/plugin-hooks.md +4 -2
- package/LLMD/reference/troubleshooting.md +364 -364
- package/LLMD/resources/controllers.md +465 -465
- package/LLMD/resources/live-auth.md +178 -1
- package/LLMD/resources/live-binary-delta.md +3 -1
- package/LLMD/resources/live-components.md +1192 -1041
- package/LLMD/resources/live-logging.md +3 -1
- package/LLMD/resources/live-rooms.md +1 -1
- package/LLMD/resources/live-upload.md +228 -181
- package/LLMD/resources/plugins-external.md +8 -7
- package/LLMD/resources/rest-auth.md +290 -290
- package/LLMD/resources/routes-eden.md +254 -254
- package/app/client/src/App.tsx +7 -7
- package/app/client/src/components/AppLayout.tsx +60 -23
- package/app/client/src/components/ColorWheel.tsx +195 -0
- package/app/client/src/components/DemoPage.tsx +5 -3
- package/app/client/src/components/LiveUploadWidget.tsx +1 -1
- package/app/client/src/components/ThemePicker.tsx +307 -0
- package/app/client/src/config/theme.config.ts +127 -0
- package/app/client/src/hooks/useThemeClock.ts +66 -0
- package/app/client/src/index.css +193 -0
- package/app/client/src/lib/theme-clock.ts +201 -0
- package/app/client/src/live/AuthDemo.tsx +9 -9
- package/app/client/src/live/CounterDemo.tsx +10 -10
- package/app/client/src/live/FormDemo.tsx +8 -8
- package/app/client/src/live/PingPongDemo.tsx +10 -10
- package/app/client/src/live/RoomChatDemo.tsx +10 -10
- package/app/client/src/live/SharedCounterDemo.tsx +5 -5
- package/app/client/src/pages/ApiTestPage.tsx +5 -5
- package/app/client/src/pages/HomePage.tsx +12 -12
- package/app/server/index.ts +8 -0
- package/app/server/live/auto-generated-components.ts +1 -1
- package/core/build/index.ts +1 -1
- package/core/cli/command-registry.ts +1 -1
- package/core/cli/commands/build.ts +25 -6
- package/core/cli/commands/plugin-deps.ts +1 -2
- package/core/cli/generators/plugin.ts +433 -581
- package/core/framework/server.ts +22 -8
- package/core/index.ts +6 -5
- package/core/plugins/index.ts +71 -199
- package/core/plugins/types.ts +76 -461
- package/core/server/index.ts +1 -1
- package/core/utils/logger/startup-banner.ts +26 -4
- package/create-fluxstack.ts +216 -107
- package/package.json +108 -107
- package/tsconfig.json +2 -1
- package/core/plugins/config.ts +0 -356
- package/core/plugins/dependency-manager.ts +0 -481
- package/core/plugins/discovery.ts +0 -379
- package/core/plugins/executor.ts +0 -353
- package/core/plugins/manager.ts +0 -645
- package/core/plugins/module-resolver.ts +0 -227
- package/core/plugins/registry.ts +0 -913
- package/vitest.config.live.ts +0 -69
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Live Components Authentication
|
|
2
2
|
|
|
3
|
-
**Version:** 1.
|
|
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.
|
|
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
|
|