create-fluxstack 1.5.4 → 1.7.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 (61) hide show
  1. package/README.md +172 -215
  2. package/app/client/src/App.tsx +45 -19
  3. package/app/client/src/components/FluxStackConfig.tsx +1 -1
  4. package/app/client/src/components/HybridLiveCounter.tsx +1 -1
  5. package/app/client/src/components/LiveClock.tsx +1 -1
  6. package/app/client/src/components/MainLayout.tsx +0 -2
  7. package/app/client/src/components/SidebarNavigation.tsx +1 -1
  8. package/app/client/src/components/SystemMonitor.tsx +16 -10
  9. package/app/client/src/components/UserProfile.tsx +1 -1
  10. package/app/server/live/FluxStackConfig.ts +2 -1
  11. package/app/server/live/LiveClockComponent.ts +8 -7
  12. package/app/server/live/SidebarNavigation.ts +2 -1
  13. package/app/server/live/SystemMonitor.ts +1 -0
  14. package/app/server/live/UserProfileComponent.ts +36 -30
  15. package/config/server.config.ts +1 -0
  16. package/core/cli/command-registry.ts +10 -10
  17. package/core/cli/commands/plugin-deps.ts +13 -5
  18. package/core/cli/plugin-discovery.ts +1 -1
  19. package/core/client/LiveComponentsProvider.tsx +414 -0
  20. package/core/client/hooks/useHybridLiveComponent.ts +194 -530
  21. package/core/client/index.ts +16 -0
  22. package/core/framework/server.ts +144 -63
  23. package/core/index.ts +4 -1
  24. package/core/plugins/built-in/monitoring/index.ts +1 -1
  25. package/core/plugins/built-in/static/index.ts +1 -1
  26. package/core/plugins/built-in/swagger/index.ts +1 -1
  27. package/core/plugins/built-in/vite/index.ts +1 -1
  28. package/core/plugins/config.ts +1 -1
  29. package/core/plugins/discovery.ts +1 -1
  30. package/core/plugins/executor.ts +1 -1
  31. package/core/plugins/index.ts +1 -0
  32. package/core/server/live/ComponentRegistry.ts +3 -1
  33. package/core/server/live/WebSocketConnectionManager.ts +14 -4
  34. package/core/server/live/websocket-plugin.ts +453 -434
  35. package/core/server/middleware/elysia-helpers.ts +3 -5
  36. package/core/server/plugins/database.ts +1 -1
  37. package/core/server/plugins/static-files-plugin.ts +1 -1
  38. package/core/types/index.ts +1 -1
  39. package/core/types/plugin.ts +1 -1
  40. package/core/types/types.ts +6 -2
  41. package/core/utils/logger/colors.ts +4 -4
  42. package/core/utils/logger/index.ts +37 -4
  43. package/core/utils/logger/winston-logger.ts +1 -1
  44. package/core/utils/sync-version.ts +61 -0
  45. package/core/utils/version.ts +6 -5
  46. package/create-fluxstack.ts +1 -1
  47. package/package.json +5 -3
  48. package/plugins/crypto-auth/server/middlewares/cryptoAuthAdmin.ts +1 -1
  49. package/plugins/crypto-auth/server/middlewares/cryptoAuthOptional.ts +1 -1
  50. package/plugins/crypto-auth/server/middlewares/cryptoAuthPermissions.ts +1 -1
  51. package/plugins/crypto-auth/server/middlewares/cryptoAuthRequired.ts +1 -1
  52. package/vite.config.ts +8 -0
  53. package/.dockerignore +0 -50
  54. package/CRYPTO-AUTH-MIDDLEWARE-GUIDE.md +0 -475
  55. package/CRYPTO-AUTH-MIDDLEWARES.md +0 -473
  56. package/CRYPTO-AUTH-USAGE.md +0 -491
  57. package/EXEMPLO-ROTA-PROTEGIDA.md +0 -347
  58. package/QUICK-START-CRYPTO-AUTH.md +0 -221
  59. package/app/client/src/components/Teste.tsx +0 -104
  60. package/app/server/live/TesteComponent.ts +0 -87
  61. package/test-crypto-auth.ts +0 -101
