fazer-lang 3.3.1 → 3.5.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 CHANGED
@@ -2,6 +2,35 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [3.4.0] - 2026-01-26
6
+
7
+ ### Added
8
+ - **Native Database (`db`)**: Built-in JSON NoSQL database.
9
+ - `db.open(path)`: Load/create a database file.
10
+ - `db.set(key, val)`, `db.get(key)`, `db.push(key, item)`: Data manipulation.
11
+ - `db.save()`: Persist data to disk.
12
+ - **Task Scheduler (`sched`)**: Native automation scheduler.
13
+ - `sched.every(ms, fn)`: Recurring tasks (intervals).
14
+ - `sched.after(ms, fn)`: Delayed tasks (timeouts).
15
+ - **Network Sockets (`net`)**: Low-level TCP/UDP support.
16
+ - `net.tcp_client(host, port, callback)`: Raw TCP client.
17
+ - `net.udp_socket(port, callback)`: UDP Server (bind) or Client.
18
+ - **Physics Helpers (`phys`)**: Game development math utilities.
19
+ - `phys.dist`, `phys.angle`, `phys.clamp`, `phys.lerp`, `phys.aabb`.
20
+ - **Ecosystem**: Added `opensiren.fz` example (UDP Syslog Server).
21
+
22
+ ## [3.3.0] - 2026-01-25
23
+
24
+ ### Added
25
+ - **GFX Image & Audio**:
26
+ - `gfx.load_image(key, path)`: Support for PNG/JPG/GIF.
27
+ - `gfx.image(key, x, y)`: Draw images/sprites.
28
+ - `gfx.load_sound(key, path)`: Support for WAV/MP3.
29
+ - `gfx.play_sound(key)`: Audio playback.
30
+ - **GFX Optimization**:
31
+ - `gfx.batch(key, items)`: High-performance batch rendering for tilemaps.
32
+ - **Isometric Math**: Added `lib/iso.fz` standard library.
33
+
5
34
  ## [3.2.1] - 2026-01-25
6
35
 
7
36
  ### Added
package/README.md CHANGED
@@ -4,6 +4,34 @@
4
4
 
5
5
  Conçu pour l'automatisation, la sécurité et le traitement de données, Fazer combine une syntaxe concise avec une bibliothèque standard "batteries included".
6
6
 
