create-fluxstack 1.17.0 → 1.18.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 (93) hide show
  1. package/LLMD/resources/live-auth.md +462 -465
  2. package/app/client/.live-stubs/LiveAdminPanel.js +15 -0
  3. package/app/client/.live-stubs/LiveCounter.js +9 -0
  4. package/app/client/.live-stubs/LiveForm.js +11 -0
  5. package/app/client/.live-stubs/LiveLocalCounter.js +8 -0
  6. package/app/client/.live-stubs/LivePingPong.js +10 -0
  7. package/app/client/.live-stubs/LiveRoomChat.js +11 -0
  8. package/app/client/.live-stubs/LiveSharedCounter.js +10 -0
  9. package/app/client/.live-stubs/LiveUpload.js +15 -0
  10. package/app/client/src/App.tsx +45 -3
  11. package/app/client/src/components/AppLayout.tsx +10 -1
  12. package/app/client/src/components/ErrorBoundary.tsx +117 -0
  13. package/app/client/src/components/LiveErrorBoundary.tsx +87 -0
  14. package/app/client/src/components/LiveUploadWidget.tsx +10 -14
  15. package/app/client/src/lib/eden-api.ts +6 -0
  16. package/app/client/src/lib/plugin-hooks.ts +82 -0
  17. package/app/client/src/live/AuthDemo.tsx +0 -1
  18. package/app/client/src/live/FormDemo.tsx +1 -1
  19. package/app/client/src/live/PingPongDemo.tsx +4 -1
  20. package/app/client/src/live/RoomChatDemo.tsx +90 -50
  21. package/app/client/src/live/SharedCounterDemo.tsx +5 -0
  22. package/app/server/auth/AuthManager.ts +24 -0
  23. package/app/server/auth/contracts.ts +12 -1
  24. package/app/server/auth/errors.ts +84 -0
  25. package/app/server/auth/guards/TokenGuard.ts +5 -2
  26. package/app/server/auth/index.ts +1 -1
  27. package/app/server/auth/providers/InMemoryProvider.ts +1 -1
  28. package/app/server/index.ts +3 -4
  29. package/app/server/live/LiveAdminPanel.ts +8 -8
  30. package/app/server/live/LiveForm.ts +1 -1
  31. package/app/server/live/LiveProtectedChat.ts +5 -5
  32. package/app/server/live/LiveRoomChat.ts +50 -28
  33. package/app/server/live/LiveUpload.ts +17 -3
  34. package/app/server/live/auto-generated-components.ts +26 -0
  35. package/app/server/live/rooms/ChatRoom.ts +17 -2
  36. package/app/server/routes/auth.routes.ts +29 -20
  37. package/app/server/routes/index.ts +9 -0
  38. package/app/server/routes/room.routes.ts +6 -6
  39. package/config/index.ts +3 -3
  40. package/config/system/app.config.ts +1 -1
  41. package/config/system/auth.config.ts +1 -1
  42. package/config/system/build.config.ts +8 -6
  43. package/config/system/client.config.ts +6 -4
  44. package/config/system/database.config.ts +1 -1
  45. package/config/system/logger.config.ts +1 -1
  46. package/config/system/monitoring.config.ts +6 -4
  47. package/config/system/plugins.config.ts +1 -1
  48. package/config/system/runtime.config.ts +1 -1
  49. package/config/system/server.config.ts +1 -1
  50. package/config/system/services.config.ts +1 -1
  51. package/config/system/session.config.ts +3 -3
  52. package/config/system/system.config.ts +1 -1
  53. package/core/build/vite-plugins.ts +3 -2
  54. package/core/cli/generators/plugin.ts +1 -1
  55. package/core/config/index.ts +8 -1
  56. package/core/framework/server.ts +9 -5
  57. package/core/index.ts +1 -1
  58. package/core/plugins/index.ts +1 -1
  59. package/core/plugins/manager.ts +5 -1
  60. package/core/plugins/types.ts +17 -1
  61. package/core/server/index.ts +5 -2
  62. package/core/server/live/index.ts +8 -71
  63. package/core/server/plugin-client-hooks.ts +97 -0
  64. package/core/types/types.ts +1 -0
  65. package/core/utils/version.ts +1 -1
  66. package/create-fluxstack.ts +1 -1
  67. package/package.json +8 -5
  68. package/src/client/components/ui/StatusBadge.tsx +23 -0
  69. package/core/utils/config-schema.ts +0 -480
  70. package/core/utils/env.ts +0 -305
  71. package/plugins/crypto-auth/README.md +0 -788
  72. package/plugins/crypto-auth/ai-context.md +0 -1282
  73. package/plugins/crypto-auth/cli/make-protected-route.command.ts +0 -383
  74. package/plugins/crypto-auth/client/CryptoAuthClient.ts +0 -302
  75. package/plugins/crypto-auth/client/components/AuthProvider.tsx +0 -131
  76. package/plugins/crypto-auth/client/components/LoginButton.tsx +0 -138
  77. package/plugins/crypto-auth/client/components/ProtectedRoute.tsx +0 -89
  78. package/plugins/crypto-auth/client/components/index.ts +0 -12
  79. package/plugins/crypto-auth/client/index.ts +0 -12
  80. package/plugins/crypto-auth/config/index.ts +0 -34
  81. package/plugins/crypto-auth/index.ts +0 -173
  82. package/plugins/crypto-auth/package.json +0 -66
  83. package/plugins/crypto-auth/server/AuthMiddleware.ts +0 -181
  84. package/plugins/crypto-auth/server/CryptoAuthLiveProvider.ts +0 -58
  85. package/plugins/crypto-auth/server/CryptoAuthService.ts +0 -186
  86. package/plugins/crypto-auth/server/index.ts +0 -25
  87. package/plugins/crypto-auth/server/middlewares/cryptoAuthAdmin.ts +0 -66
  88. package/plugins/crypto-auth/server/middlewares/cryptoAuthOptional.ts +0 -26
  89. package/plugins/crypto-auth/server/middlewares/cryptoAuthPermissions.ts +0 -77
  90. package/plugins/crypto-auth/server/middlewares/cryptoAuthRequired.ts +0 -45
  91. package/plugins/crypto-auth/server/middlewares/helpers.ts +0 -155
  92. package/plugins/crypto-auth/server/middlewares/index.ts +0 -22
  93. package/plugins/crypto-auth/server/middlewares.ts +0 -19