@@ -1,87 +0,0 @@
1
- // 🔥 Teste - Live Component
2
- import { LiveComponent } from "@/core/types/types";
3
-
4
- interface TesteState {
5
- message: string;
6
- count: number;
7
- lastUpdated: Date;
8
- }
9
-
10
- export class TesteComponent extends LiveComponent<TesteState> {
11
- constructor(initialState: TesteState, ws: any, options?: { room?: string; userId?: string }) {
12
- super({
13
- message: "Hello from Teste!",
14
- count: 0,
15
- lastUpdated: new Date(),
16
- ...initialState
17
- }, ws, options);
18
- // Default room: testeroom
19
- this.room = 'testeroom';
20
-
21
- console.log(`🔥 ${this.constructor.name} component created: ${this.id}`);
22
- }
23
-
24
- async updateMessage(payload: { message: string }) {
25
- const { message } = payload;
26
-
27
- if (!message || message.trim().length === 0) {
28
- throw new Error('Message cannot be empty');
29
- }
30
-
31
- this.setState({
32
- message: message.trim(),
33
- lastUpdated: new Date()
34
- });
35
-
36
- // Broadcast to room if in multi-user mode
37
- if (this.room) {
38
- this.broadcast('MESSAGE_UPDATED', {
39
- message: message.trim(),
40
- userId: this.userId
41
- });
42
- }
43
-
44
- console.log(`📝 Message updated: "${message}"`);
45
- return { success: true, message: message.trim() };
46
- }
47
-
48
- async incrementCounter() {
49
- const newCount = this.state.count + 1;
50
-
51
- this.setState({
52
- count: newCount,
53
- lastUpdated: new Date()
54
- });
55
-
56
- if (this.room) {
57
- this.broadcast('COUNTER_INCREMENTED', {
58
- count: newCount,
59
- userId: this.userId
60
- });
61
- }
62
-
63
- return { success: true, count: newCount };
64
- }
65
-
66
- async resetData() {
67
- this.setState({
68
- message: "Hello from Teste!",
69
- count: 0,
70
- lastUpdated: new Date()
71
- });
72
-
73
- return { success: true };
74
- }
75
-
76
- async getData() {
77
- return {
78
- success: true,
79
- data: {
80
- ...this.state,
81
- componentId: this.id,
82
- room: this.room,
83
- userId: this.userId
84
- }
85
- };
86
- }
87
- }
@@ -1,101 +0,0 @@
1
- /**
2
- * Script de teste para validar autenticação criptográfica
3
- */
4
-
5
- import { ed25519 } from '@noble/curves/ed25519'
6
- import { sha256 } from '@noble/hashes/sha256'
7
- import { bytesToHex, hexToBytes } from '@noble/hashes/utils'
8
-
9
- async function testCryptoAuth() {
10
- console.log('🔐 Testando Autenticação Criptográfica Ed25519\n')
11
-
12
- // 1. Gerar par de chaves
13
- console.log('1️⃣ Gerando par de chaves Ed25519...')
14
- const privateKey = ed25519.utils.randomPrivateKey()
15
- const publicKeyBytes = ed25519.getPublicKey(privateKey)
16
- const publicKey = bytesToHex(publicKeyBytes)
17
- const privateKeyHex = bytesToHex(privateKey)
18
-
19
- console.log(` ✅ Chave pública: ${publicKey.substring(0, 16)}...`)
20
- console.log(` ✅ Chave privada: ${privateKeyHex.substring(0, 16)}... (NUNCA enviar ao servidor!)\n`)
21
-
22
- // 2. Preparar requisição
23
- console.log('2️⃣ Preparando requisição assinada...')
24
- const url = '/api/crypto-auth/protected'
25
- const method = 'GET'
26
- const timestamp = Date.now()
27
- const nonce = generateNonce()
28
-
29
- // 3. Construir mensagem para assinar
30
- const message = `${method}:${url}`
31
- const fullMessage = `${publicKey}:${timestamp}:${nonce}:${message}`
32
-
33
- console.log(` 📝 Mensagem: ${fullMessage.substring(0, 50)}...\n`)
34
-
35
- // 4. Assinar mensagem
36
- console.log('3️⃣ Assinando mensagem com chave privada...')
37
- const messageHash = sha256(new TextEncoder().encode(fullMessage))
38
- const signatureBytes = ed25519.sign(messageHash, privateKey)
39
- const signature = bytesToHex(signatureBytes)
40
-
41
- console.log(` ✅ Assinatura: ${signature.substring(0, 32)}...\n`)
42
-
43
- // 5. Fazer requisição ao servidor
44
- console.log('4️⃣ Enviando requisição ao servidor...')
45
- const response = await fetch('http://localhost:3000/api/crypto-auth/protected', {
46
- method: 'GET',
47
- headers: {
48
- 'x-public-key': publicKey,
49
- 'x-timestamp': timestamp.toString(),
50
- 'x-nonce': nonce,
51
- 'x-signature': signature
52
- }
53
- })
54
-
55
- const data = await response.json()
56
-
57
- console.log(` 📡 Status: ${response.status}`)
58
- console.log(` 📦 Resposta:`, JSON.stringify(data, null, 2))
59
-
60
- if (data.success) {
61
- console.log('\n✅ SUCESSO! Assinatura validada corretamente pelo servidor!')
62
- console.log(` 👤 Dados protegidos recebidos: ${data.data?.secretInfo}`)
63
- } else {
64
- console.log('\n❌ ERRO! Assinatura rejeitada pelo servidor')
65
- console.log(` ⚠️ Erro: ${data.error}`)
66
- }
67
-
68
- // 6. Testar replay attack (reutilizar mesma assinatura)
69
- console.log('\n5️⃣ Testando proteção contra replay attack...')
70
- const replayResponse = await fetch('http://localhost:3000/api/crypto-auth/protected', {
71
- method: 'GET',
72
- headers: {
73
- 'x-public-key': publicKey,
74
- 'x-timestamp': timestamp.toString(),
75
- 'x-nonce': nonce, // Mesmo nonce
76
- 'x-signature': signature // Mesma assinatura
77
- }
78
- })
79
-
80
- const replayData = await replayResponse.json()
81
-
82
- console.log(` 📡 Replay Status: ${replayResponse.status}`)
83
- console.log(` 📦 Replay Response:`, JSON.stringify(replayData, null, 2))
84
-
85
- if (!replayData.success && replayData.error?.includes('nonce')) {
86
- console.log(' ✅ Proteção funcionando! Replay attack bloqueado.')
87
- } else if (replayResponse.status === 401) {
88
- console.log(' ✅ Proteção funcionando! Replay attack bloqueado (status 401).')
89
- } else {
90
- console.log(' ⚠️ ATENÇÃO: Replay attack NÃO foi bloqueado!')
91
- }
92
- }
93
-
94
- function generateNonce(): string {
95
- const bytes = new Uint8Array(16)
96
- crypto.getRandomValues(bytes)
97
- return bytesToHex(bytes)
98
- }
99
-
100
- // Executar teste
101
- testCryptoAuth().catch(console.error)