7
+ ![Version](https://img.shields.io/badge/version-3.5.0-blue.svg) ![License](https://img.shields.io/badge/license-MIT-green.svg)
8
+
9
+ ## Nouveautés v3.5 (Security & Interactive Update)
10
+
11
+ * **Interactive (`read_line`)** : Entrée utilisateur native dans la console.
12
+ * **Sentinelle** : Outil de sécurité console complet inclus.
13
+ * **Base de Données (`db`)** : Stockage JSON natif et persistant.
14
+ * **Planificateur (`sched`)** : Automatisation de tâches (Cron-like).
15
+ * **Réseau (`net`)** : Support complet TCP/UDP Sockets.
16
+ * **Physique (`phys`)** : Outils mathématiques pour le jeu vidéo.
17
+ * **Sécurité (`security`)** : Chiffrement militaire, suppression sécurisée (shred), stéganographie et protection système.
18
+
19
+ ## 🛡️ Showcase : Sentinelle
20
+
21
+ Fazer inclut désormais **Sentinelle**, un outil de sécurité console de référence écrit entièrement en Fazer.
22
+ Il démontre les capacités de protection active :
23
+ * Surveillance de fichiers temps réel.
24
+ * Coffre-fort (dossiers invisibles).
25
+ * Anti-Forensique (suppression définitive).
26
+
27
+ Retrouvez-le dans le dossier `Sentinelle/`.
28
+
29
+ Lancer Sentinelle depuis la racine du projet :
30
+
31
+ ```bash
32
+ fazer Sentinelle/sentinelle.fz
33
+ ```
34
+
7
35
  ## Installation
8
36
 
9
37
  ### Windows
@@ -0,0 +1,125 @@
1
+ # Module de Sécurité (security)
2
+
3
+ Le module `security` fournit des outils avancés pour la protection des données, l'anti-forensique et la surveillance d'intrusions.
4
+
5
+ ## Suppression Sécurisée (Shredding)
6
+
7
+ Supprime définitivement un fichier en écrasant son contenu plusieurs fois avant la suppression, rendant la récupération quasi-impossible.
8
+
9
+ ### `security.shred(path, [passes])`
10
+ * `path` : Chemin du fichier à détruire.
11
+ * `passes` : (Optionnel) Nombre de passes d'écrasement (défaut: 3).
12
+
13
+ ```fazer
14
+ # Destruction standard (3 passes)
15
+ security.shred("secrets.txt")
16
+
17
+ # Destruction extrême (10 passes)
18
+ security.shred("top_secret.db", 10)
19
+ ```
20
+
21
+ ## Chiffrement de Fichiers
22
+
23
+ Chiffre et déchiffre des fichiers entiers en utilisant l'algorithme AES-256-CBC.
24
+
25
+ ### `security.encrypt_file(path, key)`
26
+ Chiffre le fichier spécifié et crée un nouveau fichier avec l'extension `.enc`.
27
+ * Le fichier original n'est PAS supprimé automatiquement (utilisez `shred` si nécessaire).
28
+ * Utilise un sel aléatoire et un IV aléatoire (stocké dans le fichier de sortie).
29
+
30
+ ```fazer
31
+ key := "MonMotDePasseSuperSecurise"
32
+ if security.encrypt_file("data.json", key) ->
33
+ println("Fichier chiffré avec succès !")
34
+ security.shred("data.json") # Supprime l'original
35
+ end
36
+ ```
37
+
38
+ ### `security.decrypt_file(path, key)`
39
+ Déchiffre un fichier `.enc`. Si le fichier n'a pas l'extension `.enc`, ajoute `.dec` à la sortie.
40
+
41
+ ```fazer
42
+ security.decrypt_file("data.json.enc", "MonMotDePasseSuperSecurise")
43
+ ```
44
+
45
+ ## Intégrité des Fichiers
46
+
47
+ ### `security.hash_file(path)`
48
+ Calcule l'empreinte SHA-256 d'un fichier pour vérifier s'il a été modifié.
49
+
50
+ ```fazer
51
+ hash := security.hash_file("system.dll")
52
+ if hash != KNOWN_GOOD_HASH ->
53
+ println("ALERTE : Fichier système modifié !")
54
+ end
55
+ ```
56
+
57
+ ## Protection des Dossiers (Windows)
58
+
59
+ ### `security.lock_folder(path)`
60
+ Cache et verrouille un dossier en le marquant comme fichier système caché (Super Hidden).
61
+ * Le dossier ne sera pas visible même si "Afficher les fichiers cachés" est activé dans l'explorateur (sauf si "Masquer les fichiers protégés du système" est décoché).
62
+
63
+ ```fazer
64
+ security.lock_folder("C:\\Users\\Moi\\CoffreFort")
65
+ ```
66
+
67
+ ### `security.unlock_folder(path)`
68
+ Restaure la visibilité normale d'un dossier.
69
+
70
+ ```fazer
71
+ security.unlock_folder("C:\\Users\\Moi\\CoffreFort")
72
+ ```
73
+
74
+ ## Surveillance (Sentry Mode)
75
+
76
+ ### `security.monitor(path, callback)`
77
+ Surveille un fichier ou un dossier pour détecter tout changement (accès, modification, renommage).
78
+
79
+ ```fazer
80
+ fn alerte(type, nom) ->
81
+ println("INTRUSION DÉTECTÉE : " + type + " sur " + nom)
82
+ # Action défensive : supprimer les clés de chiffrement, envoyer une alerte, etc.
83
+ end
84
+
85
+ security.monitor("C:\\SensitiveData", alerte)
86
+
87
+ # Garder le script en vie
88
+ while true -> end
89
+ ```
90
+
91
+ ## Stéganographie (Nouveau)
92
+
93
+ Dissimulez des données sensibles à l'intérieur d'images anodines. Cette technique permet de contourner la censure ou de stocker des informations de manière invisible.
94
+
95
+ ### `security.steg_hide(img_path, file_path, out_path)`
96
+ Fusionne un fichier secret dans une image (JPG, PNG, etc.). L'image résultante reste lisible par les visionneuses d'images.
97
+ * `img_path` : Image de couverture.
98
+ * `file_path` : Fichier secret à cacher.
99
+ * `out_path` : Nom de l'image de sortie (qui contiendra le secret).
100
+
101
+ ```fazer
102
+ security.steg_hide("chat.jpg", "codes_nucleaires.txt", "chat_safe.jpg")
103
+ ```
104
+
105
+ ### `security.steg_reveal(img_path, out_path)`
106
+ Extrait un fichier secret caché dans une image.
107
+ ```fazer
108
+ security.steg_reveal("chat_safe.jpg", "codes_recuperes.txt")
109
+ ```
110
+
111
+ ## Pare-feu & Réseau (Windows Admin)
112
+
113
+ Contrôle direct du pare-feu Windows pour bloquer les menaces.
114
+
115
+ ### `security.firewall_block(target)`
116
+ Bloque tout le trafic entrant venant d'une IP ou sur un port spécifique.
117
+ * `target` : Chaîne (IP) ou Entier (Port).
118
+
119
+ ```fazer
120
+ # Bloquer une IP malveillante
121
+ security.firewall_block("192.168.1.66")
122
+
123
+ # Bloquer le port Telnet
124
+ security.firewall_block(23)
125
+ ```
package/docs/stdlib.md CHANGED
@@ -32,6 +32,16 @@ if fs_exists("data") -> ... end
32
32
 
33
33
  ## Manipulation de Données
34
34
 
35
+ ### Entrée Utilisateur (Terminal)
36
+
37
+ * `read_line(prompt)` : Lit une ligne tapée au clavier dans le terminal.
38
+ * `menu(options)` : Affiche une liste numérotée et retourne le choix sélectionné.
39
+
40
+ ```fazer
41
+ nom := read_line("Votre nom: ")
42
+ choix := menu(["Scanner", "Chiffrer", "Quitter"])
43
+ ```
44
+
35
45
  ### JSON
36
46
  * `json_parse(str)` : Convertit une chaîne JSON en objet/liste.
37
47
  * `json_stringify(obj)` : Convertit un objet en chaîne JSON formatée.
@@ -52,17 +62,123 @@ if fs_exists("data") -> ... end
52
62
  * `int(n)` : Conversion en entier.
53
63
  * `float(n)` : Conversion en flottant.
54
64
 
65
+ ### `net.tcp_client(host, port, onData)`
66
+ Crée un client TCP brut.
67
+ ```fazer
68
+ net.tcp_client("127.0.0.1", 9000, fn(data, api) ->
69
+ print("Reçu: " + data)
70
+ api.write("Réponse")
71
+ api.close()
72
+ end)
73
+ ```
74
+
75
+ ### `net.udp_socket(port, onMsg)`
76
+ Crée un socket UDP (Serveur si port > 0, Client si port = 0).
77
+ ```fazer
78
+ # Serveur UDP
79
+ server := net.udp_socket(5140, fn(msg, info) ->
80
+ print("De " + info.address + ": " + msg)
81
+ end)
82
+
83
+ # Client UDP
84
+ client := net.udp_socket(0, null)
85
+ client.send("Log message", "127.0.0.1", 5140)
86
+ ```
87
+
55
88
  ## Base de Données (db)
56
89
 
57
- ### `db(path)`
58
- Crée ou charge une base de données JSON persistante.
90
+ Une base de données JSON NoSQL légère et intégrée.
91
+
92
+ ### `db.open(path)`
93
+ Charge ou crée une base de données.
94
+ ```fazer
95
+ db.open("users.json")
96
+ ```
97
+
98
+ ### Manipulation
99
+ * `db.set(key, value)` : Enregistre une valeur.
100
+ * `db.get(key)` : Récupère une valeur.
101
+ * `db.delete(key)` : Supprime une clé.
102
+ * `db.save()` : Sauvegarde les changements sur le disque.
103
+ * `db.push(key, item)` : Ajoute un élément à une liste.
104
+ * `db.keys()` : Liste toutes les clés.
105
+
106
+ ## Planificateur (sched)
107
+
108
+ Pour l'automatisation et les tâches récurrentes.
109
+
110
+ ### `sched.every(ms, fn)`
111
+
112
+ ## Sécurité (security)
113
+
114
+ Module dédié à la protection des données, à l'anonymat et à l'anti-forensique.
115
+
116
+ ### `security.shred(path, passes)`
117
+ Supprime définitivement un fichier en l'écrasant plusieurs fois avec des données aléatoires avant suppression.
118
+ * `passes` (optionnel) : Nombre de passes (défaut : 3).
119
+ ```fazer
120
+ security.shred("secret.txt", 7)
121
+ ```
122
+
123
+ ### `security.lock_folder(path)` / `security.unlock_folder(path)`
124
+ (Windows uniquement) Rend un dossier "Super-Caché" (Attributs Système + Caché + Lecture Seule).
125
+ Le dossier devient invisible dans l'explorateur par défaut.
59
126
  ```fazer
60
- store := db("data.json")
61
- store.set("key", "value")
62
- val := store.get("key")
63
- data := store.all()
127
+ security.lock_folder("C:\\CoffreFort")
64
128
  ```
65
129
 
130
+ ### `security.encrypt_file(path, password)` / `security.decrypt_file(path, password)`
131
+ Chiffre ou déchiffre un fichier en utilisant l'algorithme AES-256-CBC.
132
+ Le fichier original est remplacé par sa version `.enc` (ou restauré).
133
+ ```fazer
134
+ security.encrypt_file("passwords.txt", "MonSuperMotDePasse")
135
+ ```
136
+
137
+ ### `security.monitor(path, callback)`
138
+ Surveille un dossier ou fichier en temps réel pour détecter les modifications (création, modification, suppression).
139
+ ```fazer
140
+ security.monitor("C:\\Logs", fn(evt, file) ->
141
+ print("Alerte: " + evt + " sur " + file)
142
+ end)
143
+ ```
144
+
145
+ ### `security.steg_hide(image_path, file_path, output_path)`
146
+ (Nouveau) Cache un fichier à l'intérieur d'une image (Stéganographie LSB).
147
+ ```fazer
148
+ security.steg_hide("vacances.png", "secret.txt", "vacances_safe.png")
149
+ ```
150
+
151
+ ### `security.firewall_block(ip_or_port)`
152
+ (Nouveau) Ajoute une règle de pare-feu Windows pour bloquer une IP ou un Port (Nécessite Admin).
153
+ ```fazer
154
+ security.firewall_block("192.168.1.50")
155
+ security.firewall_block(8080)
156
+ ```
157
+
158
+ Exécute une fonction en boucle.
159
+ ```fazer
160
+ id := sched.every(1000, fn() -> print("Tick") end)
161
+ ```
162
+
163
+ ### `sched.after(ms, fn)`
164
+ Exécute une fonction une fois après un délai.
165
+ ```fazer
166
+ sched.after(5000, fn() -> print("Boom") end)
167
+ ```
168
+
169
+ ### `sched.cancel(id)`
170
+ Annule une tâche planifiée.
171
+
172
+ ## Physique & Math (phys)
173
+
174
+ Helpers pour le développement de jeux.
175
+
176
+ * `phys.dist(x1, y1, x2, y2)` : Distance entre deux points.
177
+ * `phys.angle(x1, y1, x2, y2)` : Angle en radians.
178
+ * `phys.clamp(val, min, max)` : Contraint une valeur.
179
+ * `phys.lerp(a, b, t)` : Interpolation linéaire.
180
+ * `phys.aabb(rect1, rect2)` : Collision AABB (x, y, w, h).
181
+
66
182
  ## Automation & Système
67
183
 
68
184
  ### Presse-papier
@@ -140,3 +256,12 @@ Fonctionnalités pour créer des interfaces en ligne de commande (TUI) riches et
140
256
  * Exemple : `ui_bar(50, 100, 20)` -> `██████████ `
141
257
  * `box(title, line1, line2, ...)` : Affiche une boîte encadrée.
142
258
 
259
+ ## Sécurité & Protection (security)
260
+
261
+ Module dédié à la protection des données, destruction sécurisée et surveillance.
262
+ Voir la documentation complète : [security.md](security.md)
263
+
264
+ * `security.shred(path)` : Suppression sécurisée (multi-pass overwrite).
265
+ * `security.encrypt_file(path, key)` : Chiffrement AES-256 de fichiers.
266
+ * `security.lock_folder(path)` : Verrouillage/Masquage de dossier (Windows).
267
+ * `security.monitor(path, callback)` : Détection d'intrusions sur fichiers/dossiers.