@@ -1,155 +0,0 @@
1
- /**
2
- * Crypto Auth Middleware Helpers
3
- * Funções compartilhadas para validação de autenticação
4
- */
5
-
6
- import type { Logger } from '@core/utils/logger'
7
-
8
- /**
9
- * Helper to safely parse request.url which might be relative or absolute
10
- */
11
- function parseRequestURL(request: Request): URL {
12
- try {
13
- // Try parsing as absolute URL first
14
- return new URL(request.url)
15
- } catch {
16
- // If relative, use host from headers or default to localhost
17
- const host = request.headers.get('host') || 'localhost'
18
- const protocol = request.headers.get('x-forwarded-proto') || 'http'
19
- return new URL(request.url, `${protocol}://${host}`)
20
- }
21
- }
22
-
23
- export interface CryptoAuthUser {
24
- publicKey: string
25
- isAdmin: boolean
26
- permissions: string[]
27
- }
28
-
29
- /**
30
- * Get auth service from global
31
- */
32
- export function getAuthService() {
33
- const service = (global as any).cryptoAuthService
34
- if (!service) {
35
- throw new Error('CryptoAuthService not initialized. Make sure crypto-auth plugin is loaded.')
36
- }
37
- return service
38
- }
39
-
40
- /**
41
- * Get auth middleware from global
42
- */
43
- export function getAuthMiddleware() {
44
- const middleware = (global as any).cryptoAuthMiddleware
45
- if (!middleware) {
46
- throw new Error('AuthMiddleware not initialized. Make sure crypto-auth plugin is loaded.')
47
- }
48
- return middleware
49
- }
50
-
51
- /**
52
- * Extract and validate authentication from request
53
- * Versão SÍNCRONA para evitar problemas com Elysia
54
- */
55
- export function extractAuthHeaders(request: Request): {
56
- publicKey: string
57
- timestamp: number
58
- nonce: string
59
- signature: string
60
- } | null {
61
- const headers = request.headers
62
- const publicKey = headers.get('x-public-key')
63
- const timestampStr = headers.get('x-timestamp')
64
- const nonce = headers.get('x-nonce')
65
- const signature = headers.get('x-signature')
66
-
67
- if (!publicKey || !timestampStr || !nonce || !signature) {
68
- return null
69
- }
70
-
71
- const timestamp = parseInt(timestampStr, 10)
72
- if (isNaN(timestamp)) {
73
- return null
74
- }
75
-
76
- return { publicKey, timestamp, nonce, signature }
77
- }
78
-
79
- /**
80
- * Build message for signature verification
81
- */
82
- export function buildMessage(request: Request): string {
83
- const url = parseRequestURL(request)
84
- return `${request.method}:${url.pathname}`
85
- }
86
-
87
- /**
88
- * Validate authentication synchronously
89
- */
90
- export async function validateAuthSync(request: Request, logger?: Logger): Promise<{
91
- success: boolean
92
- user?: CryptoAuthUser
93
- error?: string
94
- }> {
95
- try {
96
- const authHeaders = extractAuthHeaders(request)
97
-
98
- if (!authHeaders) {
99
- return {
100
- success: false,
101
- error: 'Missing authentication headers'
102
- }
103
- }
104
-
105
- const authService = getAuthService()
106
- const message = buildMessage(request)
107
-
108
- const result = await authService.validateRequest({
109
- publicKey: authHeaders.publicKey,
110
- timestamp: authHeaders.timestamp,
111
- nonce: authHeaders.nonce,
112
- signature: authHeaders.signature,
113
- message
114
- })
115
-
116
- return result
117
- } catch (error) {
118
- logger?.error('Auth validation error', { error })
119
- return {
120
- success: false,
121
- error: error instanceof Error ? error.message : 'Unknown error'
122
- }
123
- }
124
- }
125
-
126
- /**
127
- * Helper: Obter usuário autenticado do request
128
- */
129
- export function getCryptoAuthUser(request: Request): CryptoAuthUser | null {
130
- return (request as any).user || null
131
- }
132
-
133
- /**
134
- * Helper: Verificar se request está autenticado
135
- */
136
- export function isCryptoAuthAuthenticated(request: Request): boolean {
137
- return !!(request as any).user
138
- }
139
-
140
- /**
141
- * Helper: Verificar se usuário é admin
142
- */
143
- export function isCryptoAuthAdmin(request: Request): boolean {
144
- const user = getCryptoAuthUser(request)
145
- return user?.isAdmin || false
146
- }
147
-
148
- /**
149
- * Helper: Verificar se usuário tem permissão específica
150
- */
151
- export function hasCryptoAuthPermission(request: Request, permission: string): boolean {
152
- const user = getCryptoAuthUser(request)
153
- if (!user) return false
154
- return user.permissions.includes(permission) || user.permissions.includes('admin')
155
- }
@@ -1,22 +0,0 @@
1
- /**
2
- * Crypto Auth Middlewares
3
- * Exports centralizados de todos os middlewares
4
- */
5
-
6
- // Middlewares
7
- export { cryptoAuthRequired } from './cryptoAuthRequired'
8
- export { cryptoAuthAdmin } from './cryptoAuthAdmin'
9
- export { cryptoAuthOptional } from './cryptoAuthOptional'
10
- export { cryptoAuthPermissions } from './cryptoAuthPermissions'
11
-
12
- // Helpers
13
- export {
14
- getCryptoAuthUser,
15
- isCryptoAuthAuthenticated,
16
- isCryptoAuthAdmin,
17
- hasCryptoAuthPermission,
18
- type CryptoAuthUser
19
- } from './helpers'
20
-
21
- // Types
22
- export type { CryptoAuthMiddlewareOptions } from './cryptoAuthRequired'
@@ -1,19 +0,0 @@
1
- /**
2
- * Crypto Auth Middlewares
3
- * Middlewares Elysia para autenticação criptográfica
4
- *
5
- * Uso:
6
- * ```typescript
7
- * import { cryptoAuthRequired, cryptoAuthAdmin } from '@/plugins/crypto-auth/server'
8
- *
9
- * export const myRoutes = new Elysia()
10
- * .use(cryptoAuthRequired())
11
- * .get('/protected', ({ request }) => {
12
- * const user = getCryptoAuthUser(request)
13
- * return { user }
14
- * })
15
- * ```
16
- */
17
-
18
- // Re-export tudo do módulo middlewares
19
- export * from './middlewares/index'