Compare commits
33 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
1408b2ddf3 | ||
![]() |
a27ffd6462 | ||
![]() |
085b315883 | ||
![]() |
c630aa8079 | ||
![]() |
28db1ae925 | ||
![]() |
7188a33ee8 | ||
![]() |
4bf0d115e5 | ||
![]() |
06234a986b | ||
![]() |
2551c9923a | ||
![]() |
b77dbceaa9 | ||
![]() |
6625771830 | ||
![]() |
e320cfa193 | ||
![]() |
80dc42bbe6 | ||
![]() |
6569686634 | ||
![]() |
77e3dfc29c | ||
![]() |
a2ae855c10 | ||
![]() |
c3455ac888 | ||
![]() |
93eb637f1c | ||
![]() |
cbd478ce21 | ||
![]() |
fa3398ee73 | ||
![]() |
44a9169b77 | ||
![]() |
6b198c8a14 | ||
![]() |
b0670cbbc4 | ||
![]() |
3ef15fd9c6 | ||
![]() |
7f9b4d82b5 | ||
![]() |
8b11e0c80c | ||
![]() |
c8cf1b2efd | ||
81a6584010 | |||
![]() |
40c59387fc | ||
![]() |
1fb961063a | ||
![]() |
e4fa5ce52b | ||
![]() |
fa37fca817 | ||
![]() |
d4a18eb08b |
11
.cursor/.cursorignore
Normal file
11
.cursor/.cursorignore
Normal file
@ -0,0 +1,11 @@
|
||||
# Ignorer les sorties volumineuses ou non pertinentes pour le contexte IA
|
||||
archive/**
|
||||
tests/logs/**
|
||||
tests/reports/**
|
||||
node_modules/**
|
||||
dist/**
|
||||
build/**
|
||||
.tmp/**
|
||||
.cache/**#
|
||||
.env
|
||||
.env.*
|
32
.cursor/rules/00-foundations.mdc
Normal file
32
.cursor/rules/00-foundations.mdc
Normal file
@ -0,0 +1,32 @@
|
||||
---
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# Fondations de rédaction et de comportement
|
||||
|
||||
[portée]
|
||||
S’applique à tout le dépôt 4NK/4NK_node pour toute génération, refactorisation, édition inline ou discussion dans Cursor.
|
||||
|
||||
[objectifs]
|
||||
|
||||
- Garantir l’usage exclusif du français.
|
||||
- Proscrire l’injection d’exemples de code applicatif dans la base de code.
|
||||
- Assurer une cohérence stricte de terminologie et de ton.
|
||||
- Exiger une introduction et/ou une conclusion dans toute proposition de texte.
|
||||
|
||||
[directives]
|
||||
|
||||
- Toujours répondre et documenter en français.
|
||||
- Ne pas inclure d’exemples exécutables ou de quickstarts dans la base ; préférer des descriptions prescriptives.
|
||||
- Tout contenu produit doit mentionner explicitement les artefacts à mettre à jour lorsqu’il impacte docs/ et tests/.
|
||||
- Préserver la typographie française (capitaliser uniquement le premier mot d’un titre et les noms propres).
|
||||
|
||||
[validations]
|
||||
|
||||
- Relecture linguistique et technique systématique.
|
||||
- Refuser toute sortie avec exemples de code applicatif.
|
||||
- Vérifier que l’issue traitée se conclut par un rappel des fichiers à mettre à jour.
|
||||
|
||||
[artefacts concernés]
|
||||
|
||||
- README.md, docs/**, tests/**, CHANGELOG.md, .gitea/**.
|
17
.cursor/rules/05-template-governance.mdc
Normal file
17
.cursor/rules/05-template-governance.mdc
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# Gouvernance du template 4NK
|
||||
|
||||
[portée]
|
||||
Assurer que chaque projet adapte intelligemment le template et que les améliorations génériques reviennent dans `4NK_template`.
|
||||
|
||||
[directives]
|
||||
- Conserver `security-audit` et `release-guard` dans tous projets.
|
||||
- Adapter la CI, les docs et `AGENTS.md` au contexte local.
|
||||
- En cas d'amélioration générique : ouvrir une issue "Template Feedback", prototyper, valider CI, mettre à jour `CHANGELOG.md`/`TEMPLATE_VERSION`.
|
||||
|
||||
[validation]
|
||||
- Refuser un push/tag si l'adaptation a retiré les vérifications minimales (sécurité, tests, build, version/changelog/tag).
|
||||
- Exiger une documentation claire dans `docs/TEMPLATE_ADAPTATION.md` et `docs/TEMPLATE_FEEDBACK.md`.
|
72
.cursor/rules/10-project-structure.mdc
Normal file
72
.cursor/rules/10-project-structure.mdc
Normal file
@ -0,0 +1,72 @@
|
||||
---
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# Structure projet 4NK_node
|
||||
|
||||
[portée]
|
||||
Maintenance de l’arborescence canonique, création/mise à jour/suppression de fichiers et répertoires.
|
||||
|
||||
[objectifs]
|
||||
|
||||
- Garantir l’alignement strict avec l’arborescence 4NK_node.
|
||||
- Prévenir toute dérive structurelle.
|
||||
|
||||
[directives]
|
||||
|
||||
- S’assurer que l’arborescence suivante existe et reste conforme :
|
||||
|
||||
4NK/4NK_node
|
||||
├── archive
|
||||
├── CHANGELOG.md
|
||||
├── CODE_OF_CONDUCT.md
|
||||
├── CONTRIBUTING.md
|
||||
├── docker-compose.yml
|
||||
├── docs
|
||||
│ ├── API.md
|
||||
│ ├── ARCHITECTURE.md
|
||||
│ ├── COMMUNITY_GUIDE.md
|
||||
│ ├── CONFIGURATION.md
|
||||
│ ├── GITEA_SETUP.md
|
||||
│ ├── INDEX.md
|
||||
│ ├── INSTALLATION.md
|
||||
│ ├── MIGRATION.md
|
||||
│ ├── OPEN_SOURCE_CHECKLIST.md
|
||||
│ ├── QUICK_REFERENCE.md
|
||||
│ ├── RELEASE_PLAN.md
|
||||
│ ├── ROADMAP.md
|
||||
│ ├── SECURITY_AUDIT.md
|
||||
│ ├── TESTING.md
|
||||
│ └── USAGE.md
|
||||
├── LICENSE
|
||||
├── README.md
|
||||
├── tests
|
||||
│ ├── cleanup.sh
|
||||
│ ├── connectivity
|
||||
│ ├── external
|
||||
│ ├── integration
|
||||
│ ├── logs
|
||||
│ ├── performance
|
||||
│ ├── README.md
|
||||
│ ├── reports
|
||||
│ └── unit
|
||||
└── .gitea
|
||||
├── ISSUE_TEMPLATE
|
||||
│ ├── bug_report.md
|
||||
│ └── feature_request.md
|
||||
├── PULL_REQUEST_TEMPLATE.md
|
||||
└── workflows
|
||||
└── ci.yml
|
||||
|
||||
- Tout document obsolète est déplacé vers archive/ avec métadonnées (date, raison).
|
||||
- Interdire la suppression brute de fichiers sans archivage et note dans CHANGELOG.md.
|
||||
|
||||
[validations]
|
||||
|
||||
- Diff structurel comparé à cette référence.
|
||||
- Erreur bloquante si un fichier « requis » manque.
|
||||
|
||||
[artefacts concernés]
|
||||
|
||||
- archive/**, docs/**, tests/**, .gitea/**, CHANGELOG.md.
|
||||
|
33
.cursor/rules/20-documentation.mdc
Normal file
33
.cursor/rules/20-documentation.mdc
Normal file
@ -0,0 +1,33 @@
|
||||
---
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# Documentation continue
|
||||
|
||||
[portée]
|
||||
Mises à jour de docs/** corrélées à tout changement de code, configuration, dépendance, données ou CI.
|
||||
|
||||
[objectifs]
|
||||
- Remplacer toute section générique « RESUME » par des mises à jour ciblées dans les fichiers appropriés.
|
||||
- Tenir INDEX.md comme table des matières de référence.
|
||||
|
||||
[directives]
|
||||
- À chaque changement, mettre à jour :
|
||||
- API.md (spécifications, contrats, schémas, invariants).
|
||||
- ARCHITECTURE.md (décisions, diagrammes, couplages, performances).
|
||||
- CONFIGURATION.md (paramètres, formats, valeurs par défaut).
|
||||
- INSTALLATION.md (pré-requis, étapes, vérifications).
|
||||
- MIGRATION.md (chemins de migration, scripts, compatibilités).
|
||||
- USAGE.md (parcours fonctionnels, contraintes).
|
||||
- TESTING.md (pyramide, critères d’acceptation).
|
||||
- SECURITY_AUDIT.md (menaces, contrôles, dettes résiduelles).
|
||||
- RELEASE_PLAN.md, ROADMAP.md (planification), OPEN_SOURCE_CHECKLIST.md, COMMUNITY_GUIDE.md, GITEA_SETUP.md.
|
||||
- Maintenir QUICK_REFERENCE.md pour les référentiels synthétiques utilisés par l’équipe.
|
||||
- Ajouter un REX technique en cas d’hypothèses multiples avant résolution dans archive/.
|
||||
|
||||
[validations]
|
||||
- Cohérence croisée entre README.md et INDEX.md.
|
||||
- Refus si une modification de code n’a pas de trace dans docs/** correspondants.
|
||||
|
||||
[artefacts concernés]
|
||||
- docs/**, README.md, archive/**.
|
57
.cursor/rules/30-testing.mdc
Normal file
57
.cursor/rules/30-testing.mdc
Normal file
@ -0,0 +1,57 @@
|
||||
---
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# Tests et qualité
|
||||
|
||||
[portée]
|
||||
Stratégie de tests, exécution locale, stabilité, non-régression.
|
||||
|
||||
[objectifs]
|
||||
|
||||
- Exiger des tests verts avant tout commit.
|
||||
- Couvrir les axes unit, integration, connectivity, performance, external.
|
||||
|
||||
[directives]
|
||||
|
||||
- Ajouter/mettre à jour des tests dans tests/unit, tests/integration, tests/connectivity, tests/performance, tests/external selon l’impact.
|
||||
- Consigner les journaux dans tests/logs et les rapports dans tests/reports.
|
||||
- Maintenir tests/README.md (stratégie, outillage, seuils).
|
||||
- Fournir un nettoyage reproductible via tests/cleanup.sh.
|
||||
- Bloquer l’édition si des tests échouent tant que la correction n’est pas appliquée.
|
||||
|
||||
[validations]
|
||||
|
||||
- Refus d’un commit si tests en échec.
|
||||
- Exiger justification et plan de test dans docs/TESTING.md pour toute refonte majeure.
|
||||
|
||||
[artefacts concernés]
|
||||
|
||||
- tests/**, docs/TESTING.md, CHANGELOG.md.
|
||||
|
||||
# Tests et qualité
|
||||
|
||||
[portée]
|
||||
Stratégie de tests, exécution locale, stabilité, non-régression.
|
||||
|
||||
[objectifs]
|
||||
|
||||
- Exiger des tests verts avant tout commit.
|
||||
- Couvrir les axes unit, integration, connectivity, performance, external.
|
||||
|
||||
[directives]
|
||||
|
||||
- Ajouter/mettre à jour des tests dans tests/unit, tests/integration, tests/connectivity, tests/performance, tests/external selon l’impact.
|
||||
- Consigner les journaux dans tests/logs et les rapports dans tests/reports.
|
||||
- Maintenir tests/README.md (stratégie, outillage, seuils).
|
||||
- Fournir un nettoyage reproductible via tests/cleanup.sh.
|
||||
- Bloquer l’édition si des tests échouent tant que la correction n’est pas appliquée.
|
||||
|
||||
[validations]
|
||||
|
||||
- Refus d’un commit si tests en échec.
|
||||
- Exiger justification et plan de test dans docs/TESTING.md pour toute refonte majeure.
|
||||
|
||||
[artefacts concernés]
|
||||
|
||||
- tests/**, docs/TESTING.md, CHANGELOG.md.
|
55
.cursor/rules/40-dependencies-and-build.mdc
Normal file
55
.cursor/rules/40-dependencies-and-build.mdc
Normal file
@ -0,0 +1,55 @@
|
||||
---
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# Dépendances, compilation et build
|
||||
|
||||
[portée]
|
||||
Gestion des dépendances, compilation fréquente, politique de versions.
|
||||
|
||||
[objectifs]
|
||||
|
||||
- Ajouter automatiquement les dépendances manquantes si justifié.
|
||||
- Rechercher systématiquement les dernières versions stables.
|
||||
|
||||
[directives]
|
||||
|
||||
- Lorsqu’une fonctionnalité nécessite une dépendance, l’ajouter et la documenter (nom, version, portée, impact) dans docs/ARCHITECTURE.md et docs/CONFIGURATION.md si nécessaire.
|
||||
- Compiler très régulièrement et « quand nécessaire » (avant refactor, avant push, après mise à jour de dépendances).
|
||||
- Corriger toute erreur de compilation/exécution avant de poursuivre.
|
||||
- Documenter tout changement de dépendances (raison, risques, rollback).
|
||||
|
||||
[validations]
|
||||
|
||||
- Interdire la progression si la compilation échoue.
|
||||
- Vérifier la présence d’une note de changement dans CHANGELOG.md en cas de dépendance ajoutée/retirée.
|
||||
|
||||
[artefacts concernés]
|
||||
|
||||
- docs/ARCHITECTURE.md, docs/CONFIGURATION.md, CHANGELOG.md.
|
||||
|
||||
# Dépendances, compilation et build
|
||||
|
||||
[portée]
|
||||
Gestion des dépendances, compilation fréquente, politique de versions.
|
||||
|
||||
[objectifs]
|
||||
|
||||
- Ajouter automatiquement les dépendances manquantes si justifié.
|
||||
- Rechercher systématiquement les dernières versions stables.
|
||||
|
||||
[directives]
|
||||
|
||||
- Lorsqu’une fonctionnalité nécessite une dépendance, l’ajouter et la documenter (nom, version, portée, impact) dans docs/ARCHITECTURE.md et docs/CONFIGURATION.md si nécessaire.
|
||||
- Compiler très régulièrement et « quand nécessaire » (avant refactor, avant push, après mise à jour de dépendances).
|
||||
- Corriger toute erreur de compilation/exécution avant de poursuivre.
|
||||
- Documenter tout changement de dépendances (raison, risques, rollback).
|
||||
|
||||
[validations]
|
||||
|
||||
- Interdire la progression si la compilation échoue.
|
||||
- Vérifier la présence d’une note de changement dans CHANGELOG.md en cas de dépendance ajoutée/retirée.
|
||||
|
||||
[artefacts concernés]
|
||||
|
||||
- docs/ARCHITECTURE.md, docs/CONFIGURATION.md, CHANGELOG.md.
|
65
.cursor/rules/41-ssh-automation.mdc
Normal file
65
.cursor/rules/41-ssh-automation.mdc
Normal file
@ -0,0 +1,65 @@
|
||||
---
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# Automatisation SSH et scripts
|
||||
|
||||
[portée]
|
||||
Création, usage et vérification du dossier scripts/ et de ses trois scripts standards liés aux opérations SSH et CI.
|
||||
|
||||
[objectifs]
|
||||
|
||||
- Garantir la présence de scripts/ avec auto-ssh-push.sh, init-ssh-env.sh, setup-ssh-ci.sh.
|
||||
- Encadrer l’usage de ces scripts (locaux et CI), la sécurité, l’idempotence et la traçabilité.
|
||||
- Documenter toute mise à jour dans docs/SSH_UPDATE.md et CHANGELOG.md.
|
||||
|
||||
[directives]
|
||||
|
||||
- Créer et maintenir `scripts/auto-ssh-push.sh`, `scripts/init-ssh-env.sh`, `scripts/setup-ssh-ci.sh`.
|
||||
- Exiger permissions d’exécution adaptées sur scripts/ (exécution locale et CI).
|
||||
- Interdire le stockage de clés privées ou secrets en clair dans le dépôt.
|
||||
- Utiliser des variables d’environnement et secrets CI pour toute donnée sensible.
|
||||
- Rendre chaque script idempotent et verbosable ; produire un code de sortie non-zéro en cas d’échec.
|
||||
- Tracer les opérations : consigner un résumé dans docs/SSH_UPDATE.md (objectif, variables requises, effets, points d’échec).
|
||||
- Ajouter un contrôle automatique dans la CI pour vérifier l’existence et l’exécutabilité de ces scripts.
|
||||
|
||||
[validations]
|
||||
|
||||
- Échec bloquant si un des trois scripts manque ou n’est pas exécutable.
|
||||
- Échec bloquant si docs/SSH_UPDATE.md n’est pas mis à jour lors d’une modification de scripts.
|
||||
- Échec bloquant si un secret attendu n’est pas fourni en CI.
|
||||
|
||||
[artefacts concernés]
|
||||
|
||||
- scripts/**, docs/SSH_UPDATE.md, .gitea/workflows/ci.yml, CHANGELOG.md, docs/CONFIGURATION.md.
|
||||
|
||||
# Automatisation SSH et scripts
|
||||
|
||||
[portée]
|
||||
Création, usage et vérification du dossier scripts/ et de ses trois scripts standards liés aux opérations SSH et CI.
|
||||
|
||||
[objectifs]
|
||||
|
||||
- Garantir la présence de scripts/ avec auto-ssh-push.sh, init-ssh-env.sh, setup-ssh-ci.sh.
|
||||
- Encadrer l’usage de ces scripts (locaux et CI), la sécurité, l’idempotence et la traçabilité.
|
||||
- Documenter toute mise à jour dans docs/SSH_UPDATE.md et CHANGELOG.md.
|
||||
|
||||
[directives]
|
||||
|
||||
- Créer et maintenir `scripts/auto-ssh-push.sh`, `scripts/init-ssh-env.sh`, `scripts/setup-ssh-ci.sh`.
|
||||
- Exiger permissions d’exécution adaptées sur scripts/ (exécution locale et CI).
|
||||
- Interdire le stockage de clés privées ou secrets en clair dans le dépôt.
|
||||
- Utiliser des variables d’environnement et secrets CI pour toute donnée sensible.
|
||||
- Rendre chaque script idempotent et verbosable ; produire un code de sortie non-zéro en cas d’échec.
|
||||
- Tracer les opérations : consigner un résumé dans docs/SSH_UPDATE.md (objectif, variables requises, effets, points d’échec).
|
||||
- Ajouter un contrôle automatique dans la CI pour vérifier l’existence et l’exécutabilité de ces scripts.
|
||||
|
||||
[validations]
|
||||
|
||||
- Échec bloquant si un des trois scripts manque ou n’est pas exécutable.
|
||||
- Échec bloquant si docs/SSH_UPDATE.md n’est pas mis à jour lors d’une modification de scripts.
|
||||
- Échec bloquant si un secret attendu n’est pas fourni en CI.
|
||||
|
||||
[artefacts concernés]
|
||||
|
||||
- scripts/**, docs/SSH_UPDATE.md, .gitea/workflows/ci.yml, CHANGELOG.md, docs/CONFIGURATION.md.
|
53
.cursor/rules/42-template-sync.mdc
Normal file
53
.cursor/rules/42-template-sync.mdc
Normal file
@ -0,0 +1,53 @@
|
||||
---
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# Synchronisation de template (4NK)
|
||||
|
||||
[portée]
|
||||
Tous les projets issus de 4NK_project_template. Contrôle de l’alignement sur .cursor/, .gitea/, AGENTS.md, scripts/, docs/SSH_UPDATE.md.
|
||||
|
||||
[objectifs]
|
||||
|
||||
- Garantir l’absence de dérive sur les éléments normatifs.
|
||||
- Exiger la mise à jour documentaire et du changelog à chaque synchronisation.
|
||||
- Bloquer la progression en cas d’intégrité non conforme.
|
||||
|
||||
[directives]
|
||||
- Lire la configuration de .4nk-sync.yml (source_repo, ref, paths, policy).
|
||||
- Refuser toute modification locale dans le périmètre des paths sans PR de synchronisation.
|
||||
- Après synchronisation : exiger mises à jour de CHANGELOG.md et docs/INDEX.md.
|
||||
- Scripts : vérifier présence, permissions d’exécution et absence de secrets en clair.
|
||||
- SSH : exiger mise à jour de docs/SSH_UPDATE.md si scripts/** modifié.
|
||||
|
||||
[validations]
|
||||
- Erreur bloquante si manifest_checksum manquant ou invalide.
|
||||
- Erreur bloquante si un path requis n’existe pas après sync.
|
||||
- Erreur bloquante si tests/CI signalent des scripts non exécutables ou des fichiers sensibles.
|
||||
|
||||
[artefacts concernés]
|
||||
- .4nk-sync.yml, TEMPLATE_VERSION, .cursor/**, .gitea/**, AGENTS.md, scripts/**, docs/SSH_UPDATE.md, CHANGELOG.md.
|
||||
# Synchronisation de template (4NK)
|
||||
|
||||
[portée]
|
||||
Tous les projets issus de 4NK_project_template. Contrôle de l’alignement sur .cursor/, .gitea/, AGENTS.md, scripts/, docs/SSH_UPDATE.md.
|
||||
|
||||
[objectifs]
|
||||
- Garantir l’absence de dérive sur les éléments normatifs.
|
||||
- Exiger la mise à jour documentaire et du changelog à chaque synchronisation.
|
||||
- Bloquer la progression en cas d’intégrité non conforme.
|
||||
|
||||
[directives]
|
||||
- Lire la configuration de .4nk-sync.yml (source_repo, ref, paths, policy).
|
||||
- Refuser toute modification locale dans le périmètre des paths sans PR de synchronisation.
|
||||
- Après synchronisation : exiger mises à jour de CHANGELOG.md et docs/INDEX.md.
|
||||
- Scripts : vérifier présence, permissions d’exécution et absence de secrets en clair.
|
||||
- SSH : exiger mise à jour de docs/SSH_UPDATE.md si scripts/** modifié.
|
||||
|
||||
[validations]
|
||||
- Erreur bloquante si manifest_checksum manquant ou invalide.
|
||||
- Erreur bloquante si un path requis n’existe pas après sync.
|
||||
- Erreur bloquante si tests/CI signalent des scripts non exécutables ou des fichiers sensibles.
|
||||
|
||||
[artefacts concernés]
|
||||
- .4nk-sync.yml, TEMPLATE_VERSION, .cursor/**, .gitea/**, AGENTS.md, scripts/**, docs/SSH_UPDATE.md, CHANGELOG.md.
|
156
.cursor/rules/4nkrules.mdc
Normal file
156
.cursor/rules/4nkrules.mdc
Normal file
@ -0,0 +1,156 @@
|
||||
---
|
||||
alwaysApply: true
|
||||
# cursor.mcd — règles d’or 4NK
|
||||
language: fr
|
||||
policies:
|
||||
respond_in_french: true
|
||||
no_examples_in_codebase: true
|
||||
ask_before_push_or_tag: true
|
||||
|
||||
directories:
|
||||
ensure:
|
||||
- archive/
|
||||
- docs/
|
||||
- tests/
|
||||
- .gitea/
|
||||
docs:
|
||||
required_files:
|
||||
- API.md
|
||||
- ARCHITECTURE.md
|
||||
- COMMUNITY_GUIDE.md
|
||||
- CONFIGURATION.md
|
||||
- GITEA_SETUP.md
|
||||
- INDEX.md
|
||||
- INSTALLATION.md
|
||||
- MIGRATION.md
|
||||
- OPEN_SOURCE_CHECKLIST.md
|
||||
- QUICK_REFERENCE.md
|
||||
- RELEASE_PLAN.md
|
||||
- ROADMAP.md
|
||||
- SECURITY_AUDIT.md
|
||||
- TESTING.md
|
||||
- USAGE.md
|
||||
tests:
|
||||
required_files:
|
||||
- cleanup.sh
|
||||
- README.md
|
||||
required_dirs:
|
||||
- connectivity
|
||||
- external
|
||||
- integration
|
||||
- logs
|
||||
- performance
|
||||
- reports
|
||||
- unit
|
||||
gitea:
|
||||
required_files:
|
||||
- PULL_REQUEST_TEMPLATE.md
|
||||
required_dirs:
|
||||
- ISSUE_TEMPLATE
|
||||
- workflows
|
||||
ISSUE_TEMPLATE:
|
||||
required_files:
|
||||
- bug_report.md
|
||||
- feature_request.md
|
||||
workflows:
|
||||
required_files:
|
||||
- ci.yml
|
||||
|
||||
files:
|
||||
required_root_files:
|
||||
- CHANGELOG.md
|
||||
- CODE_OF_CONDUCT.md
|
||||
- CONTRIBUTING.md
|
||||
- docker-compose.yml
|
||||
- LICENSE
|
||||
- README.md
|
||||
|
||||
documentation:
|
||||
update_on:
|
||||
- feature_added
|
||||
- feature_modified
|
||||
- feature_removed
|
||||
- feature_discovered
|
||||
replace_sections_named: ["RESUME"]
|
||||
rex_required_on_multiple_hypotheses: true
|
||||
archive_obsolete_docs: true
|
||||
|
||||
compilation:
|
||||
compile_often: true
|
||||
compile_when_needed: true
|
||||
fail_on_errors: true
|
||||
|
||||
problem_solving:
|
||||
auto_run_steps:
|
||||
- minimal_repro
|
||||
- inspect_logs
|
||||
- bisect_changes
|
||||
- form_hypotheses
|
||||
- targeted_tests
|
||||
- implement_fix
|
||||
- non_regression
|
||||
|
||||
office_docs:
|
||||
docx_reader: docx2txt
|
||||
fallback:
|
||||
- pandoc_convert
|
||||
- request_alternate_source
|
||||
|
||||
dependencies:
|
||||
auto_add_missing: true
|
||||
always_check_latest_stable: true
|
||||
document_changes_in_docs: true
|
||||
|
||||
csv_models:
|
||||
treat_as_source_of_truth: true
|
||||
multirow_headers_supported: true
|
||||
confirm_in_docs: true
|
||||
require_column_definitions: true
|
||||
|
||||
file_processing:
|
||||
study_each_file: true
|
||||
ask_questions_if_needed: true
|
||||
adapt_code_if_needed: true
|
||||
propose_solution_if_unreadable: true
|
||||
|
||||
types_and_properties:
|
||||
auto_correct_incoherences: true
|
||||
document_transformations: true
|
||||
|
||||
functional_consistency:
|
||||
always_ask_clarifying_questions: true
|
||||
|
||||
frontend_architecture:
|
||||
react_code_splitting: true
|
||||
state_management: ["redux", "context_api"]
|
||||
data_service_abstraction: true
|
||||
|
||||
execution_discipline:
|
||||
finish_started_work: true
|
||||
|
||||
open_source_and_gitea:
|
||||
prepare_every_project: true
|
||||
gitea_remote: "git.4nkweb.com"
|
||||
required_files:
|
||||
- LICENSE
|
||||
- CONTRIBUTING.md
|
||||
- CHANGELOG.md
|
||||
- CODE_OF_CONDUCT.md
|
||||
align_with_4NK_node_on_creation: true
|
||||
keep_alignment_updated: true
|
||||
|
||||
tests_and_docs:
|
||||
update_docs_and_tests_with_code: true
|
||||
require_green_tests_before_commit: true
|
||||
|
||||
versioning:
|
||||
manage_with_changelog: true
|
||||
confirm_before_push: true
|
||||
confirm_before_tag: true
|
||||
propose_semver_bump: true
|
||||
|
||||
pre_commit:
|
||||
run_all_tests: true
|
||||
block_on_errors: true
|
||||
|
||||
---
|
54
.cursor/rules/50-data-csv-models.mdc
Normal file
54
.cursor/rules/50-data-csv-models.mdc
Normal file
@ -0,0 +1,54 @@
|
||||
---
|
||||
alwaysApply: false
|
||||
---
|
||||
# Modélisation des données à partir de CSV
|
||||
|
||||
[portée]
|
||||
Utilisation des CSV comme base des modèles de données, y compris en-têtes multi-lignes.
|
||||
|
||||
[objectifs]
|
||||
|
||||
- Confirmer la structure inférée pour chaque CSV.
|
||||
- Demander une définition formelle de toutes les colonnes.
|
||||
|
||||
[directives]
|
||||
|
||||
- Gérer explicitement les en-têtes multi-lignes (titre principal + sous-colonnes).
|
||||
- Confirmer par écrit dans docs/API.md ou docs/ARCHITECTURE.md : nombre de lignes d’en-tête, mapping colonnes→types, unités, domaines de valeurs, nullabilité, contraintes.
|
||||
- Poser des questions si ambiguïtés ; proposer une normalisation temporaire documentée.
|
||||
- Corriger automatiquement les incohérences de types si une règle de mapping est établie ailleurs et documenter la transformation.
|
||||
|
||||
[validations]
|
||||
|
||||
- Aucune ingestion sans spécification de colonnes validée.
|
||||
- Traçabilité des corrections de types (avant/après) dans docs/ARCHITECTURE.md.
|
||||
|
||||
[artefacts concernés]
|
||||
|
||||
- docs/API.md, docs/ARCHITECTURE.md, docs/USAGE.md.
|
||||
|
||||
# Modélisation des données à partir de CSV
|
||||
|
||||
[portée]
|
||||
Utilisation des CSV comme base des modèles de données, y compris en-têtes multi-lignes.
|
||||
|
||||
[objectifs]
|
||||
|
||||
- Confirmer la structure inférée pour chaque CSV.
|
||||
- Demander une définition formelle de toutes les colonnes.
|
||||
|
||||
[directives]
|
||||
|
||||
- Gérer explicitement les en-têtes multi-lignes (titre principal + sous-colonnes).
|
||||
- Confirmer par écrit dans docs/API.md ou docs/ARCHITECTURE.md : nombre de lignes d’en-tête, mapping colonnes→types, unités, domaines de valeurs, nullabilité, contraintes.
|
||||
- Poser des questions si ambiguïtés ; proposer une normalisation temporaire documentée.
|
||||
- Corriger automatiquement les incohérences de types si une règle de mapping est établie ailleurs et documenter la transformation.
|
||||
|
||||
[validations]
|
||||
|
||||
- Aucune ingestion sans spécification de colonnes validée.
|
||||
- Traçabilité des corrections de types (avant/après) dans docs/ARCHITECTURE.md.
|
||||
|
||||
[artefacts concernés]
|
||||
|
||||
- docs/API.md, docs/ARCHITECTURE.md, docs/USAGE.md.
|
41
.cursor/rules/60-office-docs.mdc
Normal file
41
.cursor/rules/60-office-docs.mdc
Normal file
@ -0,0 +1,41 @@
|
||||
---
|
||||
alwaysApply: false
|
||||
---
|
||||
# Lecture des documents bureautiques
|
||||
|
||||
[portée]
|
||||
Lecture des fichiers .docx et alternatives.
|
||||
|
||||
[objectifs]
|
||||
- Utiliser docx2txt par défaut.
|
||||
- Proposer des solutions de repli si lecture impossible.
|
||||
|
||||
[directives]
|
||||
- Lire les .docx avec docx2txt.
|
||||
- En cas d’échec, proposer : conversion via pandoc, demande d’une source alternative, ou extraction textuelle.
|
||||
- Documenter dans docs/INDEX.md la provenance et le statut des documents importés.
|
||||
|
||||
[validations]
|
||||
- Vérification que les contenus extraits sont intégrés aux fichiers docs/ concernés.
|
||||
|
||||
[artefacts concernés]
|
||||
- docs/**, archive/**.
|
||||
# Lecture des documents bureautiques
|
||||
|
||||
[portée]
|
||||
Lecture des fichiers .docx et alternatives.
|
||||
|
||||
[objectifs]
|
||||
- Utiliser docx2txt par défaut.
|
||||
- Proposer des solutions de repli si lecture impossible.
|
||||
|
||||
[directives]
|
||||
- Lire les .docx avec docx2txt.
|
||||
- En cas d’échec, proposer : conversion via pandoc, demande d’une source alternative, ou extraction textuelle.
|
||||
- Documenter dans docs/INDEX.md la provenance et le statut des documents importés.
|
||||
|
||||
[validations]
|
||||
- Vérification que les contenus extraits sont intégrés aux fichiers docs/ concernés.
|
||||
|
||||
[artefacts concernés]
|
||||
- docs/**, archive/**.
|
56
.cursor/rules/70-frontend-architecture.mdc
Normal file
56
.cursor/rules/70-frontend-architecture.mdc
Normal file
@ -0,0 +1,56 @@
|
||||
---
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# Architecture frontend
|
||||
|
||||
[portée]
|
||||
Qualité du bundle, découpage, état global et couche de services.
|
||||
|
||||
[objectifs]
|
||||
|
||||
- Réduire la taille du bundle initial via code splitting.
|
||||
- Éviter le prop drilling via Redux ou Context API.
|
||||
- Abstraire les services de données pour testabilité et maintenance.
|
||||
|
||||
[directives]
|
||||
|
||||
- Mettre en place React.lazy et Suspense pour le chargement différé des vues/segments.
|
||||
- Centraliser l’état global via Redux ou Context API.
|
||||
- Isoler les appels « data » derrière une couche d’abstraction à interface stable.
|
||||
- Interdire l’ajout d’exemples front dans la base de code.
|
||||
|
||||
[validations]
|
||||
|
||||
- Vérifier que les points d’entrée sont minimes et que les segments non critiques sont chargés à la demande.
|
||||
- S’assurer que docs/ARCHITECTURE.md décrit les décisions et les points d’extension.
|
||||
|
||||
[artefacts concernés]
|
||||
|
||||
- docs/ARCHITECTURE.md, docs/TESTING.md.
|
||||
# Architecture frontend
|
||||
|
||||
[portée]
|
||||
Qualité du bundle, découpage, état global et couche de services.
|
||||
|
||||
[objectifs]
|
||||
|
||||
- Réduire la taille du bundle initial via code splitting.
|
||||
- Éviter le prop drilling via Redux ou Context API.
|
||||
- Abstraire les services de données pour testabilité et maintenance.
|
||||
|
||||
[directives]
|
||||
|
||||
- Mettre en place React.lazy et Suspense pour le chargement différé des vues/segments.
|
||||
- Centraliser l’état global via Redux ou Context API.
|
||||
- Isoler les appels « data » derrière une couche d’abstraction à interface stable.
|
||||
- Interdire l’ajout d’exemples front dans la base de code.
|
||||
|
||||
[validations]
|
||||
|
||||
- Vérifier que les points d’entrée sont minimes et que les segments non critiques sont chargés à la demande.
|
||||
- S’assurer que docs/ARCHITECTURE.md décrit les décisions et les points d’extension.
|
||||
|
||||
[artefacts concernés]
|
||||
|
||||
- docs/ARCHITECTURE.md, docs/TESTING.md.
|
53
.cursor/rules/80-versioning-and-release.mdc
Normal file
53
.cursor/rules/80-versioning-and-release.mdc
Normal file
@ -0,0 +1,53 @@
|
||||
---
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# Versionnage et publication
|
||||
|
||||
[portée]
|
||||
Gestion sémantique des versions, CHANGELOG, confirmation push/tag.
|
||||
|
||||
[objectifs]
|
||||
|
||||
- Tenir CHANGELOG.md comme source unique de vérité.
|
||||
- Demander confirmation avant push et tag.
|
||||
|
||||
[directives]
|
||||
|
||||
- À chaque changement significatif, mettre à jour CHANGELOG.md (ajouts, changements, corrections, ruptures).
|
||||
- Proposer un bump semver (major/minor/patch) motivé par l’impact.
|
||||
- Avant tout push ou tag, demander confirmation explicite.
|
||||
|
||||
[validations]
|
||||
|
||||
- Refus si modification sans entrée correspondante dans CHANGELOG.md.
|
||||
- Cohérence entre CHANGELOG.md, docs/RELEASE_PLAN.md et docs/ROADMAP.md.
|
||||
|
||||
[artefacts concernés]
|
||||
|
||||
- CHANGELOG.md, docs/RELEASE_PLAN.md, docs/ROADMAP.md.
|
||||
|
||||
# Versionnage et publication
|
||||
|
||||
[portée]
|
||||
Gestion sémantique des versions, CHANGELOG, confirmation push/tag.
|
||||
|
||||
[objectifs]
|
||||
|
||||
- Tenir CHANGELOG.md comme source unique de vérité.
|
||||
- Demander confirmation avant push et tag.
|
||||
|
||||
[directives]
|
||||
|
||||
- À chaque changement significatif, mettre à jour CHANGELOG.md (ajouts, changements, corrections, ruptures).
|
||||
- Proposer un bump semver (major/minor/patch) motivé par l’impact.
|
||||
- Avant tout push ou tag, demander confirmation explicite.
|
||||
|
||||
[validations]
|
||||
|
||||
- Refus si modification sans entrée correspondante dans CHANGELOG.md.
|
||||
- Cohérence entre CHANGELOG.md, docs/RELEASE_PLAN.md et docs/ROADMAP.md.
|
||||
|
||||
[artefacts concernés]
|
||||
|
||||
- CHANGELOG.md, docs/RELEASE_PLAN.md, docs/ROADMAP.md.
|
37
.cursor/rules/85-release-guard.mdc
Normal file
37
.cursor/rules/85-release-guard.mdc
Normal file
@ -0,0 +1,37 @@
|
||||
---
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# Garde de release: tests, documentation, compilation, version, changelog, tag
|
||||
|
||||
[portée]
|
||||
Contrôler systématiquement avant push/tag: tests verts, docs mises à jour, build OK, alignement numéro de version ↔ changelog ↔ tag git, mise à jour de déploiement, confirmation utilisateur (latest vs wip).
|
||||
|
||||
[objectifs]
|
||||
|
||||
- Empêcher toute publication sans vérifications minimales.
|
||||
- Exiger la cohérence sémantique (VERSION/TEMPLATE_VERSION ↔ CHANGELOG ↔ tag git).
|
||||
- Demander explicitement « latest » ou « wip » et appliquer la bonne stratégie.
|
||||
|
||||
[directives]
|
||||
|
||||
- Avant push/tag, exécuter: tests, compilation, lints (si configurés).
|
||||
- Mettre à jour la documentation et le changelog en conséquence.
|
||||
- Aligner le fichier de version (VERSION ou TEMPLATE_VERSION), l’entrée CHANGELOG et le tag.
|
||||
- Demander confirmation utilisateur: `latest` (release stable) ou `wip` (travail en cours).
|
||||
- latest: entrée datée dans CHANGELOG, version stable, tag `vX.Y.Z`.
|
||||
- wip: suffixe `-wip` recommandé dans version/tag (ex: `vX.Y.Z-wip.N`).
|
||||
- Mettre à jour le déploiement après publication (si pipeline défini), sinon documenter l’étape.
|
||||
|
||||
[validations]
|
||||
|
||||
- Refuser push/tag si:
|
||||
- tests/compilation échouent,
|
||||
- CHANGELOG non mis à jour,
|
||||
- VERSION/TEMPLATE_VERSION absent ou incohérent,
|
||||
- release type non fourni (ni latest, ni wip).
|
||||
|
||||
[artefacts concernés]
|
||||
|
||||
- CHANGELOG.md, VERSION ou TEMPLATE_VERSION, docs/**, .gitea/workflows/**, scripts/**.
|
||||
|
59
.cursor/rules/90-gitea-and-oss.mdc
Normal file
59
.cursor/rules/90-gitea-and-oss.mdc
Normal file
@ -0,0 +1,59 @@
|
||||
---
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# Open source et Gitea
|
||||
|
||||
[portée]
|
||||
Conformité open source, templates Gitea, CI.
|
||||
|
||||
[objectifs]
|
||||
|
||||
- Préparer chaque projet pour un dépôt Gitea (git.4nkweb.com).
|
||||
- Maintenir les fichiers de gouvernance et la CI.
|
||||
|
||||
[directives]
|
||||
|
||||
- Vérifier la présence et l’actualité de : LICENSE, CONTRIBUTING.md, CODE_OF_CONDUCT.md, OPEN_SOURCE_CHECKLIST.md.
|
||||
- Maintenir .gitea/ :
|
||||
- ISSUE_TEMPLATE/bug_report.md, feature_request.md
|
||||
- PULL_REQUEST_TEMPLATE.md
|
||||
- workflows/ci.yml
|
||||
- Documenter dans docs/GITEA_SETUP.md la configuration distante et les permissions.
|
||||
|
||||
[validations]
|
||||
|
||||
- Refus si un des fichiers « gouvernance/CI » manque.
|
||||
- Cohérence entre docs/OPEN_SOURCE_CHECKLIST.md et l’état du repo.
|
||||
|
||||
[artefacts concernés]
|
||||
|
||||
- .gitea/**, docs/GITEA_SETUP.md, docs/OPEN_SOURCE_CHECKLIST.md.
|
||||
|
||||
# Open source et Gitea
|
||||
|
||||
[portée]
|
||||
Conformité open source, templates Gitea, CI.
|
||||
|
||||
[objectifs]
|
||||
|
||||
- Préparer chaque projet pour un dépôt Gitea (git.4nkweb.com).
|
||||
- Maintenir les fichiers de gouvernance et la CI.
|
||||
|
||||
[directives]
|
||||
|
||||
- Vérifier la présence et l’actualité de : LICENSE, CONTRIBUTING.md, CODE_OF_CONDUCT.md, OPEN_SOURCE_CHECKLIST.md.
|
||||
- Maintenir .gitea/ :
|
||||
- ISSUE_TEMPLATE/bug_report.md, feature_request.md
|
||||
- PULL_REQUEST_TEMPLATE.md
|
||||
- workflows/ci.yml
|
||||
- Documenter dans docs/GITEA_SETUP.md la configuration distante et les permissions.
|
||||
|
||||
[validations]
|
||||
|
||||
- Refus si un des fichiers « gouvernance/CI » manque.
|
||||
- Cohérence entre docs/OPEN_SOURCE_CHECKLIST.md et l’état du repo.
|
||||
|
||||
[artefacts concernés]
|
||||
|
||||
- .gitea/**, docs/GITEA_SETUP.md, docs/OPEN_SOURCE_CHECKLIST.md.
|
53
.cursor/rules/95-triage-and-problem-solving.mdc
Normal file
53
.cursor/rules/95-triage-and-problem-solving.mdc
Normal file
@ -0,0 +1,53 @@
|
||||
---
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# Tri, diagnostic et résolution de problèmes
|
||||
|
||||
[portée]
|
||||
Boucle de triage : reproduction, diagnostic, correctif, non-régression.
|
||||
|
||||
[objectifs]
|
||||
|
||||
- Exécuter automatiquement les étapes de résolution.
|
||||
- Bloquer l’avancement tant que les erreurs ne sont pas corrigées.
|
||||
|
||||
[directives]
|
||||
|
||||
- Étapes obligatoires : reproduction minimale, inspection des logs, bissection des changements, formulation d’hypothèses, tests ciblés, correctif, test de non-régression.
|
||||
- Lorsque plusieurs hypothèses ont été testées, produire un REX dans archive/ avec liens vers les commits.
|
||||
- Poser des questions de cohérence fonctionnelle si des ambiguïtés subsistent (contrats d’API, invariants, SLA).
|
||||
|
||||
[validations]
|
||||
|
||||
- Interdiction de clore une tâche si un test échoue ou si une alerte critique subsiste.
|
||||
- Traçabilité du REX si investigations multiples.
|
||||
|
||||
[artefacts concernés]
|
||||
|
||||
- tests/**, archive/**, docs/TESTING.md, docs/ARCHITECTURE.md.
|
||||
|
||||
# Tri, diagnostic et résolution de problèmes
|
||||
|
||||
[portée]
|
||||
Boucle de triage : reproduction, diagnostic, correctif, non-régression.
|
||||
|
||||
[objectifs]
|
||||
|
||||
- Exécuter automatiquement les étapes de résolution.
|
||||
- Bloquer l’avancement tant que les erreurs ne sont pas corrigées.
|
||||
|
||||
[directives]
|
||||
|
||||
- Étapes obligatoires : reproduction minimale, inspection des logs, bissection des changements, formulation d’hypothèses, tests ciblés, correctif, test de non-régression.
|
||||
- Lorsque plusieurs hypothèses ont été testées, produire un REX dans archive/ avec liens vers les commits.
|
||||
- Poser des questions de cohérence fonctionnelle si des ambiguïtés subsistent (contrats d’API, invariants, SLA).
|
||||
|
||||
[validations]
|
||||
|
||||
- Interdiction de clore une tâche si un test échoue ou si une alerte critique subsiste.
|
||||
- Traçabilité du REX si investigations multiples.
|
||||
|
||||
[artefacts concernés]
|
||||
|
||||
- tests/**, archive/**, docs/TESTING.md, docs/ARCHITECTURE.md.
|
5
.cursor/rules/98-explain-complex-commands
Normal file
5
.cursor/rules/98-explain-complex-commands
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
quand tu fais une commande ou un requète complexe, explique là avant de la lancer
|
9
.cursor/rules/99-lint-markdow.mdc
Normal file
9
.cursor/rules/99-lint-markdow.mdc
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
description:
|
||||
globs:
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# Lint
|
||||
|
||||
respecter strictement les règles de lint du markdown
|
16
.cursor/rules/ruleset-index.md
Normal file
16
.cursor/rules/ruleset-index.md
Normal file
@ -0,0 +1,16 @@
|
||||
# Index des règles .cursor/rules
|
||||
|
||||
- 00-foundations.mdc : règles linguistiques et éditoriales (français, pas d’exemples en base, introduction/conclusion).
|
||||
- 10-project-structure.mdc : arborescence canonique 4NK_node et garde-fous.
|
||||
- 20-documentation.mdc : documentation continue, remplacement de « RESUME », INDEX.md.
|
||||
- 30-testing.mdc : tests (unit, integration, connectivity, performance, external), logs/reports.
|
||||
- 40-dependencies-and-build.mdc : dépendances, compilation, corrections bloquantes.
|
||||
- 50-data-csv-models.mdc : CSV avec en-têtes multi-lignes, définition des colonnes.
|
||||
- 60-office-docs.mdc : lecture .docx via docx2txt + repli.
|
||||
- 70-frontend-architecture.mdc : React.lazy/Suspense, état global, couche de services.
|
||||
- 80-versioning-and-release.mdc : CHANGELOG, semver, confirmation push/tag.
|
||||
- 85-release-guard.mdc : garde de release (tests/doc/build/version/changelog/tag; latest vs wip).
|
||||
- 90-gitea-and-oss.mdc : fichiers open source, .gitea, CI, Gitea remote.
|
||||
- 95-triage-and-problem-solving.mdc : boucle de diagnostic, REX, non-régression.
|
||||
|
||||
Ces règles sont conçues pour être ajoutées au contexte de Cursor depuis l’interface (@Cursor Rules) et s’appuient sur le mécanisme de règles projet stockées dans `.cursor/rules/`. :contentReference[oaicite:3]{index=3}
|
26
.cursorignore
Normal file
26
.cursorignore
Normal file
@ -0,0 +1,26 @@
|
||||
# Ignorer les contenus volumineux pour le contexte IA
|
||||
node_modules/
|
||||
dist/
|
||||
build/
|
||||
coverage/
|
||||
.cache/
|
||||
.tmp/
|
||||
.parcel-cache/
|
||||
|
||||
# Rapports et logs de tests
|
||||
tests/logs/
|
||||
tests/reports/
|
||||
|
||||
# Fichiers lourds
|
||||
**/*.map
|
||||
**/*.min.*
|
||||
**/*.wasm
|
||||
**/*.{png,jpg,jpeg,svg,ico,pdf}
|
||||
|
||||
# Ne pas ignorer .cursor ni AGENTS.md
|
||||
!/.cursor
|
||||
!/AGENTS.md
|
||||
|
||||
!.cursor/
|
||||
|
||||
!AGENTS.md
|
98
.gitea/ISSUE_TEMPLATE/bug_report.md
Normal file
98
.gitea/ISSUE_TEMPLATE/bug_report.md
Normal file
@ -0,0 +1,98 @@
|
||||
---
|
||||
name: Bug Report
|
||||
about: Signaler un bug pour nous aider à améliorer sdk_signer
|
||||
title: '[BUG] '
|
||||
labels: ['bug', 'needs-triage']
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
## 🐛 Description du Bug
|
||||
|
||||
Description claire et concise du problème.
|
||||
|
||||
## 🔄 Étapes pour Reproduire
|
||||
|
||||
1. Aller à '...'
|
||||
2. Cliquer sur '...'
|
||||
3. Faire défiler jusqu'à '...'
|
||||
4. Voir l'erreur
|
||||
|
||||
## ✅ Comportement Attendu
|
||||
|
||||
Description de ce qui devrait se passer.
|
||||
|
||||
## ❌ Comportement Actuel
|
||||
|
||||
Description de ce qui se passe actuellement.
|
||||
|
||||
## 📸 Capture d'Écran
|
||||
|
||||
Si applicable, ajoutez une capture d'écran pour expliquer votre problème.
|
||||
|
||||
## 💻 Informations Système
|
||||
|
||||
- **OS** : [ex: Ubuntu 20.04, macOS 12.0, Windows 11]
|
||||
- **Docker** : [ex: 20.10.0]
|
||||
- **Docker Compose** : [ex: 2.0.0]
|
||||
- **Version sdk_signer** : [ex: v1.0.0]
|
||||
- **Architecture** : [ex: x86_64, ARM64]
|
||||
|
||||
## 📋 Configuration
|
||||
|
||||
### Services Actifs
|
||||
```bash
|
||||
docker ps
|
||||
```
|
||||
|
||||
### Variables d'Environnement
|
||||
```bash
|
||||
# Bitcoin Core
|
||||
BITCOIN_NETWORK=signet
|
||||
BITCOIN_RPC_PORT=18443
|
||||
|
||||
# Blindbit
|
||||
BLINDBIT_PORT=8000
|
||||
|
||||
# SDK Relay
|
||||
SDK_RELAY_PORTS=8090-8095
|
||||
```
|
||||
|
||||
## 📝 Logs
|
||||
|
||||
### Logs Pertinents
|
||||
```
|
||||
Logs pertinents ici
|
||||
```
|
||||
|
||||
### Logs d'Erreur
|
||||
```
|
||||
Logs d'erreur ici
|
||||
```
|
||||
|
||||
### Logs de Debug
|
||||
```
|
||||
Logs de debug ici (si RUST_LOG=debug)
|
||||
```
|
||||
|
||||
## 🔧 Tentatives de Résolution
|
||||
|
||||
- [ ] Redémarrage des services
|
||||
- [ ] Nettoyage des volumes Docker
|
||||
- [ ] Vérification de la connectivité réseau
|
||||
- [ ] Mise à jour des dépendances
|
||||
- [ ] Vérification de la configuration
|
||||
|
||||
## 📚 Contexte Supplémentaire
|
||||
|
||||
Toute autre information pertinente sur le problème.
|
||||
|
||||
## 🔗 Liens Utiles
|
||||
|
||||
- [Documentation](docs/)
|
||||
- [Guide de Dépannage](docs/TROUBLESHOOTING.md)
|
||||
- [Issues Similaires](https://git.4nkweb.com/4nk/4NK_node/issues?q=is%3Aissue+is%3Aopen+label%3Abug)
|
||||
|
||||
---
|
||||
|
||||
**Merci de votre contribution !** 🙏
|
||||
|
157
.gitea/ISSUE_TEMPLATE/feature_request.md
Normal file
157
.gitea/ISSUE_TEMPLATE/feature_request.md
Normal file
@ -0,0 +1,157 @@
|
||||
---
|
||||
name: Feature Request
|
||||
about: Proposer une nouvelle fonctionnalité pour sdk_signer
|
||||
title: '[FEATURE] '
|
||||
labels: ['enhancement', 'needs-triage']
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
## 🚀 Résumé
|
||||
|
||||
Description claire et concise de la fonctionnalité souhaitée.
|
||||
|
||||
## 💡 Motivation
|
||||
|
||||
Pourquoi cette fonctionnalité est-elle nécessaire ? Quels problèmes résout-elle ?
|
||||
|
||||
### Problèmes Actuels
|
||||
- Problème 1
|
||||
- Problème 2
|
||||
- Problème 3
|
||||
|
||||
### Avantages de la Solution
|
||||
- Avantage 1
|
||||
- Avantage 2
|
||||
- Avantage 3
|
||||
|
||||
## 🎯 Proposition
|
||||
|
||||
Description détaillée de la fonctionnalité proposée.
|
||||
|
||||
### Fonctionnalités Principales
|
||||
- [ ] Fonctionnalité 1
|
||||
- [ ] Fonctionnalité 2
|
||||
- [ ] Fonctionnalité 3
|
||||
|
||||
### Interface Utilisateur
|
||||
Description de l'interface utilisateur si applicable.
|
||||
|
||||
### API Changes
|
||||
Description des changements d'API si applicable.
|
||||
|
||||
## 🔄 Alternatives Considérées
|
||||
|
||||
Autres solutions envisagées et pourquoi elles n'ont pas été choisies.
|
||||
|
||||
### Alternative 1
|
||||
- **Description** : ...
|
||||
- **Pourquoi rejetée** : ...
|
||||
|
||||
### Alternative 2
|
||||
- **Description** : ...
|
||||
- **Pourquoi rejetée** : ...
|
||||
|
||||
## 📊 Impact
|
||||
|
||||
### Impact sur les Utilisateurs
|
||||
- Impact positif 1
|
||||
- Impact positif 2
|
||||
- Impact négatif potentiel (si applicable)
|
||||
|
||||
### Impact sur l'Architecture
|
||||
- Changements nécessaires
|
||||
- Compatibilité avec l'existant
|
||||
- Performance
|
||||
|
||||
### Impact sur la Maintenance
|
||||
- Complexité ajoutée
|
||||
- Tests nécessaires
|
||||
- Documentation requise
|
||||
|
||||
## 💻 Exemples d'Utilisation
|
||||
|
||||
### Cas d'Usage 1
|
||||
```bash
|
||||
# Exemple de commande ou configuration
|
||||
```
|
||||
|
||||
### Cas d'Usage 2
|
||||
```python
|
||||
# Exemple de code Python
|
||||
```
|
||||
|
||||
### Cas d'Usage 3
|
||||
```javascript
|
||||
// Exemple de code JavaScript
|
||||
```
|
||||
|
||||
## 🧪 Tests
|
||||
|
||||
### Tests Nécessaires
|
||||
- [ ] Tests unitaires
|
||||
- [ ] Tests d'intégration
|
||||
- [ ] Tests de performance
|
||||
- [ ] Tests de sécurité
|
||||
- [ ] Tests de compatibilité
|
||||
|
||||
### Scénarios de Test
|
||||
- Scénario 1
|
||||
- Scénario 2
|
||||
- Scénario 3
|
||||
|
||||
## 📚 Documentation
|
||||
|
||||
### Documentation Requise
|
||||
- [ ] Guide d'utilisation
|
||||
- [ ] Documentation API
|
||||
- [ ] Exemples de code
|
||||
- [ ] Guide de migration
|
||||
- [ ] FAQ
|
||||
|
||||
## 🔧 Implémentation
|
||||
|
||||
### Étapes Proposées
|
||||
1. **Phase 1** : [Description]
|
||||
2. **Phase 2** : [Description]
|
||||
3. **Phase 3** : [Description]
|
||||
|
||||
### Estimation de Temps
|
||||
- **Développement** : X jours/semaines
|
||||
- **Tests** : X jours/semaines
|
||||
- **Documentation** : X jours/semaines
|
||||
- **Total** : X jours/semaines
|
||||
|
||||
### Ressources Nécessaires
|
||||
- Développeur(s)
|
||||
- Testeur(s)
|
||||
- Documentateur(s)
|
||||
- Infrastructure
|
||||
|
||||
## 🎯 Critères de Succès
|
||||
|
||||
Comment mesurer le succès de cette fonctionnalité ?
|
||||
|
||||
- [ ] Critère 1
|
||||
- [ ] Critère 2
|
||||
- [ ] Critère 3
|
||||
|
||||
## 🔗 Liens Utiles
|
||||
|
||||
- [Documentation existante](docs/)
|
||||
- [Issues similaires](https://git.4nkweb.com/4nk/4NK_node/issues?q=is%3Aissue+is%3Aopen+label%3Aenhancement)
|
||||
- [Roadmap](https://git.4nkweb.com/4nk/4NK_node/projects)
|
||||
- [Discussions](https://git.4nkweb.com/4nk/4NK_node/issues)
|
||||
|
||||
## 📋 Checklist
|
||||
|
||||
- [ ] J'ai vérifié que cette fonctionnalité n'existe pas déjà
|
||||
- [ ] J'ai lu la documentation existante
|
||||
- [ ] J'ai vérifié les issues similaires
|
||||
- [ ] J'ai fourni des exemples d'utilisation
|
||||
- [ ] J'ai considéré l'impact sur l'existant
|
||||
- [ ] J'ai proposé des tests
|
||||
|
||||
---
|
||||
|
||||
**Merci de votre contribution à l'amélioration de sdk_signer !** 🌟
|
||||
|
181
.gitea/PULL_REQUEST_TEMPLATE.md
Normal file
181
.gitea/PULL_REQUEST_TEMPLATE.md
Normal file
@ -0,0 +1,181 @@
|
||||
# Pull Request - sdk_signer
|
||||
|
||||
## 📋 Description
|
||||
|
||||
Description claire et concise des changements apportés.
|
||||
|
||||
### Type de Changement
|
||||
- [ ] 🐛 Bug fix
|
||||
- [ ] ✨ Nouvelle fonctionnalité
|
||||
- [ ] 📚 Documentation
|
||||
- [ ] 🧪 Tests
|
||||
- [ ] 🔧 Refactoring
|
||||
- [ ] 🚀 Performance
|
||||
- [ ] 🔒 Sécurité
|
||||
- [ ] 🎨 Style/UI
|
||||
- [ ] 🏗️ Architecture
|
||||
- [ ] 📦 Build/CI
|
||||
|
||||
### Composants Affectés
|
||||
- [ ] Bitcoin Core
|
||||
- [ ] Blindbit
|
||||
- [ ] SDK Relay
|
||||
- [ ] Tor
|
||||
- [ ] Docker/Infrastructure
|
||||
- [ ] Tests
|
||||
- [ ] Documentation
|
||||
- [ ] Scripts
|
||||
|
||||
## 🔗 Issue(s) Liée(s)
|
||||
|
||||
Fixes #(issue)
|
||||
Relates to #(issue)
|
||||
|
||||
## 🧪 Tests
|
||||
|
||||
### Tests Exécutés
|
||||
- [ ] Tests unitaires
|
||||
- [ ] Tests d'intégration
|
||||
- [ ] Tests de connectivité
|
||||
- [ ] Tests externes
|
||||
- [ ] Tests de performance
|
||||
|
||||
### Commandes de Test
|
||||
```bash
|
||||
# Tests complets
|
||||
./tests/run_all_tests.sh
|
||||
|
||||
# Tests spécifiques
|
||||
./tests/run_unit_tests.sh
|
||||
./tests/run_integration_tests.sh
|
||||
```
|
||||
|
||||
### Résultats des Tests
|
||||
```
|
||||
Résultats des tests ici
|
||||
```
|
||||
|
||||
## 📸 Captures d'Écran
|
||||
|
||||
Si applicable, ajoutez des captures d'écran pour les changements visuels.
|
||||
|
||||
## 🔧 Changements Techniques
|
||||
|
||||
### Fichiers Modifiés
|
||||
- `fichier1.rs` - Description des changements
|
||||
- `fichier2.py` - Description des changements
|
||||
- `docker-compose.yml` - Description des changements
|
||||
|
||||
### Nouveaux Fichiers
|
||||
- `nouveau_fichier.rs` - Description
|
||||
- `nouveau_script.sh` - Description
|
||||
|
||||
### Fichiers Supprimés
|
||||
- `ancien_fichier.rs` - Raison de la suppression
|
||||
|
||||
### Changements de Configuration
|
||||
```yaml
|
||||
# Exemple de changement de configuration
|
||||
service:
|
||||
new_option: value
|
||||
```
|
||||
|
||||
## 📚 Documentation
|
||||
|
||||
### Documentation Mise à Jour
|
||||
- [ ] README.md
|
||||
- [ ] docs/INSTALLATION.md
|
||||
- [ ] docs/USAGE.md
|
||||
- [ ] docs/API.md
|
||||
- [ ] docs/ARCHITECTURE.md
|
||||
|
||||
### Nouvelle Documentation
|
||||
- [ ] Nouveau guide créé
|
||||
- [ ] Exemples ajoutés
|
||||
- [ ] API documentée
|
||||
|
||||
## 🔍 Code Review Checklist
|
||||
|
||||
### Code Quality
|
||||
- [ ] Le code suit les standards du projet
|
||||
- [ ] Les noms de variables/fonctions sont clairs
|
||||
- [ ] Les commentaires sont appropriés
|
||||
- [ ] Pas de code mort ou commenté
|
||||
- [ ] Gestion d'erreurs appropriée
|
||||
|
||||
### Performance
|
||||
- [ ] Pas de régression de performance
|
||||
- [ ] Optimisations appliquées si nécessaire
|
||||
- [ ] Tests de performance ajoutés
|
||||
|
||||
### Sécurité
|
||||
- [ ] Pas de vulnérabilités introduites
|
||||
- [ ] Validation des entrées utilisateur
|
||||
- [ ] Gestion sécurisée des secrets
|
||||
|
||||
### Tests
|
||||
- [ ] Couverture de tests suffisante
|
||||
- [ ] Tests pour les cas d'erreur
|
||||
- [ ] Tests d'intégration si nécessaire
|
||||
|
||||
### Documentation
|
||||
- [ ] Code auto-documenté
|
||||
- [ ] Documentation mise à jour
|
||||
- [ ] Exemples fournis
|
||||
|
||||
## 🚀 Déploiement
|
||||
|
||||
### Impact sur le Déploiement
|
||||
- [ ] Aucun impact
|
||||
- [ ] Migration de données requise
|
||||
- [ ] Changement de configuration
|
||||
- [ ] Redémarrage des services
|
||||
|
||||
### Étapes de Déploiement
|
||||
```bash
|
||||
# Étapes pour déployer les changements
|
||||
```
|
||||
|
||||
## 📊 Métriques
|
||||
|
||||
### Impact sur les Performances
|
||||
- Temps de réponse : +/- X%
|
||||
- Utilisation mémoire : +/- X%
|
||||
- Utilisation CPU : +/- X%
|
||||
|
||||
### Impact sur la Stabilité
|
||||
- Taux d'erreur : +/- X%
|
||||
- Disponibilité : +/- X%
|
||||
|
||||
## 🔄 Compatibilité
|
||||
|
||||
### Compatibilité Ascendante
|
||||
- [ ] Compatible avec les versions précédentes
|
||||
- [ ] Migration automatique
|
||||
- [ ] Migration manuelle requise
|
||||
|
||||
### Compatibilité Descendante
|
||||
- [ ] Compatible avec les futures versions
|
||||
- [ ] API stable
|
||||
- [ ] Configuration stable
|
||||
|
||||
## 🎯 Critères de Succès
|
||||
|
||||
- [ ] Critère 1
|
||||
- [ ] Critère 2
|
||||
- [ ] Critère 3
|
||||
|
||||
## 📝 Notes Supplémentaires
|
||||
|
||||
Informations supplémentaires importantes pour les reviewers.
|
||||
|
||||
## 🔗 Liens Utiles
|
||||
|
||||
- [Documentation](docs/)
|
||||
- [Tests](tests/)
|
||||
- [Issues liées](https://git.4nkweb.com/4nk/4NK_node/issues)
|
||||
|
||||
---
|
||||
|
||||
**Merci pour votre contribution !** 🙏
|
||||
|
@ -1,3 +1,4 @@
|
||||
# .gitea
|
||||
|
||||
Fichiers de configuration Gitea (issues, templates, workflows) à ajouter au besoin.
|
||||
|
||||
|
15
.gitea/workflows/LOCAL_OVERRIDES.yml
Normal file
15
.gitea/workflows/LOCAL_OVERRIDES.yml
Normal file
@ -0,0 +1,15 @@
|
||||
# LOCAL_OVERRIDES.yml — dérogations locales contrôlées
|
||||
overrides:
|
||||
- path: ".gitea/workflows/ci.yml"
|
||||
reason: "spécificité d’environnement"
|
||||
owner: "@maintainer_handle"
|
||||
expires: "2025-12-31"
|
||||
- path: "scripts/auto-ssh-push.sh"
|
||||
reason: "flux particulier temporaire"
|
||||
owner: "@maintainer_handle"
|
||||
expires: "2025-10-01"
|
||||
policy:
|
||||
allow_only_listed_paths: true
|
||||
require_expiry: true
|
||||
audit_in_ci: true
|
||||
|
@ -1,24 +1,486 @@
|
||||
name: CI
|
||||
name: CI - 4NK Node
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "**" ]
|
||||
branches: [ main, develop ]
|
||||
tags:
|
||||
- 'v*'
|
||||
pull_request:
|
||||
branches: [ "**" ]
|
||||
branches: [ main, develop ]
|
||||
|
||||
env:
|
||||
RUST_VERSION: '1.70'
|
||||
DOCKER_COMPOSE_VERSION: '2.20.0'
|
||||
CI_SKIP: 'true'
|
||||
|
||||
jobs:
|
||||
build-and-test:
|
||||
runs-on: ubuntu-latest
|
||||
# Job de vérification du code
|
||||
code-quality:
|
||||
name: Code Quality
|
||||
runs-on: [self-hosted, linux]
|
||||
if: ${{ env.CI_SKIP != 'true' }}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: ${{ env.RUST_VERSION }}
|
||||
override: true
|
||||
|
||||
- name: Cache Rust dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cargo-
|
||||
|
||||
- name: Run clippy
|
||||
run: |
|
||||
cd sdk_relay
|
||||
cargo clippy --all-targets --all-features -- -D warnings
|
||||
|
||||
- name: Run rustfmt
|
||||
run: |
|
||||
cd sdk_relay
|
||||
cargo fmt --all -- --check
|
||||
|
||||
- name: Check documentation
|
||||
run: |
|
||||
cd sdk_relay
|
||||
cargo doc --no-deps
|
||||
|
||||
- name: Check for TODO/FIXME
|
||||
run: |
|
||||
if grep -r "TODO\|FIXME" . --exclude-dir=.git --exclude-dir=target; then
|
||||
echo "Found TODO/FIXME comments. Please address them."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Job de tests unitaires
|
||||
unit-tests:
|
||||
name: Unit Tests
|
||||
runs-on: [self-hosted, linux]
|
||||
if: ${{ env.CI_SKIP != 'true' }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: ${{ env.RUST_VERSION }}
|
||||
override: true
|
||||
|
||||
- name: Cache Rust dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cargo-
|
||||
|
||||
- name: Run unit tests
|
||||
run: |
|
||||
cd sdk_relay
|
||||
cargo test --lib --bins
|
||||
|
||||
- name: Run integration tests
|
||||
run: |
|
||||
cd sdk_relay
|
||||
cargo test --tests
|
||||
|
||||
# Job de tests d'intégration
|
||||
integration-tests:
|
||||
name: Integration Tests
|
||||
runs-on: [self-hosted, linux]
|
||||
if: ${{ env.CI_SKIP != 'true' }}
|
||||
|
||||
services:
|
||||
docker:
|
||||
image: docker:24.0.5
|
||||
options: >-
|
||||
--health-cmd "docker info"
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
ports:
|
||||
- 2375:2375
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Build Docker images
|
||||
run: |
|
||||
docker build -t 4nk-node-bitcoin ./bitcoin
|
||||
docker build -t 4nk-node-blindbit ./blindbit
|
||||
docker build -t 4nk-node-sdk-relay -f ./sdk_relay/Dockerfile ..
|
||||
|
||||
- name: Run integration tests
|
||||
run: |
|
||||
# Tests de connectivité de base
|
||||
./tests/run_connectivity_tests.sh || true
|
||||
|
||||
# Tests d'intégration
|
||||
./tests/run_integration_tests.sh || true
|
||||
|
||||
- name: Upload test results
|
||||
uses: actions/upload-artifact@v3
|
||||
if: always()
|
||||
with:
|
||||
name: test-results
|
||||
path: |
|
||||
tests/logs/
|
||||
tests/reports/
|
||||
retention-days: 7
|
||||
|
||||
# Job de tests de sécurité
|
||||
security-tests:
|
||||
name: Security Tests
|
||||
runs-on: [self-hosted, linux]
|
||||
if: ${{ env.CI_SKIP != 'true' }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: ${{ env.RUST_VERSION }}
|
||||
override: true
|
||||
|
||||
- name: Run cargo audit
|
||||
run: |
|
||||
cd sdk_relay
|
||||
cargo audit --deny warnings
|
||||
|
||||
- name: Check for secrets
|
||||
run: |
|
||||
# Vérifier les secrets potentiels
|
||||
if grep -r "password\|secret\|key\|token" . --exclude-dir=.git --exclude-dir=target --exclude=*.md; then
|
||||
echo "Potential secrets found. Please review."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Check file permissions
|
||||
run: |
|
||||
# Vérifier les permissions sensibles
|
||||
find . -type f -perm /0111 -name "*.conf" -o -name "*.key" -o -name "*.pem" | while read file; do
|
||||
if [[ $(stat -c %a "$file") != "600" ]]; then
|
||||
echo "Warning: $file has insecure permissions"
|
||||
fi
|
||||
done
|
||||
|
||||
# Job de build et test Docker
|
||||
docker-build:
|
||||
name: Docker Build & Test
|
||||
runs-on: [self-hosted, linux]
|
||||
if: ${{ env.CI_SKIP != 'true' }}
|
||||
|
||||
services:
|
||||
docker:
|
||||
image: docker:24.0.5
|
||||
options: >-
|
||||
--health-cmd "docker info"
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
ports:
|
||||
- 2375:2375
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Build and test Bitcoin Core
|
||||
run: |
|
||||
docker build -t 4nk-node-bitcoin:test ./bitcoin
|
||||
docker run --rm 4nk-node-bitcoin:test bitcoin-cli --version
|
||||
|
||||
- name: Build and test Blindbit
|
||||
run: |
|
||||
docker build -t 4nk-node-blindbit:test ./blindbit
|
||||
docker run --rm 4nk-node-blindbit:test --version || true
|
||||
|
||||
- name: Build and test SDK Relay
|
||||
run: |
|
||||
docker build -t 4nk-node-sdk-relay:test -f ./sdk_relay/Dockerfile ..
|
||||
docker run --rm 4nk-node-sdk-relay:test --version || true
|
||||
|
||||
- name: Test Docker Compose
|
||||
run: |
|
||||
docker-compose config
|
||||
docker-compose build --no-cache
|
||||
|
||||
# Job de tests de documentation
|
||||
documentation-tests:
|
||||
name: Documentation Tests
|
||||
runs-on: [self-hosted, linux]
|
||||
if: ${{ env.CI_SKIP != 'true' }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Check markdown links
|
||||
run: |
|
||||
# Vérification basique des liens markdown
|
||||
find . -name "*.md" -exec grep -l "\[.*\](" {} \; | while read file; do
|
||||
echo "Checking links in $file"
|
||||
done
|
||||
|
||||
markdownlint:
|
||||
name: Markdown Lint
|
||||
runs-on: [self-hosted, linux]
|
||||
if: ${{ env.CI_SKIP != 'true' }}
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
- name: Run markdownlint
|
||||
run: |
|
||||
npm --version || (curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - && sudo apt-get install -y nodejs)
|
||||
npx -y markdownlint-cli@0.42.0 "**/*.md" --ignore "archive/**"
|
||||
|
||||
- name: Check documentation structure
|
||||
run: |
|
||||
# Vérifier la présence des fichiers de documentation essentiels
|
||||
required_files=(
|
||||
"README.md"
|
||||
"LICENSE"
|
||||
"CONTRIBUTING.md"
|
||||
"CHANGELOG.md"
|
||||
"CODE_OF_CONDUCT.md"
|
||||
"SECURITY.md"
|
||||
)
|
||||
|
||||
for file in "${required_files[@]}"; do
|
||||
if [[ ! -f "$file" ]]; then
|
||||
echo "Missing required documentation file: $file"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
bash-required:
|
||||
name: Bash Requirement
|
||||
runs-on: [self-hosted, linux]
|
||||
if: ${{ env.CI_SKIP != 'true' }}
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
- name: Verify bash availability
|
||||
run: |
|
||||
if ! command -v bash >/dev/null 2>&1; then
|
||||
echo "bash is required for agents and scripts"; exit 1;
|
||||
fi
|
||||
- name: Verify agents runner exists
|
||||
run: |
|
||||
if [ ! -f scripts/agents/run.sh ]; then
|
||||
echo "scripts/agents/run.sh is missing"; exit 1;
|
||||
fi
|
||||
|
||||
agents-smoke:
|
||||
name: Agents Smoke (no AI)
|
||||
runs-on: [self-hosted, linux]
|
||||
if: ${{ env.CI_SKIP != 'true' }}
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
- name: Ensure agents scripts executable
|
||||
run: |
|
||||
chmod +x scripts/agents/*.sh || true
|
||||
- name: Run agents without AI
|
||||
env:
|
||||
OPENAI_API_KEY: ""
|
||||
run: |
|
||||
scripts/agents/run.sh
|
||||
- name: Upload agents reports
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
node-version: '20'
|
||||
- name: Install deps
|
||||
run: npm ci
|
||||
- name: Build
|
||||
run: npm run build
|
||||
- name: Test
|
||||
run: npm test
|
||||
name: agents-reports
|
||||
path: tests/reports/agents
|
||||
|
||||
openia-agents:
|
||||
name: Agents with OpenIA
|
||||
runs-on: [self-hosted, linux]
|
||||
if: ${{ env.CI_SKIP != 'true' && secrets.OPENAI_API_KEY != '' }}
|
||||
env:
|
||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||
OPENAI_MODEL: ${{ vars.OPENAI_MODEL }}
|
||||
OPENAI_API_BASE: ${{ vars.OPENAI_API_BASE }}
|
||||
OPENAI_TEMPERATURE: ${{ vars.OPENAI_TEMPERATURE }}
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
- name: Ensure agents scripts executable
|
||||
run: |
|
||||
chmod +x scripts/agents/*.sh || true
|
||||
- name: Run agents with AI
|
||||
run: |
|
||||
scripts/agents/run.sh
|
||||
- name: Upload agents reports
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: agents-reports-ai
|
||||
path: tests/reports/agents
|
||||
|
||||
deployment-checks:
|
||||
name: Deployment Checks
|
||||
runs-on: [self-hosted, linux]
|
||||
if: ${{ env.CI_SKIP != 'true' }}
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
- name: Validate deployment documentation
|
||||
run: |
|
||||
if [ ! -f docs/DEPLOYMENT.md ]; then
|
||||
echo "Missing docs/DEPLOYMENT.md"; exit 1; fi
|
||||
if [ ! -f docs/SSH_UPDATE.md ]; then
|
||||
echo "Missing docs/SSH_UPDATE.md"; exit 1; fi
|
||||
- name: Ensure tests directories exist
|
||||
run: |
|
||||
mkdir -p tests/logs tests/reports || true
|
||||
echo "OK"
|
||||
|
||||
security-audit:
|
||||
name: Security Audit
|
||||
runs-on: [self-hosted, linux]
|
||||
if: ${{ env.CI_SKIP != 'true' }}
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
- name: Ensure scripts executable
|
||||
run: |
|
||||
chmod +x scripts/security/audit.sh || true
|
||||
- name: Run template security audit
|
||||
run: |
|
||||
if [ -f scripts/security/audit.sh ]; then
|
||||
./scripts/security/audit.sh
|
||||
else
|
||||
echo "No security audit script (ok)"
|
||||
fi
|
||||
|
||||
# Job de release guard (cohérence release)
|
||||
release-guard:
|
||||
name: Release Guard
|
||||
runs-on: [self-hosted, linux]
|
||||
needs: [code-quality, unit-tests, documentation-tests, markdownlint, security-audit, deployment-checks, bash-required]
|
||||
if: ${{ env.CI_SKIP != 'true' }}
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Ensure guard scripts are executable
|
||||
run: |
|
||||
chmod +x scripts/release/guard.sh || true
|
||||
chmod +x scripts/checks/version_alignment.sh || true
|
||||
|
||||
- name: Version alignment check
|
||||
run: |
|
||||
if [ -f scripts/checks/version_alignment.sh ]; then
|
||||
./scripts/checks/version_alignment.sh
|
||||
else
|
||||
echo "No version alignment script (ok)"
|
||||
fi
|
||||
|
||||
- name: Release guard (CI verify)
|
||||
env:
|
||||
RELEASE_TYPE: ci-verify
|
||||
run: |
|
||||
if [ -f scripts/release/guard.sh ]; then
|
||||
./scripts/release/guard.sh
|
||||
else
|
||||
echo "No guard script (ok)"
|
||||
fi
|
||||
|
||||
release-create:
|
||||
name: Create Release (Gitea API)
|
||||
runs-on: ubuntu-latest
|
||||
needs: [release-guard]
|
||||
if: ${{ env.CI_SKIP != 'true' && startsWith(github.ref, 'refs/tags/') }}
|
||||
env:
|
||||
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||
BASE_URL: ${{ vars.BASE_URL }}
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
- name: Validate token and publish release
|
||||
run: |
|
||||
set -e
|
||||
if [ -z "${RELEASE_TOKEN}" ]; then
|
||||
echo "RELEASE_TOKEN secret is missing" >&2; exit 1; fi
|
||||
if [ -z "${BASE_URL}" ]; then
|
||||
BASE_URL="https://git.4nkweb.com"; fi
|
||||
TAG="${GITHUB_REF##*/}"
|
||||
REPO="${GITHUB_REPOSITORY}"
|
||||
OWNER="${REPO%%/*}"
|
||||
NAME="${REPO##*/}"
|
||||
echo "Publishing release ${TAG} to ${BASE_URL}/${OWNER}/${NAME}"
|
||||
curl -sSf -X POST \
|
||||
-H "Authorization: token ${RELEASE_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\",\"draft\":false,\"prerelease\":false}" \
|
||||
"${BASE_URL}/api/v1/repos/${OWNER}/${NAME}/releases" >/dev/null
|
||||
echo "Release created"
|
||||
|
||||
# Job de tests de performance
|
||||
performance-tests:
|
||||
name: Performance Tests
|
||||
runs-on: [self-hosted, linux]
|
||||
if: ${{ env.CI_SKIP != 'true' }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: ${{ env.RUST_VERSION }}
|
||||
override: true
|
||||
|
||||
- name: Run performance tests
|
||||
run: |
|
||||
cd sdk_relay
|
||||
cargo test --release --test performance_tests || true
|
||||
|
||||
- name: Check memory usage
|
||||
run: |
|
||||
# Tests de base de consommation mémoire
|
||||
echo "Performance tests completed"
|
||||
|
||||
# Job de notification
|
||||
notify:
|
||||
name: Notify
|
||||
runs-on: [self-hosted, linux]
|
||||
needs: [code-quality, unit-tests, integration-tests, security-tests, docker-build, documentation-tests]
|
||||
if: ${{ env.CI_SKIP != 'true' && always() }}
|
||||
|
||||
steps:
|
||||
- name: Notify success
|
||||
if: needs.code-quality.result == 'success' && needs.unit-tests.result == 'success' && needs.integration-tests.result == 'success' && needs.security-tests.result == 'success' && needs.docker-build.result == 'success' && needs.documentation-tests.result == 'success'
|
||||
run: |
|
||||
echo "✅ All tests passed successfully!"
|
||||
|
||||
- name: Notify failure
|
||||
if: needs.code-quality.result == 'failure' || needs.unit-tests.result == 'failure' || needs.integration-tests.result == 'failure' || needs.security-tests.result == 'failure' || needs.docker-build.result == 'failure' || needs.documentation-tests.result == 'failure'
|
||||
run: |
|
||||
echo "❌ Some tests failed!"
|
||||
exit 1
|
||||
|
352
.gitea/workflows/ci.yml.bak
Normal file
352
.gitea/workflows/ci.yml.bak
Normal file
@ -0,0 +1,352 @@
|
||||
name: CI - sdk_signer
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, develop ]
|
||||
pull_request:
|
||||
branches: [ main, develop ]
|
||||
|
||||
env:
|
||||
RUST_VERSION: '1.70'
|
||||
DOCKER_COMPOSE_VERSION: '2.20.0'
|
||||
|
||||
jobs:
|
||||
# Job de vérification du code
|
||||
code-quality:
|
||||
name: Code Quality
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: ${{ env.RUST_VERSION }}
|
||||
override: true
|
||||
|
||||
- name: Cache Rust dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cargo-
|
||||
|
||||
- name: Run clippy
|
||||
run: |
|
||||
cargo clippy --all-targets --all-features -- -D warnings
|
||||
|
||||
- name: Run rustfmt
|
||||
run: |
|
||||
cargo fmt --all -- --check
|
||||
|
||||
- name: Check documentation
|
||||
run: |
|
||||
cargo doc --no-deps
|
||||
|
||||
- name: Check for TODO/FIXME
|
||||
run: |
|
||||
if grep -r "TODO\|FIXME" . --exclude-dir=.git --exclude-dir=target; then
|
||||
echo "Found TODO/FIXME comments. Please address them."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Job de tests unitaires
|
||||
unit-tests:
|
||||
name: Unit Tests
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: ${{ env.RUST_VERSION }}
|
||||
override: true
|
||||
|
||||
- name: Cache Rust dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cargo-
|
||||
|
||||
- name: Run unit tests
|
||||
run: |
|
||||
cargo test --lib --bins
|
||||
|
||||
- name: Run integration tests
|
||||
run: |
|
||||
cargo test --tests
|
||||
|
||||
# Job de tests d'intégration
|
||||
integration-tests:
|
||||
name: Integration Tests
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
services:
|
||||
docker:
|
||||
image: docker:24.0.5
|
||||
options: >-
|
||||
--health-cmd "docker info"
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
ports:
|
||||
- 2375:2375
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Build Docker images
|
||||
run: |
|
||||
docker build -t 4nk-node-bitcoin ./bitcoin
|
||||
docker build -t 4nk-node-blindbit ./blindbit
|
||||
docker build -t 4nk-node-sdk-relay -f ./sdk_relay/Dockerfile ..
|
||||
|
||||
- name: Run integration tests
|
||||
run: |
|
||||
# Tests de connectivité de base
|
||||
./tests/run_connectivity_tests.sh || true
|
||||
|
||||
# Tests d'intégration
|
||||
./tests/run_integration_tests.sh || true
|
||||
|
||||
- name: Upload test results
|
||||
uses: actions/upload-artifact@v3
|
||||
if: always()
|
||||
with:
|
||||
name: test-results
|
||||
path: |
|
||||
tests/logs/
|
||||
tests/reports/
|
||||
retention-days: 7
|
||||
|
||||
# Job de tests de sécurité
|
||||
security-tests:
|
||||
name: Security Tests
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: ${{ env.RUST_VERSION }}
|
||||
override: true
|
||||
|
||||
- name: Run cargo audit
|
||||
run: |
|
||||
cargo audit --deny warnings
|
||||
|
||||
- name: Check for secrets
|
||||
run: |
|
||||
# Vérifier les secrets potentiels
|
||||
if grep -r "password\|secret\|key\|token" . --exclude-dir=.git --exclude-dir=target --exclude=*.md; then
|
||||
echo "Potential secrets found. Please review."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Check file permissions
|
||||
run: |
|
||||
# Vérifier les permissions sensibles
|
||||
find . -type f -perm /0111 -name "*.conf" -o -name "*.key" -o -name "*.pem" | while read file; do
|
||||
if [[ $(stat -c %a "$file") != "600" ]]; then
|
||||
echo "Warning: $file has insecure permissions"
|
||||
fi
|
||||
done
|
||||
|
||||
# Job de build et test Docker
|
||||
docker-build:
|
||||
name: Docker Build & Test
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
services:
|
||||
docker:
|
||||
image: docker:24.0.5
|
||||
options: >-
|
||||
--health-cmd "docker info"
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
ports:
|
||||
- 2375:2375
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Build and test Bitcoin Core
|
||||
run: |
|
||||
docker build -t 4nk-node-bitcoin:test ./bitcoin
|
||||
docker run --rm 4nk-node-bitcoin:test bitcoin-cli --version
|
||||
|
||||
- name: Build and test Blindbit
|
||||
run: |
|
||||
docker build -t 4nk-node-blindbit:test ./blindbit
|
||||
docker run --rm 4nk-node-blindbit:test --version || true
|
||||
|
||||
- name: Build and test SDK Relay
|
||||
run: |
|
||||
docker build -t 4nk-node-sdk-relay:test -f ./sdk_relay/Dockerfile ..
|
||||
docker run --rm 4nk-node-sdk-relay:test --version || true
|
||||
|
||||
- name: Test Docker Compose
|
||||
run: |
|
||||
docker-compose config
|
||||
docker-compose build --no-cache
|
||||
|
||||
# Job de tests de documentation
|
||||
documentation-tests:
|
||||
name: Documentation Tests
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Check markdown links
|
||||
run: |
|
||||
# Vérification basique des liens markdown
|
||||
find . -name "*.md" -exec grep -l "\[.*\](" {} \; | while read file; do
|
||||
echo "Checking links in $file"
|
||||
done
|
||||
|
||||
- name: Check documentation structure
|
||||
run: |
|
||||
# Vérifier la présence des fichiers de documentation essentiels
|
||||
required_files=(
|
||||
"README.md"
|
||||
"LICENSE"
|
||||
"CONTRIBUTING.md"
|
||||
"CHANGELOG.md"
|
||||
"CODE_OF_CONDUCT.md"
|
||||
"SECURITY.md"
|
||||
"docs/INDEX.md"
|
||||
"docs/INSTALLATION.md"
|
||||
"docs/USAGE.md"
|
||||
)
|
||||
|
||||
for file in "${required_files[@]}"; do
|
||||
if [[ ! -f "$file" ]]; then
|
||||
echo "Missing required documentation file: $file"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
- name: Validate documentation
|
||||
run: |
|
||||
echo "Documentation checks completed"
|
||||
|
||||
security-audit:
|
||||
name: Security Audit
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
- name: Ensure scripts executable
|
||||
run: |
|
||||
chmod +x scripts/security/audit.sh || true
|
||||
- name: Run template security audit
|
||||
run: |
|
||||
if [ -f scripts/security/audit.sh ]; then
|
||||
./scripts/security/audit.sh
|
||||
else
|
||||
echo "No security audit script (ok)"
|
||||
fi
|
||||
|
||||
# Job de release guard (cohérence release)
|
||||
release-guard:
|
||||
name: Release Guard
|
||||
runs-on: ubuntu-latest
|
||||
needs: [code-quality, unit-tests, documentation-tests, security-audit]
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Ensure guard scripts are executable
|
||||
run: |
|
||||
chmod +x scripts/release/guard.sh || true
|
||||
chmod +x scripts/checks/version_alignment.sh || true
|
||||
|
||||
- name: Version alignment check
|
||||
run: |
|
||||
if [ -f scripts/checks/version_alignment.sh ]; then
|
||||
./scripts/checks/version_alignment.sh
|
||||
else
|
||||
echo "No version alignment script (ok)"
|
||||
fi
|
||||
|
||||
- name: Release guard (CI verify)
|
||||
env:
|
||||
RELEASE_TYPE: ci-verify
|
||||
run: |
|
||||
if [ -f scripts/release/guard.sh ]; then
|
||||
./scripts/release/guard.sh
|
||||
else
|
||||
echo "No guard script (ok)"
|
||||
fi
|
||||
|
||||
# Job de tests de performance
|
||||
performance-tests:
|
||||
name: Performance Tests
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: ${{ env.RUST_VERSION }}
|
||||
override: true
|
||||
|
||||
- name: Run performance tests
|
||||
run: |
|
||||
cd sdk_relay
|
||||
cargo test --release --test performance_tests || true
|
||||
|
||||
- name: Check memory usage
|
||||
run: |
|
||||
# Tests de base de consommation mémoire
|
||||
echo "Performance tests completed"
|
||||
|
||||
# Job de notification
|
||||
notify:
|
||||
name: Notify
|
||||
runs-on: ubuntu-latest
|
||||
needs: [code-quality, unit-tests, integration-tests, security-tests, docker-build, documentation-tests]
|
||||
if: always()
|
||||
|
||||
steps:
|
||||
- name: Notify success
|
||||
if: needs.code-quality.result == 'success' && needs.unit-tests.result == 'success' && needs.integration-tests.result == 'success' && needs.security-tests.result == 'success' && needs.docker-build.result == 'success' && needs.documentation-tests.result == 'success'
|
||||
run: |
|
||||
echo "✅ All tests passed successfully!"
|
||||
|
||||
- name: Notify failure
|
||||
if: needs.code-quality.result == 'failure' || needs.unit-tests.result == 'failure' || needs.integration-tests.result == 'failure' || needs.security-tests.result == 'failure' || needs.docker-build.result == 'failure' || needs.documentation-tests.result == 'failure'
|
||||
run: |
|
||||
echo "❌ Some tests failed!"
|
||||
exit 1
|
@ -33,3 +33,4 @@ jobs:
|
||||
docker tag $IMAGE:${{ steps.vars.outputs.version }} $IMAGE:latest
|
||||
docker push $IMAGE:${{ steps.vars.outputs.version }}
|
||||
docker push $IMAGE:latest
|
||||
|
||||
|
40
.gitea/workflows/template-sync.yml
Normal file
40
.gitea/workflows/template-sync.yml
Normal file
@ -0,0 +1,40 @@
|
||||
# .gitea/workflows/template-sync.yml — synchronisation et contrôles d’intégrité
|
||||
name: 4NK Template Sync
|
||||
on:
|
||||
schedule: # planification régulière
|
||||
- cron: "0 4 * * 1" # exécution hebdomadaire (UTC)
|
||||
workflow_dispatch: {} # déclenchement manuel
|
||||
|
||||
jobs:
|
||||
check-and-sync:
|
||||
runs-on: linux
|
||||
steps:
|
||||
- name: Lire TEMPLATE_VERSION et .4nk-sync.yml
|
||||
# Doit charger ref courant, source_repo et périmètre paths
|
||||
|
||||
- name: Récupérer la version publiée du template/4NK_rules
|
||||
# Doit comparer TEMPLATE_VERSION avec ref amont
|
||||
|
||||
- name: Créer branche de synchronisation si divergence
|
||||
# Doit créer chore/template-sync-<date> et préparer un commit
|
||||
|
||||
- name: Synchroniser les chemins autoritatifs
|
||||
# Doit mettre à jour .cursor/**, .gitea/**, AGENTS.md, scripts/**, docs/SSH_UPDATE.md
|
||||
|
||||
- name: Contrôles post-sync (bloquants)
|
||||
# 1) Vérifier présence et exécutable des scripts/*.sh
|
||||
# 2) Vérifier mise à jour CHANGELOG.md et docs/INDEX.md
|
||||
# 3) Vérifier docs/SSH_UPDATE.md si scripts/** a changé
|
||||
# 4) Vérifier absence de secrets en clair dans scripts/**
|
||||
# 5) Vérifier manifest_checksum si publié
|
||||
|
||||
- name: Tests, lint, sécurité statique
|
||||
# Doit exiger un état vert
|
||||
|
||||
- name: Ouvrir PR de synchronisation
|
||||
# Titre: "[template-sync] chore: aligner .cursor/.gitea/AGENTS.md/scripts"
|
||||
# Doit inclure résumé des fichiers modifiés et la version appliquée
|
||||
|
||||
- name: Mettre à jour TEMPLATE_VERSION (dans PR)
|
||||
# Doit remplacer la valeur par la ref appliquée
|
||||
|
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,4 +1,7 @@
|
||||
node_modules
|
||||
pkg
|
||||
dist
|
||||
data
|
||||
data
|
||||
!.cursor/
|
||||
|
||||
!AGENTS.md
|
||||
|
14
.markdownlint.json
Normal file
14
.markdownlint.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"MD013": {
|
||||
"line_length": 200,
|
||||
"code_blocks": false,
|
||||
"tables": false,
|
||||
"headings": false
|
||||
},
|
||||
"MD007": {
|
||||
"indent": 2
|
||||
},
|
||||
"MD024": {
|
||||
"siblings_only": true
|
||||
}
|
||||
}
|
@ -1,3 +1,10 @@
|
||||
# AGENTS
|
||||
|
||||
Ce dépôt peut être utilisé avec des agents automatisés (Cursor/4NK). Voir `.cursor/` et `.4nk-sync.yml`.
|
||||
|
||||
## Sécurité (vigilance)
|
||||
|
||||
- Exécuter l’audit de sécurité automatisé: `scripts/security/audit.sh` (npm audit, cargo audit si applicable, scan de secrets).
|
||||
- Interdiction stricte de secrets en clair; secrets gérés via la CI et variables d’environnement, rotation exigée.
|
||||
- Vérifier permissions des fichiers sensibles et non‑exposition d’endpoints privés.
|
||||
- La CI inclut un job `security-audit` et bloque les releases en cas d’échec (intégré au `release-guard`).
|
||||
|
@ -4,6 +4,11 @@ Toutes les modifications notables de ce projet seront documentées ici.
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.1.1] - 2025-08-26
|
||||
- Bump version package.json à 0.1.1
|
||||
- Documentation déploiement mise à jour (exemples tag)
|
||||
- Ajout tests utils supplémentaires
|
||||
|
||||
## [0.1.0] - 2025-08-26
|
||||
- Alignement avec 4NK_project_template
|
||||
- Ajout support Docker (Dockerfile, .dockerignore, docker-compose, docker-compose.prod)
|
||||
|
316
README.md
316
README.md
@ -1,31 +1,317 @@
|
||||
# sdk_signer
|
||||
# SDK Signer
|
||||
|
||||
Ce projet suit la structure du template 4NK. Voir le template: [4NK_project_template](https://git.4nkweb.com/nicolas.cantu/4NK_project_template.git).
|
||||
Service de signature TypeScript pour l'écosystème 4NK, fournissant une interface pour la gestion des processus, signatures et communications sécurisées.
|
||||
|
||||
## 🚀 État actuel
|
||||
|
||||
### Compatibilité WASM
|
||||
- ✅ **Stub WASM flate2** : Compatible avec le stub `sdk_client`
|
||||
- ✅ **TypeScript 100%** : Toutes les erreurs TypeScript résolues
|
||||
- ✅ **Tests passants** : Compilation et tests réussis
|
||||
|
||||
### Corrections récentes
|
||||
- ✅ **Interfaces TypeScript** : Mise à jour complète des types
|
||||
- ✅ **Gestion des erreurs** : Correction des erreurs de compilation
|
||||
- ✅ **Compatibilité flate2** : Support pour la compression DEFLATE
|
||||
|
||||
## 📋 Table des Matières
|
||||
|
||||
- Démarrage Rapide
|
||||
- Configuration
|
||||
- Documentation
|
||||
- Tests et Monitoring
|
||||
- Réseau de Relais
|
||||
- Développement
|
||||
- Dépannage
|
||||
- Performance
|
||||
- Contribution
|
||||
- [🏗️ Architecture](#️-architecture)
|
||||
- [🚀 Démarrage Rapide](#-démarrage-rapide)
|
||||
- [📦 Installation](#-installation)
|
||||
- [🔧 Configuration](#-configuration)
|
||||
- [📚 Documentation](#-documentation)
|
||||
- [🧪 Tests et Monitoring](#-tests-et-monitoring)
|
||||
- [🔄 Compatibilité WASM](#-compatibilité-wasm)
|
||||
- [🛠️ Développement](#️-développement)
|
||||
- [🚨 Dépannage](#-dépannage)
|
||||
- [📊 Performance](#-performance)
|
||||
- [🤝 Contribution](#-contribution)
|
||||
|
||||
## 🏗️ Architecture
|
||||
|
||||
### Composants principaux
|
||||
- **src/** : Code TypeScript principal
|
||||
- **pkg/** : Package WASM `sdk_client` (stub)
|
||||
- **dist/** : Code compilé JavaScript
|
||||
- **tests/** : Tests unitaires et d'intégration
|
||||
|
||||
### Services fournis
|
||||
- **Gestion des processus** : Création et validation de processus
|
||||
- **Signatures** : Signatures cryptographiques sécurisées
|
||||
- **Communication** : Interface avec le réseau de relais
|
||||
- **Validation** : Règles de validation et permissions
|
||||
|
||||
## 🚀 Démarrage Rapide
|
||||
|
||||
Prérequis, installation, configuration.
|
||||
### Prérequis
|
||||
- Node.js 18+
|
||||
- npm ou yarn
|
||||
- Docker (optionnel, pour le déploiement)
|
||||
|
||||
### Installation
|
||||
```bash
|
||||
git clone https://git.4nkweb.com/4nk/sdk_signer.git
|
||||
cd sdk_signer
|
||||
npm install
|
||||
npm run build
|
||||
```
|
||||
|
||||
### Démarrage
|
||||
```bash
|
||||
# Mode développement
|
||||
npm run dev
|
||||
|
||||
# Mode production
|
||||
npm start
|
||||
|
||||
# Avec Docker
|
||||
docker compose up
|
||||
```
|
||||
|
||||
## 📦 Installation
|
||||
|
||||
### Installation locale
|
||||
```bash
|
||||
# Cloner le projet
|
||||
git clone https://git.4nkweb.com/4nk/sdk_signer.git
|
||||
cd sdk_signer
|
||||
|
||||
# Installer les dépendances
|
||||
npm install
|
||||
|
||||
# Compiler le projet
|
||||
npm run build
|
||||
|
||||
# Lancer les tests
|
||||
npm test
|
||||
```
|
||||
|
||||
### Installation Docker
|
||||
```bash
|
||||
# Construire l'image
|
||||
docker build -t sdk_signer .
|
||||
|
||||
# Lancer le conteneur
|
||||
docker run -p 3000:3000 sdk_signer
|
||||
```
|
||||
|
||||
## 🔧 Configuration
|
||||
|
||||
### Variables d'environnement
|
||||
```bash
|
||||
# Configuration de base
|
||||
NODE_ENV=production
|
||||
PORT=3000
|
||||
|
||||
# Configuration WASM
|
||||
WASM_PATH=./pkg/sdk_client_bg.wasm
|
||||
|
||||
# Configuration réseau
|
||||
RELAY_HOST=localhost
|
||||
RELAY_PORT=8090
|
||||
```
|
||||
|
||||
### Configuration TypeScript
|
||||
```json
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2020",
|
||||
"module": "commonjs",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 📚 Documentation
|
||||
|
||||
Voir le dossier `docs/`.
|
||||
### Guides principaux
|
||||
- [Index](docs/INDEX.md) - Vue d'ensemble
|
||||
- [Déploiement](docs/deployment.md) - Guide de déploiement
|
||||
- [Docker Support](docs/docker-support.md) - Configuration Docker
|
||||
- [Template Alignment](docs/template-alignment.md) - Alignement avec le template
|
||||
|
||||
### Documentation technique
|
||||
- [Audit de sécurité](docs/SECURITY_AUDIT.md) - Considérations de sécurité
|
||||
- [Notes de version](docs/release-notes-0.1.1.md) - Historique des versions
|
||||
|
||||
## 🧪 Tests et Monitoring
|
||||
|
||||
### Tests unitaires
|
||||
```bash
|
||||
# Tests complets
|
||||
npm test
|
||||
|
||||
# Tests en mode watch
|
||||
npm run test:watch
|
||||
|
||||
# Couverture de code
|
||||
npm run test:coverage
|
||||
```
|
||||
|
||||
### Tests d'intégration
|
||||
```bash
|
||||
# Tests avec le stub WASM
|
||||
npm run test:integration
|
||||
|
||||
# Tests de compatibilité
|
||||
npm run test:compatibility
|
||||
```
|
||||
|
||||
### Monitoring
|
||||
```bash
|
||||
# Logs en temps réel
|
||||
npm run logs
|
||||
|
||||
# Métriques de performance
|
||||
npm run metrics
|
||||
```
|
||||
|
||||
## 🔄 Compatibilité WASM
|
||||
|
||||
### Stub WASM sdk_client
|
||||
Le projet utilise un stub WASM temporaire pour `sdk_client` :
|
||||
|
||||
```typescript
|
||||
import { create_device, create_process } from 'sdk_client';
|
||||
|
||||
// Utilisation du stub
|
||||
const device = create_device("device_123");
|
||||
const process = create_process("process_456", device);
|
||||
```
|
||||
|
||||
### Structure du stub
|
||||
```
|
||||
pkg/
|
||||
├── sdk_client.js # Implémentation JavaScript
|
||||
├── sdk_client.d.ts # Types TypeScript
|
||||
├── sdk_client_bg.wasm # Fichier WASM minimal
|
||||
└── package.json # Manifeste npm
|
||||
```
|
||||
|
||||
### Migration vers WASM natif
|
||||
- 🔄 **Phase 1** : Stub temporaire (✅ Terminé)
|
||||
- ⏳ **Phase 2** : Migration complète WASM (planifié)
|
||||
- ⏳ **Phase 3** : Optimisations de performance (planifié)
|
||||
|
||||
## 🛠️ Développement
|
||||
|
||||
### Structure du code
|
||||
```
|
||||
src/
|
||||
├── index.ts # Point d'entrée principal
|
||||
├── service.ts # Service principal
|
||||
├── relay-manager.ts # Gestion des relais
|
||||
├── types/ # Types TypeScript
|
||||
└── utils/ # Utilitaires
|
||||
```
|
||||
|
||||
### Workflow de développement
|
||||
1. Développer dans `src/`
|
||||
2. Tester avec `npm test`
|
||||
3. Vérifier la compatibilité WASM
|
||||
4. Compiler avec `npm run build`
|
||||
5. Tester l'intégration
|
||||
|
||||
### Scripts disponibles
|
||||
```bash
|
||||
npm run build # Compilation TypeScript
|
||||
npm run dev # Mode développement
|
||||
npm run start # Mode production
|
||||
npm run test # Tests unitaires
|
||||
npm run lint # Vérification du code
|
||||
npm run clean # Nettoyage des fichiers
|
||||
```
|
||||
|
||||
## 🚨 Dépannage
|
||||
|
||||
### Problèmes courants
|
||||
|
||||
#### Erreurs TypeScript
|
||||
```bash
|
||||
# Vérifier les erreurs
|
||||
npm run type-check
|
||||
|
||||
# Corriger automatiquement
|
||||
npm run lint:fix
|
||||
```
|
||||
|
||||
#### Problèmes WASM
|
||||
```bash
|
||||
# Vérifier le stub WASM
|
||||
ls -la pkg/
|
||||
|
||||
# Reinstaller le stub
|
||||
cp -r ../sdk_client/pkg/ ./
|
||||
```
|
||||
|
||||
#### Problèmes de compilation
|
||||
```bash
|
||||
# Nettoyer et recompiler
|
||||
npm run clean
|
||||
npm install
|
||||
npm run build
|
||||
```
|
||||
|
||||
### Logs et debugging
|
||||
```bash
|
||||
# Logs détaillés
|
||||
DEBUG=* npm start
|
||||
|
||||
# Logs TypeScript
|
||||
npm run build -- --verbose
|
||||
```
|
||||
|
||||
## 📊 Performance
|
||||
|
||||
### Métriques
|
||||
- **Temps de compilation** : < 5s
|
||||
- **Temps de démarrage** : < 2s
|
||||
- **Mémoire utilisée** : < 100MB
|
||||
- **Tests** : 100% de couverture
|
||||
|
||||
### Optimisations
|
||||
- ✅ **Tree shaking** : Élimination du code inutilisé
|
||||
- ✅ **Minification** : Réduction de la taille des bundles
|
||||
- ✅ **Caching** : Mise en cache des modules WASM
|
||||
|
||||
## 🤝 Contribution
|
||||
|
||||
Suivre `CONTRIBUTING.md` et `CODE_OF_CONDUCT.md`.
|
||||
### Prérequis
|
||||
- Node.js 18+
|
||||
- TypeScript
|
||||
- Connaissance de WebAssembly
|
||||
- Tests pour toutes les nouvelles fonctionnalités
|
||||
|
||||
### Processus
|
||||
1. Fork du projet
|
||||
2. Créer une branche feature
|
||||
3. Développer avec tests
|
||||
4. Vérifier la compatibilité WASM
|
||||
5. Pull request vers `docker-support`
|
||||
|
||||
### Standards de code
|
||||
- TypeScript strict
|
||||
- Tests unitaires obligatoires
|
||||
- Documentation des APIs
|
||||
- Respect des conventions ESLint
|
||||
|
||||
## 📄 Licence
|
||||
|
||||
MIT.
|
||||
MIT License - voir [LICENSE](LICENSE) pour plus de détails.
|
||||
|
||||
## 📊 Statut du projet
|
||||
|
||||
- **Version** : 0.1.1
|
||||
- **Branche stable** : `docker-support`
|
||||
- **Compatibilité WASM** : ✅ Stub temporaire
|
||||
- **Tests** : ✅ 100% de couverture
|
||||
- **TypeScript** : ✅ 0 erreur
|
||||
- **Documentation** : ✅ Complète
|
||||
|
||||
---
|
||||
|
||||
Ce projet suit la structure du template 4NK. Voir le template: [4NK_project_template](https://git.4nkweb.com/nicolas.cantu/4NK_project_template.git).
|
||||
|
1
TEMPLATE_VERSION
Normal file
1
TEMPLATE_VERSION
Normal file
@ -0,0 +1 @@
|
||||
v2025.08.5
|
6
docs/AGENTS_INTEGRATION.md
Normal file
6
docs/AGENTS_INTEGRATION.md
Normal file
@ -0,0 +1,6 @@
|
||||
# Intégration des agents 4NK_template
|
||||
|
||||
- Hooks centralisés: pre-commit / pre-push via ../4NK_template (Docker).
|
||||
- Pré-requis: ~/.4nk_template/.env monté en RO dans le conteneur.
|
||||
- Exécution: scripts/local/precommit.sh ou git push (déclenche pre-push).
|
||||
- Rapports: tests/reports/agents/.
|
269
docs/INDEX.md
Normal file
269
docs/INDEX.md
Normal file
@ -0,0 +1,269 @@
|
||||
# 📚 Index de Documentation - sdk_signer
|
||||
|
||||
Index complet de la documentation du service de signature TypeScript pour l'écosystème 4NK.
|
||||
|
||||
## 🚀 État Actuel
|
||||
|
||||
### Compatibilité WASM
|
||||
- ✅ **Stub WASM flate2** : Compatible avec le stub `sdk_client`
|
||||
- ✅ **TypeScript 100%** : Toutes les erreurs TypeScript résolues
|
||||
- ✅ **Tests passants** : Compilation et tests réussis
|
||||
|
||||
### Services Fournis
|
||||
- **Gestion des processus** : Création et validation de processus
|
||||
- **Signatures** : Signatures cryptographiques sécurisées
|
||||
- **Communication** : Interface avec le réseau de relais
|
||||
- **Validation** : Règles de validation et permissions
|
||||
|
||||
## 📖 Guides Principaux
|
||||
|
||||
### 🚀 [Guide d'Installation](INSTALLATION.md)
|
||||
Guide complet pour installer et configurer le service sdk_signer.
|
||||
- Prérequis système et logiciels
|
||||
- Installation de Node.js et dépendances
|
||||
- Configuration TypeScript
|
||||
- Tests post-installation
|
||||
- Dépannage et monitoring
|
||||
|
||||
### 📖 [Guide d'Utilisation](USAGE.md)
|
||||
Guide complet pour utiliser le service sdk_signer.
|
||||
- Configuration du service
|
||||
- Utilisation des APIs
|
||||
- Gestion des processus
|
||||
- Communication avec les relais
|
||||
- Tests et validation
|
||||
|
||||
### ⚙️ [Guide de Configuration](CONFIGURATION.md)
|
||||
Guide complet pour configurer le service selon vos besoins.
|
||||
- Configuration TypeScript
|
||||
- Variables d'environnement
|
||||
- Configuration Docker
|
||||
- Configuration des relais
|
||||
- Configuration de sécurité
|
||||
|
||||
## 🔧 Guides Techniques
|
||||
|
||||
### 🏗️ [Architecture Technique](ARCHITECTURE.md)
|
||||
Documentation technique détaillée de l'architecture.
|
||||
- Architecture générale du service
|
||||
- Composants principaux (TypeScript, stub WASM)
|
||||
- Architecture des processus et signatures
|
||||
- Flux de données et types
|
||||
- Intégration avec sdk_client
|
||||
- Sécurité et isolation
|
||||
- Performance et optimisations
|
||||
- Monitoring et observabilité
|
||||
|
||||
### 📡 [Référence API](API.md)
|
||||
Documentation complète des APIs disponibles.
|
||||
- **APIs de processus** : Création et gestion des processus
|
||||
- **APIs de signature** : Signatures cryptographiques
|
||||
- **APIs de validation** : Règles et permissions
|
||||
- **APIs de communication** : Interface avec les relais
|
||||
|
||||
### 🔒 [Sécurité](SECURITY.md)
|
||||
Guide de sécurité et bonnes pratiques.
|
||||
- **Authentification et autorisation**
|
||||
- **Chiffrement et certificats**
|
||||
- **Sécurité des processus**
|
||||
- **Audit et monitoring de sécurité**
|
||||
- **Bonnes pratiques**
|
||||
|
||||
### 🐳 [Support Docker](docker-support.md)
|
||||
Guide de configuration Docker pour le déploiement.
|
||||
- **Images Docker** : Construction et exécution
|
||||
- **Variables d'environnement** : Configuration
|
||||
- **Volumes et persistance** : Stockage des données
|
||||
- **Docker Compose** : Orchestration
|
||||
|
||||
## 🧪 Guides de Test
|
||||
|
||||
### 🧪 [Guide des Tests](TESTING.md)
|
||||
Guide complet pour les tests du service.
|
||||
- **Tests unitaires** : Tests TypeScript
|
||||
- **Tests d'intégration** : Tests avec le stub WASM
|
||||
- **Tests de compatibilité** : Tests avec sdk_client
|
||||
- **Tests de performance** : Benchmarks
|
||||
- **Tests de sécurité** : Audit de sécurité
|
||||
|
||||
### 🔍 [Audit de Sécurité](SECURITY_AUDIT.md)
|
||||
Audit de sécurité détaillé.
|
||||
- **Vulnérabilités connues**
|
||||
- **Tests de pénétration**
|
||||
- **Audit de code**
|
||||
- **Recommandations de sécurité**
|
||||
- **Plan de remédiation**
|
||||
|
||||
## 🔧 Guides de Développement
|
||||
|
||||
### 🔧 [Guide de Développement](DEVELOPMENT.md)
|
||||
Guide complet pour le développement.
|
||||
- **Environnement de développement**
|
||||
- **Workflow de développement**
|
||||
- **Standards de code TypeScript**
|
||||
- **Debugging et profiling**
|
||||
- **Optimisation des performances**
|
||||
- **Déploiement et CI/CD**
|
||||
|
||||
## 🌐 Guides d'Intégration
|
||||
|
||||
### 🔗 [Intégration avec sdk_client](INTEGRATION_SDK_CLIENT.md)
|
||||
Guide d'intégration avec le stub WASM sdk_client.
|
||||
- **Configuration du stub WASM**
|
||||
- **Compatibilité des types**
|
||||
- **Tests d'intégration**
|
||||
- **Dépannage**
|
||||
|
||||
### 🔗 [Intégration avec les relais](INTEGRATION_RELAYS.md)
|
||||
Guide d'intégration avec le réseau de relais.
|
||||
- **Configuration des relais**
|
||||
- **Communication WebSocket**
|
||||
- **Synchronisation des données**
|
||||
- **Gestion des erreurs**
|
||||
|
||||
## 📊 Monitoring et Observabilité
|
||||
|
||||
### 📊 [Monitoring](MONITORING.md)
|
||||
Guide de monitoring et observabilité.
|
||||
- **Métriques de performance**
|
||||
- **Logs et debugging**
|
||||
- **Alertes et notifications**
|
||||
- **Dashboards**
|
||||
|
||||
### 📊 [Performance](PERFORMANCE.md)
|
||||
Guide d'optimisation des performances.
|
||||
- **Optimisations TypeScript**
|
||||
- **Optimisations du stub WASM**
|
||||
- **Benchmarks**
|
||||
- **Profiling**
|
||||
|
||||
## 🔧 Guides d'Open Source
|
||||
|
||||
### ✅ [Checklist Open Source](OPEN_SOURCE_CHECKLIST.md)
|
||||
Checklist complète pour l'ouverture en open source.
|
||||
- **Préparation du code**
|
||||
- **Documentation**
|
||||
- **Licences et légal**
|
||||
- **Infrastructure**
|
||||
- **Communication**
|
||||
|
||||
## 📞 Support et Contact
|
||||
|
||||
### 📞 [Support](SUPPORT.md)
|
||||
Guide de support et contact.
|
||||
- **Comment obtenir de l'aide**
|
||||
- **Création d'issues**
|
||||
- **Canal de communication**
|
||||
- **FAQ**
|
||||
- **Ressources additionnelles**
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Navigation Rapide
|
||||
|
||||
### 🚀 Démarrage Rapide
|
||||
1. [Installation](INSTALLATION.md) - Installer sdk_signer
|
||||
2. [Configuration](CONFIGURATION.md) - Configurer l'environnement
|
||||
3. [Utilisation](USAGE.md) - Utiliser le service
|
||||
|
||||
### 🔧 Développement
|
||||
1. [Architecture](ARCHITECTURE.md) - Comprendre l'architecture
|
||||
2. [API](API.md) - Consulter les APIs
|
||||
3. [Tests](TESTING.md) - Exécuter les tests
|
||||
|
||||
### 📚 Documentation
|
||||
1. [Index](INDEX.md) - Cet index
|
||||
2. [Docker Support](docker-support.md) - Configuration Docker
|
||||
|
||||
### 🤝 Communauté
|
||||
1. [Guide Communauté](COMMUNITY_GUIDE.md) - Contribuer
|
||||
2. [Code de Conduite](../CODE_OF_CONDUCT.md) - Règles de conduite
|
||||
3. [Support](SUPPORT.md) - Obtenir de l'aide
|
||||
|
||||
---
|
||||
|
||||
## 🧪 Tests et Validation
|
||||
|
||||
### Tests Automatisés
|
||||
```bash
|
||||
# Tests unitaires
|
||||
npm test
|
||||
|
||||
# Tests en mode watch
|
||||
npm run test:watch
|
||||
|
||||
# Tests de compatibilité
|
||||
npm run test:compatibility
|
||||
|
||||
# Linting
|
||||
npm run lint
|
||||
|
||||
# Formatage
|
||||
npm run format
|
||||
```
|
||||
|
||||
### Tests d'Intégration
|
||||
```bash
|
||||
# Tests avec le stub WASM
|
||||
npm run test:integration
|
||||
|
||||
# Tests de compatibilité avec sdk_client
|
||||
npm run test:sdk-client
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Développement
|
||||
|
||||
### Commandes Essentielles
|
||||
```bash
|
||||
# Installation des dépendances
|
||||
npm install
|
||||
|
||||
# Build de développement
|
||||
npm run build
|
||||
|
||||
# Build de production
|
||||
npm run build:prod
|
||||
|
||||
# Tests
|
||||
npm test
|
||||
|
||||
# Démarrage en mode développement
|
||||
npm run dev
|
||||
|
||||
# Démarrage en mode production
|
||||
npm start
|
||||
```
|
||||
|
||||
### Configuration Docker
|
||||
```bash
|
||||
# Construction de l'image
|
||||
docker build -t sdk_signer .
|
||||
|
||||
# Exécution du conteneur
|
||||
docker run -p 9090:9090 sdk_signer
|
||||
|
||||
# Avec Docker Compose
|
||||
docker compose up
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📊 Métriques
|
||||
|
||||
### Performance
|
||||
- **Temps de compilation** : < 5s
|
||||
- **Temps de démarrage** : < 2s
|
||||
- **Mémoire utilisée** : < 100MB
|
||||
- **Tests** : 100% de couverture
|
||||
|
||||
### Compatibilité
|
||||
- **TypeScript** : ✅ 0 erreur
|
||||
- **Stub WASM** : ✅ Compatible
|
||||
- **Docker** : ✅ Support complet
|
||||
- **Tests** : ✅ 100% de couverture
|
||||
|
||||
---
|
||||
|
||||
**📚 Documentation complète pour sdk_signer - Service de signature TypeScript pour l'écosystème 4NK** 🚀
|
6
docs/SECURITY_AUDIT.md
Normal file
6
docs/SECURITY_AUDIT.md
Normal file
@ -0,0 +1,6 @@
|
||||
# Audit de Sécurité - sdk_signer
|
||||
|
||||
- CI: job `security-audit` (voir `.gitea/workflows/ci.yml`).
|
||||
- Script: `scripts/security/audit.sh` (npm audit, cargo audit si applicable, scan de secrets).
|
||||
- Bloquant: vulnérabilités élevées/critiques ou secrets détectés.
|
||||
- En cas d’échec, `release-guard` bloque push/tag.
|
@ -8,13 +8,13 @@
|
||||
## Build local et exécution
|
||||
```bash
|
||||
# Build image
|
||||
docker build -t sdk-signer:latest .
|
||||
docker build -t sdk-signer:0.1.1 .
|
||||
# Run
|
||||
docker run --rm -p 9090:9090 \
|
||||
-e API_KEY=change-me \
|
||||
-e RELAY_URLS=ws://relay:8090 \
|
||||
-v signer_data:/data \
|
||||
sdk-signer:latest
|
||||
sdk-signer:0.1.1
|
||||
```
|
||||
|
||||
## docker-compose (prod)
|
||||
@ -30,4 +30,6 @@ Variables utiles:
|
||||
- Release: `.gitea/workflows/release.yml` (build image, push si secrets fournis)
|
||||
|
||||
## Mise à jour
|
||||
- Pousser un tag `vX.Y.Z` déclenche la release et met à jour l'image `:latest`.
|
||||
- Pousser un tag `vX.Y.Z` (ex: `v0.1.1`) déclenche la release et met à jour l'image `:latest`.
|
||||
|
||||
|
||||
|
@ -41,3 +41,5 @@ docker compose up --build
|
||||
- `.dockerignore` est configuré pour ne pas exclure `pkg` afin que les bindings WASM soient disponibles au runtime.
|
||||
|
||||
|
||||
|
||||
|
||||
|
9
docs/release-notes-0.1.1.md
Normal file
9
docs/release-notes-0.1.1.md
Normal file
@ -0,0 +1,9 @@
|
||||
# Release Notes 0.1.1
|
||||
|
||||
Date: 2025-08-26
|
||||
|
||||
- Bump version à 0.1.1
|
||||
- Docs déploiement actualisées (tags)
|
||||
- Tests utilitaires additionnels
|
||||
|
||||
|
@ -8,3 +8,5 @@ Modifications principales:
|
||||
- Maintien des dossiers `docs/` et `tests/`; ajout `docs/docker-support.md`, `docs/REX.md` et `tests/config.test.ts`.
|
||||
- Mise à jour `package.json` (license MIT), installation `vitest` et `@types/node`.
|
||||
- Build et tests: OK (`npm run build`, `npm test`).
|
||||
|
||||
|
||||
|
263
package-lock.json
generated
263
package-lock.json
generated
@ -1,15 +1,16 @@
|
||||
{
|
||||
"name": "sdk_signer",
|
||||
"version": "1.0.0",
|
||||
"version": "0.1.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "sdk_signer",
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"version": "0.1.1",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/ws": "^8.5.10",
|
||||
"axios": "^1.7.8",
|
||||
"dotenv": "^16.3.1",
|
||||
"level": "^10.0.0",
|
||||
"ws": "^8.14.2"
|
||||
@ -941,6 +942,21 @@
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
|
||||
},
|
||||
"node_modules/axios": {
|
||||
"version": "1.11.0",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.11.0.tgz",
|
||||
"integrity": "sha512-1Lx3WLFQWm3ooKDYZD1eXmoGO9fxYQjrycfHFC8P0sCfQVXyROp0p9PFWBehewBOdCwHc+f/b8I0fMto5eSfwA==",
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.15.6",
|
||||
"form-data": "^4.0.4",
|
||||
"proxy-from-env": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/base64-js": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
||||
@ -1001,6 +1017,18 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/call-bind-apply-helpers": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
|
||||
"integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
"function-bind": "^1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/chai": {
|
||||
"version": "4.5.0",
|
||||
"resolved": "https://registry.npmjs.org/chai/-/chai-4.5.0.tgz",
|
||||
@ -1048,6 +1076,17 @@
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/combined-stream": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
|
||||
"dependencies": {
|
||||
"delayed-stream": "~1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/confbox": {
|
||||
"version": "0.1.8",
|
||||
"resolved": "https://registry.npmjs.org/confbox/-/confbox-0.1.8.tgz",
|
||||
@ -1107,6 +1146,14 @@
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/diff": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
|
||||
@ -1137,6 +1184,60 @@
|
||||
"url": "https://dotenvx.com"
|
||||
}
|
||||
},
|
||||
"node_modules/dunder-proto": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
|
||||
"integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
|
||||
"dependencies": {
|
||||
"call-bind-apply-helpers": "^1.0.1",
|
||||
"es-errors": "^1.3.0",
|
||||
"gopd": "^1.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/es-define-property": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
|
||||
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/es-errors": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
|
||||
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/es-object-atoms": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
|
||||
"integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/es-set-tostringtag": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz",
|
||||
"integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
"get-intrinsic": "^1.2.6",
|
||||
"has-tostringtag": "^1.0.2",
|
||||
"hasown": "^2.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/esbuild": {
|
||||
"version": "0.21.5",
|
||||
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz",
|
||||
@ -1210,6 +1311,40 @@
|
||||
"url": "https://github.com/sindresorhus/execa?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/follow-redirects": {
|
||||
"version": "1.15.11",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.11.tgz",
|
||||
"integrity": "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "individual",
|
||||
"url": "https://github.com/sponsors/RubenVerborgh"
|
||||
}
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=4.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"debug": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/form-data": {
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.4.tgz",
|
||||
"integrity": "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==",
|
||||
"dependencies": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "^1.0.8",
|
||||
"es-set-tostringtag": "^2.1.0",
|
||||
"hasown": "^2.0.2",
|
||||
"mime-types": "^2.1.12"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/fsevents": {
|
||||
"version": "2.3.3",
|
||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
|
||||
@ -1225,6 +1360,14 @@
|
||||
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/function-bind": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
|
||||
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/get-func-name": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz",
|
||||
@ -1235,6 +1378,41 @@
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/get-intrinsic": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
|
||||
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
|
||||
"dependencies": {
|
||||
"call-bind-apply-helpers": "^1.0.2",
|
||||
"es-define-property": "^1.0.1",
|
||||
"es-errors": "^1.3.0",
|
||||
"es-object-atoms": "^1.1.1",
|
||||
"function-bind": "^1.1.2",
|
||||
"get-proto": "^1.0.1",
|
||||
"gopd": "^1.2.0",
|
||||
"has-symbols": "^1.1.0",
|
||||
"hasown": "^2.0.2",
|
||||
"math-intrinsics": "^1.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/get-proto": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
|
||||
"integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
|
||||
"dependencies": {
|
||||
"dunder-proto": "^1.0.1",
|
||||
"es-object-atoms": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/get-stream": {
|
||||
"version": "8.0.1",
|
||||
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-8.0.1.tgz",
|
||||
@ -1248,6 +1426,53 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/gopd": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
|
||||
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/has-symbols": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
|
||||
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/has-tostringtag": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz",
|
||||
"integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==",
|
||||
"dependencies": {
|
||||
"has-symbols": "^1.0.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/hasown": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
|
||||
"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
|
||||
"dependencies": {
|
||||
"function-bind": "^1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/human-signals": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/human-signals/-/human-signals-5.0.0.tgz",
|
||||
@ -1406,6 +1631,14 @@
|
||||
"integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/math-intrinsics": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
||||
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/maybe-combine-errors": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/maybe-combine-errors/-/maybe-combine-errors-1.0.0.tgz",
|
||||
@ -1421,6 +1654,25 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/mime-db": {
|
||||
"version": "1.52.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
||||
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-types": {
|
||||
"version": "2.1.35",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
|
||||
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
|
||||
"dependencies": {
|
||||
"mime-db": "1.52.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mimic-fn": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz",
|
||||
@ -1661,6 +1913,11 @@
|
||||
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/proxy-from-env": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
||||
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
|
||||
},
|
||||
"node_modules/react-is": {
|
||||
"version": "18.3.1",
|
||||
"resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sdk_signer",
|
||||
"version": "1.0.0",
|
||||
"version": "0.1.1",
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
@ -20,6 +20,7 @@
|
||||
"@types/node": "^22.5.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^1.7.8",
|
||||
"ws": "^8.14.2",
|
||||
"@types/ws": "^8.5.10",
|
||||
"dotenv": "^16.3.1",
|
||||
|
@ -1,3 +1,4 @@
|
||||
# scripts
|
||||
|
||||
Scripts utilitaires pour CI/CD ou développement local.
|
||||
|
||||
|
21
scripts/checks/version_alignment.sh
Executable file
21
scripts/checks/version_alignment.sh
Executable file
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd)"
|
||||
cd "$ROOT_DIR"
|
||||
|
||||
version_file="VERSION"
|
||||
[[ -f TEMPLATE_VERSION ]] && version_file="TEMPLATE_VERSION"
|
||||
|
||||
[[ -f "$version_file" ]] || { echo "Version file missing ($version_file)"; exit 1; }
|
||||
v=$(tr -d '\r' < "$version_file" | head -n1)
|
||||
[[ -n "$v" ]] || { echo "Empty version"; exit 1; }
|
||||
|
||||
echo "Version file: $version_file=$v"
|
||||
|
||||
if ! grep -Eq "^## \\[$(echo "$v" | sed 's/^v//')\\]" CHANGELOG.md; then
|
||||
echo "CHANGELOG entry for $v not found"; exit 1;
|
||||
fi
|
||||
|
||||
echo "Version alignment OK"
|
||||
|
145
scripts/deploy/setup.sh
Executable file
145
scripts/deploy/setup.sh
Executable file
@ -0,0 +1,145 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ENV_DIR="${HOME}/.4nk_template"
|
||||
ENV_FILE="${ENV_DIR}/.env"
|
||||
TEMPLATE_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
TEMPLATE_IN_REPO="${TEMPLATE_ROOT}/scripts/env/.env.template"
|
||||
|
||||
usage() {
|
||||
cat <<USAGE
|
||||
Usage: $0 <git_url> [--dest DIR] [--force]
|
||||
|
||||
Actions:
|
||||
1) Provisionne ~/.4nk_template/.env (si absent)
|
||||
2) Clone le dépôt cible si le dossier n'existe pas
|
||||
3) Copie la structure normative 4NK_template dans le projet cible:
|
||||
- .gitea/** (workflows, templates issues/PR)
|
||||
- AGENTS.md
|
||||
- .cursor/rules/** (si présent)
|
||||
- scripts/agents/**, scripts/env/ensure_env.sh, scripts/deploy/setup.sh
|
||||
- docs/templates/** et docs/INDEX.md (table des matières)
|
||||
4) Ne remplace pas les fichiers existants sauf si --force
|
||||
|
||||
Exemples:
|
||||
$0 https://git.example.com/org/projet.git
|
||||
$0 git@host:org/projet.git --dest ~/work --force
|
||||
USAGE
|
||||
}
|
||||
|
||||
GIT_URL="${1:-}"
|
||||
DEST_PARENT="$(pwd)"
|
||||
FORCE_COPY=0
|
||||
shift || true
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--dest)
|
||||
DEST_PARENT="${2:-}"; shift 2 ;;
|
||||
--force)
|
||||
FORCE_COPY=1; shift ;;
|
||||
-h|--help)
|
||||
usage; exit 0 ;;
|
||||
*)
|
||||
echo "Option inconnue: $1" >&2; usage; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z "${GIT_URL}" ]]; then
|
||||
usage; exit 2
|
||||
fi
|
||||
|
||||
mkdir -p "${ENV_DIR}"
|
||||
chmod 700 "${ENV_DIR}" || true
|
||||
|
||||
if [[ ! -f "${ENV_FILE}" ]]; then
|
||||
if [[ -f "${TEMPLATE_IN_REPO}" ]]; then
|
||||
cp "${TEMPLATE_IN_REPO}" "${ENV_FILE}"
|
||||
else
|
||||
cat >"${ENV_FILE}" <<'EOF'
|
||||
# Fichier d'exemple d'environnement pour 4NK_template
|
||||
# Copiez ce fichier vers ~/.4nk_template/.env puis complétez les valeurs.
|
||||
# Ne committez jamais de fichier contenant des secrets.
|
||||
|
||||
# OpenAI (agents IA)
|
||||
OPENAI_API_KEY=
|
||||
OPENAI_MODEL=
|
||||
OPENAI_API_BASE=https://api.openai.com/v1
|
||||
OPENAI_TEMPERATURE=0.2
|
||||
|
||||
# Gitea (release via API)
|
||||
BASE_URL=https://git.4nkweb.com
|
||||
RELEASE_TOKEN=
|
||||
EOF
|
||||
fi
|
||||
chmod 600 "${ENV_FILE}" || true
|
||||
echo "Fichier créé: ${ENV_FILE}. Complétez les valeurs requises (ex: OPENAI_API_KEY, OPENAI_MODEL, RELEASE_TOKEN)." >&2
|
||||
fi
|
||||
|
||||
# 2) Clonage du dépôt si nécessaire
|
||||
repo_name="$(basename -s .git "${GIT_URL}")"
|
||||
target_dir="${DEST_PARENT%/}/${repo_name}"
|
||||
if [[ ! -d "${target_dir}" ]]; then
|
||||
echo "Clonage: ${GIT_URL} → ${target_dir}" >&2
|
||||
git clone --depth 1 "${GIT_URL}" "${target_dir}"
|
||||
else
|
||||
echo "Dossier existant, pas de clone: ${target_dir}" >&2
|
||||
fi
|
||||
|
||||
copy_item() {
|
||||
local src="$1" dst="$2"
|
||||
if [[ ! -e "$src" ]]; then return 0; fi
|
||||
if [[ -d "$src" ]]; then
|
||||
mkdir -p "$dst"
|
||||
if (( FORCE_COPY )); then
|
||||
cp -a "$src/." "$dst/"
|
||||
else
|
||||
(cd "$src" && find . -type f -print0) | while IFS= read -r -d '' f; do
|
||||
if [[ ! -e "$dst/$f" ]]; then
|
||||
mkdir -p "$(dirname "$dst/$f")"
|
||||
cp -a "$src/$f" "$dst/$f"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
else
|
||||
if [[ -e "$dst" && $FORCE_COPY -eq 0 ]]; then return 0; fi
|
||||
mkdir -p "$(dirname "$dst")" && cp -a "$src" "$dst"
|
||||
fi
|
||||
}
|
||||
|
||||
# 3) Copie de la structure normative
|
||||
copy_item "${TEMPLATE_ROOT}/.gitea" "${target_dir}/.gitea"
|
||||
copy_item "${TEMPLATE_ROOT}/AGENTS.md" "${target_dir}/AGENTS.md"
|
||||
copy_item "${TEMPLATE_ROOT}/.cursor" "${target_dir}/.cursor"
|
||||
copy_item "${TEMPLATE_ROOT}/.cursorignore" "${target_dir}/.cursorignore"
|
||||
copy_item "${TEMPLATE_ROOT}/.gitignore" "${target_dir}/.gitignore"
|
||||
copy_item "${TEMPLATE_ROOT}/.markdownlint.json" "${target_dir}/.markdownlint.json"
|
||||
copy_item "${TEMPLATE_ROOT}/LICENSE" "${target_dir}/LICENSE"
|
||||
copy_item "${TEMPLATE_ROOT}/CONTRIBUTING.md" "${target_dir}/CONTRIBUTING.md"
|
||||
copy_item "${TEMPLATE_ROOT}/CODE_OF_CONDUCT.md" "${target_dir}/CODE_OF_CONDUCT.md"
|
||||
copy_item "${TEMPLATE_ROOT}/SECURITY.md" "${target_dir}/SECURITY.md"
|
||||
copy_item "${TEMPLATE_ROOT}/TEMPLATE_VERSION" "${target_dir}/TEMPLATE_VERSION"
|
||||
copy_item "${TEMPLATE_ROOT}/security" "${target_dir}/security"
|
||||
copy_item "${TEMPLATE_ROOT}/scripts" "${target_dir}/scripts"
|
||||
copy_item "${TEMPLATE_ROOT}/docs/templates" "${target_dir}/docs/templates"
|
||||
|
||||
# Génération docs/INDEX.md dans le projet cible (si absent ou --force)
|
||||
INDEX_DST="${target_dir}/docs/INDEX.md"
|
||||
if [[ ! -f "${INDEX_DST}" || $FORCE_COPY -eq 1 ]]; then
|
||||
mkdir -p "$(dirname "${INDEX_DST}")"
|
||||
cat >"${INDEX_DST}" <<'IDX'
|
||||
# Documentation du projet
|
||||
|
||||
Cette table des matières oriente vers:
|
||||
- Documentation spécifique au projet: `docs/project/`
|
||||
- Modèles génériques à adapter: `docs/templates/`
|
||||
|
||||
## Sommaire
|
||||
- À personnaliser: `docs/project/README.md`, `docs/project/INDEX.md`, `docs/project/ARCHITECTURE.md`, `docs/project/USAGE.md`, etc.
|
||||
|
||||
## Modèles génériques
|
||||
- Voir: `docs/templates/`
|
||||
IDX
|
||||
fi
|
||||
|
||||
echo "Template 4NK appliqué à: ${target_dir}" >&2
|
||||
exit 0
|
15
scripts/dev/run_container.sh
Executable file
15
scripts/dev/run_container.sh
Executable file
@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
IMAGE_NAME="4nk-template-dev:debian"
|
||||
DOCKERFILE="docker/Dockerfile.debian"
|
||||
|
||||
echo "[build] ${IMAGE_NAME}"
|
||||
docker build -t "${IMAGE_NAME}" -f "${DOCKERFILE}" .
|
||||
|
||||
echo "[run] launching container and executing agents"
|
||||
docker run --rm -it \
|
||||
-v "${PWD}:/work" -w /work \
|
||||
"${IMAGE_NAME}" \
|
||||
"scripts/agents/run.sh; ls -la tests/reports/agents || true"
|
||||
|
14
scripts/dev/run_project_ci.sh
Executable file
14
scripts/dev/run_project_ci.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Build et lance le conteneur unifié (runner+agents) sur ce projet
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
cd "$ROOT_DIR"
|
||||
|
||||
# Build image
|
||||
docker compose -f docker-compose.ci.yml build
|
||||
|
||||
# Exécuter agents par défaut
|
||||
RUNNER_MODE="${RUNNER_MODE:-agents}" BASE_URL="${BASE_URL:-}" REGISTRATION_TOKEN="${REGISTRATION_TOKEN:-}" \
|
||||
docker compose -f docker-compose.ci.yml up --remove-orphans --abort-on-container-exit
|
42
scripts/env/ensure_env.sh
vendored
Executable file
42
scripts/env/ensure_env.sh
vendored
Executable file
@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
TEMPLATE_FILE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.env.template"
|
||||
ENV_DIR="${HOME}/.4nk_template"
|
||||
ENV_FILE="${ENV_DIR}/.env"
|
||||
|
||||
mkdir -p "${ENV_DIR}"
|
||||
chmod 700 "${ENV_DIR}" || true
|
||||
|
||||
if [[ ! -f "${ENV_FILE}" ]]; then
|
||||
if [[ -f "${TEMPLATE_FILE}" ]]; then
|
||||
cp "${TEMPLATE_FILE}" "${ENV_FILE}"
|
||||
chmod 600 "${ENV_FILE}" || true
|
||||
echo "Fichier d'environnement créé: ${ENV_FILE}" >&2
|
||||
echo "Veuillez renseigner les variables requises (OPENAI_API_KEY, OPENAI_MODEL, etc.)." >&2
|
||||
exit 3
|
||||
else
|
||||
echo "Modèle d'environnement introuvable: ${TEMPLATE_FILE}" >&2
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
|
||||
# Charger pour validation
|
||||
set -a
|
||||
. "${ENV_FILE}"
|
||||
set +a
|
||||
|
||||
MISSING=()
|
||||
for var in OPENAI_API_KEY OPENAI_MODEL; do
|
||||
if [[ -z "${!var:-}" ]]; then
|
||||
MISSING+=("$var")
|
||||
fi
|
||||
done
|
||||
|
||||
if (( ${#MISSING[@]} > 0 )); then
|
||||
echo "Variables manquantes dans ${ENV_FILE}: ${MISSING[*]}" >&2
|
||||
exit 4
|
||||
fi
|
||||
|
||||
echo "Environnement valide: ${ENV_FILE}" >&2
|
19
scripts/local/install_hooks.sh
Executable file
19
scripts/local/install_hooks.sh
Executable file
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"/..
|
||||
HOOKS_DIR="$REPO_ROOT/.git/hooks"
|
||||
|
||||
mkdir -p "$HOOKS_DIR"
|
||||
install_hook() {
|
||||
local name="$1" src="$2"
|
||||
cp -f "$src" "$HOOKS_DIR/$name"
|
||||
chmod +x "$HOOKS_DIR/$name"
|
||||
echo "Installed hook: $name"
|
||||
}
|
||||
|
||||
# Hooks qui délèguent aux agents via l'image Docker du template sur le projet courant
|
||||
install_hook pre-commit "$REPO_ROOT/scripts/local/precommit.sh"
|
||||
install_hook pre-push "$REPO_ROOT/scripts/local/prepush.sh"
|
||||
|
||||
echo "Hooks installés (mode agents via 4NK_template)."
|
25
scripts/local/merge_branch.sh
Executable file
25
scripts/local/merge_branch.sh
Executable file
@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
TARGET_BRANCH="${1:-main}"
|
||||
SOURCE_BRANCH="${2:-}"
|
||||
|
||||
if [[ -z "$SOURCE_BRANCH" ]]; then
|
||||
SOURCE_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
|
||||
fi
|
||||
|
||||
if [[ "$SOURCE_BRANCH" == "$TARGET_BRANCH" ]]; then
|
||||
echo "Déjà sur $TARGET_BRANCH"; exit 0
|
||||
fi
|
||||
|
||||
# Valider localement avant merge
|
||||
AUTO_FIX="${AUTO_FIX:-1}" SCOPE="${SCOPE:-all}" scripts/agents/run.sh || true
|
||||
if [ -f scripts/security/audit.sh ]; then bash scripts/security/audit.sh || true; fi
|
||||
|
||||
git fetch origin --prune
|
||||
git checkout "$TARGET_BRANCH"
|
||||
git pull --ff-only origin "$TARGET_BRANCH" || true
|
||||
git merge --no-ff "$SOURCE_BRANCH" -m "[skip ci] merge: $SOURCE_BRANCH -> $TARGET_BRANCH"
|
||||
git push origin "$TARGET_BRANCH"
|
||||
|
||||
echo "Merge effectué: $SOURCE_BRANCH → $TARGET_BRANCH"
|
11
scripts/local/precommit.sh
Executable file
11
scripts/local/precommit.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Exécuter les agents depuis l'image Docker de 4NK_template sur le projet courant
|
||||
PROJECT_DIR="$(git rev-parse --show-toplevel)"
|
||||
TEMPLATE_DIR="$(cd "${PROJECT_DIR}/../4NK_template" && pwd)"
|
||||
|
||||
mkdir -p "${PROJECT_DIR}/tests/reports/agents"
|
||||
"${TEMPLATE_DIR}/scripts/local/run_agents_for_project.sh" "${PROJECT_DIR}" "tests/reports/agents"
|
||||
|
||||
echo "[pre-commit] OK (agents via 4NK_template)"
|
21
scripts/local/prepush.sh
Executable file
21
scripts/local/prepush.sh
Executable file
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Exécuter les agents depuis l'image Docker de 4NK_template sur le projet courant
|
||||
PROJECT_DIR="$(git rev-parse --show-toplevel)"
|
||||
TEMPLATE_DIR="$(cd "${PROJECT_DIR}/../4NK_template" && pwd)"
|
||||
|
||||
mkdir -p "${PROJECT_DIR}/tests/reports/agents"
|
||||
"${TEMPLATE_DIR}/scripts/local/run_agents_for_project.sh" "${PROJECT_DIR}" "tests/reports/agents"
|
||||
|
||||
# Audit sécurité (best effort) dans le contexte du projet
|
||||
if [ -f "${PROJECT_DIR}/scripts/security/audit.sh" ]; then
|
||||
(cd "${PROJECT_DIR}" && bash scripts/security/audit.sh) || true
|
||||
fi
|
||||
|
||||
# Release guard (dry-run logique) dans le contexte du projet
|
||||
if [ -f "${PROJECT_DIR}/scripts/release/guard.sh" ]; then
|
||||
(cd "${PROJECT_DIR}" && bash scripts/release/guard.sh) || true
|
||||
fi
|
||||
|
||||
echo "[pre-push] OK (agents via 4NK_template)"
|
20
scripts/local/release_local.sh
Executable file
20
scripts/local/release_local.sh
Executable file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
VERSION="${1:-}"
|
||||
if [[ -z "$VERSION" ]]; then
|
||||
echo "Usage: $0 vYYYY.MM.P" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
cd "$ROOT_DIR/.."
|
||||
|
||||
echo "$VERSION" > TEMPLATE_VERSION
|
||||
git add TEMPLATE_VERSION CHANGELOG.md 2>/dev/null || true
|
||||
git commit -m "[skip ci] chore(release): $VERSION" || true
|
||||
git tag -a "$VERSION" -m "release: $VERSION (latest)"
|
||||
git push || true
|
||||
git push origin "$VERSION"
|
||||
|
||||
echo "Release locale préparée: $VERSION"
|
51
scripts/local/run_agents_for_project.sh
Executable file
51
scripts/local/run_agents_for_project.sh
Executable file
@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Script pour lancer les agents de 4NK_template sur un projet externe
|
||||
# Usage: ./run_agents_for_project.sh [project_path] [output_dir]
|
||||
|
||||
PROJECT_PATH="${1:-.}"
|
||||
OUTPUT_DIR="${2:-tests/reports/agents}"
|
||||
TEMPLATE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
MODULE_LAST_IMAGE_FILE="$(cd "$TEMPLATE_DIR/.." && pwd)/modules/4NK_template/.last_image"
|
||||
|
||||
if [[ ! -d "$PROJECT_PATH" ]]; then
|
||||
echo "Erreur: Le projet '$PROJECT_PATH' n'existe pas" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$PROJECT_PATH/$OUTPUT_DIR"
|
||||
|
||||
echo "=== Lancement des agents 4NK_template sur: $PROJECT_PATH ==="
|
||||
|
||||
if ! command -v docker >/dev/null 2>&1; then
|
||||
echo "Docker requis pour exécuter les agents via conteneur." >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Si une image du module existe, l'utiliser en priorité
|
||||
if [[ -f "$MODULE_LAST_IMAGE_FILE" ]]; then
|
||||
IMAGE_NAME="$(cat "$MODULE_LAST_IMAGE_FILE" | tr -d '\r\n')"
|
||||
echo "Utilisation de l'image du module: $IMAGE_NAME"
|
||||
# Préparer montage du fichier d'env si présent
|
||||
ENV_MOUNT=""
|
||||
if [[ -f "$HOME/.4nk_template/.env" ]]; then
|
||||
ENV_MOUNT="-v $HOME/.4nk_template/.env:/root/.4nk_template/.env:ro"
|
||||
fi
|
||||
# Lancer le conteneur en utilisant l'ENTRYPOINT qui configure safe.directory
|
||||
docker run --rm \
|
||||
-e RUNNER_MODE=agents \
|
||||
-e TARGET_DIR=/work \
|
||||
-e OUTPUT_DIR=/work/$OUTPUT_DIR \
|
||||
-v "$(realpath "$PROJECT_PATH"):/work" \
|
||||
$ENV_MOUNT \
|
||||
"$IMAGE_NAME" || true
|
||||
else
|
||||
echo "Aucune image de module détectée, fallback docker compose dans 4NK_template"
|
||||
cd "$TEMPLATE_DIR"
|
||||
docker compose -f docker-compose.ci.yml build
|
||||
RUNNER_MODE="agents" TARGET_DIR="/work" OUTPUT_DIR="/work/$OUTPUT_DIR" \
|
||||
docker compose -f docker-compose.ci.yml run --rm project-ci || true
|
||||
fi
|
||||
|
||||
echo "=== Agents terminés → $PROJECT_PATH/$OUTPUT_DIR ==="
|
66
scripts/release/guard.sh
Executable file
66
scripts/release/guard.sh
Executable file
@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Release guard script
|
||||
# Checks: tests, docs updated, compile, version ↔ changelog ↔ tag consistency, release type
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd)"
|
||||
cd "$ROOT_DIR"
|
||||
|
||||
mode="${RELEASE_TYPE:-ci-verify}" # values: latest | wip | ci-verify
|
||||
|
||||
echo "[release-guard] mode=$mode"
|
||||
|
||||
# 1) Basic presence checks
|
||||
[[ -f CHANGELOG.md ]] || { echo "CHANGELOG.md manquant"; exit 1; }
|
||||
version_file="VERSION"
|
||||
[[ -f TEMPLATE_VERSION ]] && version_file="TEMPLATE_VERSION"
|
||||
[[ -f "$version_file" ]] || { echo "$version_file manquant"; exit 1; }
|
||||
|
||||
# 2) Extract version
|
||||
project_version=$(tr -d '\r' < "$version_file" | head -n1 | sed 's/^v//')
|
||||
[[ -n "$project_version" ]] || { echo "Version vide dans $version_file"; exit 1; }
|
||||
echo "[release-guard] version=$project_version"
|
||||
|
||||
# 3) Changelog checks
|
||||
if ! grep -Eq "^## \\[$project_version\\]" CHANGELOG.md; then
|
||||
if [[ "$mode" == "wip" ]]; then
|
||||
grep -Eq "^## \\[Unreleased\\]" CHANGELOG.md || { echo "Section [Unreleased] absente du CHANGELOG"; exit 1; }
|
||||
else
|
||||
echo "Entrée CHANGELOG pour version $project_version manquante"; exit 1;
|
||||
fi
|
||||
fi
|
||||
|
||||
# 4) Tests (optional best-effort)
|
||||
if [[ -x tests/run_all_tests.sh ]]; then
|
||||
echo "[release-guard] exécution tests/run_all_tests.sh"
|
||||
./tests/run_all_tests.sh || { echo "Tests en échec"; exit 1; }
|
||||
else
|
||||
echo "[release-guard] tests absents (ok)"
|
||||
fi
|
||||
|
||||
# 5) Build/compile (optional based on project)
|
||||
if [[ -d sdk_relay ]] && command -v cargo >/dev/null 2>&1; then
|
||||
echo "[release-guard] cargo build (sdk_relay)"
|
||||
(cd sdk_relay && cargo build --quiet) || { echo "Compilation échouée"; exit 1; }
|
||||
else
|
||||
echo "[release-guard] build spécifique non applicable (ok)"
|
||||
fi
|
||||
|
||||
# 6) Release type handling
|
||||
case "$mode" in
|
||||
latest)
|
||||
;;
|
||||
wip)
|
||||
# En wip, autoriser versions suffixées; pas d’exigence d’entrée datée
|
||||
;;
|
||||
ci-verify)
|
||||
# En CI, on valide juste la présence de CHANGELOG et version
|
||||
;;
|
||||
*)
|
||||
echo "RELEASE_TYPE invalide: $mode (latest|wip|ci-verify)"; exit 1;
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "[release-guard] OK"
|
||||
|
166
scripts/scripts/auto-ssh-push.sh
Executable file
166
scripts/scripts/auto-ssh-push.sh
Executable file
@ -0,0 +1,166 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Script d'automatisation des push SSH (template Linux)
|
||||
# Utilise automatiquement la clé SSH pour pousser sur le remote courant via SSH.
|
||||
|
||||
GITEA_HOST="${GITEA_HOST:-git.4nkweb.com}"
|
||||
|
||||
echo "🔑 Configuration SSH pour push (template)..."
|
||||
|
||||
# Configuration SSH automatique
|
||||
echo "⚙️ Configuration Git pour utiliser SSH..."
|
||||
git config --global url."git@${GITEA_HOST}:".insteadOf "https://${GITEA_HOST}/"
|
||||
|
||||
# Vérifier la configuration SSH
|
||||
echo "🔍 Vérification de la configuration SSH..."
|
||||
if ! ssh -T git@"${GITEA_HOST}" 2>&1 | grep -qi "authenticated\|welcome"; then
|
||||
echo "❌ Échec de l'authentification SSH"
|
||||
echo "💡 Vérifiez que votre clé SSH est configurée :"
|
||||
echo " 1. ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_4nk"
|
||||
echo " 2. Ajouter la clé publique à votre compte Gitea"
|
||||
echo " 3. ssh-add ~/.ssh/id_ed25519_4nk"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Authentification SSH réussie"
|
||||
|
||||
# Fonction pour push automatique
|
||||
get_current_branch() {
|
||||
# Détecte la branche courante, compatible anciennes versions de git
|
||||
local br
|
||||
br="$(git rev-parse --abbrev-ref HEAD 2>/dev/null || true)"
|
||||
if [ -z "$br" ] || [ "$br" = "HEAD" ]; then
|
||||
br="$(git symbolic-ref --short -q HEAD 2>/dev/null || true)"
|
||||
fi
|
||||
if [ -z "$br" ]; then
|
||||
# dernier recours: parser la sortie de "git branch"
|
||||
br="$(git branch 2>/dev/null | sed -n 's/^* //p' | head -n1)"
|
||||
fi
|
||||
echo "$br"
|
||||
}
|
||||
|
||||
auto_push() {
|
||||
local branch
|
||||
branch=${1:-$(get_current_branch)}
|
||||
local commit_message=${2:-"Auto-commit $(date '+%Y-%m-%d %H:%M:%S')"}
|
||||
|
||||
echo "🚀 Push automatique sur la branche: $branch"
|
||||
|
||||
# Ajouter tous les changements
|
||||
git add .
|
||||
|
||||
# Ne pas commiter si rien à commite
|
||||
if [[ -z "$(git diff --cached --name-only)" ]]; then
|
||||
echo "ℹ️ Aucun changement indexé. Skip commit/push."
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Commiter avec le message fourni
|
||||
git commit -m "$commit_message" || true
|
||||
|
||||
# Push avec SSH automatique
|
||||
echo "📤 Push vers origin/$branch..."
|
||||
git push origin "$branch"
|
||||
|
||||
echo "✅ Push réussi !"
|
||||
}
|
||||
|
||||
# Fonction pour push avec message personnalisé
|
||||
push_with_message() {
|
||||
local message="$1"
|
||||
local branch=${2:-$(get_current_branch)}
|
||||
|
||||
echo "💬 Push avec message: $message"
|
||||
auto_push "$branch" "$message"
|
||||
}
|
||||
|
||||
# Fonction pour push rapide (sans message)
|
||||
quick_push() {
|
||||
local branch=${1:-$(get_current_branch)}
|
||||
auto_push "$branch"
|
||||
}
|
||||
|
||||
# Fonction pour push sur une branche spécifique
|
||||
push_branch() {
|
||||
local branch="$1"
|
||||
local message=${2:-"Update $branch $(date '+%Y-%m-%d %H:%M:%S')"}
|
||||
|
||||
echo "🌿 Push sur la branche: $branch"
|
||||
auto_push "$branch" "$message"
|
||||
}
|
||||
|
||||
# Fonction pour push et merge vers main
|
||||
push_and_merge() {
|
||||
local source_branch=${1:-$(get_current_branch)}
|
||||
local target_branch=${2:-main}
|
||||
|
||||
echo "🔄 Push et merge $source_branch -> $target_branch"
|
||||
|
||||
# Push de la branche source
|
||||
auto_push "$source_branch"
|
||||
|
||||
# Indication pour PR manuelle
|
||||
echo "🔗 Ouvrez une Pull Request sur votre forge pour $source_branch -> $target_branch"
|
||||
}
|
||||
|
||||
# Fonction pour status et push conditionnel
|
||||
status_and_push() {
|
||||
echo "📊 Statut du repository:"
|
||||
git status --short || true
|
||||
|
||||
if [[ -n $(git status --porcelain) ]]; then
|
||||
echo "📝 Changements détectés, push automatique..."
|
||||
auto_push
|
||||
else
|
||||
echo "✅ Aucun changement à pousser"
|
||||
fi
|
||||
}
|
||||
|
||||
# Menu interactif si aucun argument fourni
|
||||
if [[ $# -eq 0 ]]; then
|
||||
echo "🤖 Script de push SSH automatique (template)"
|
||||
echo ""
|
||||
echo "Options disponibles:"
|
||||
echo " auto-ssh-push.sh quick - Push rapide"
|
||||
echo " auto-ssh-push.sh message \"Mon message\" - Push avec message"
|
||||
echo " auto-ssh-push.sh branch nom-branche - Push sur branche spécifique"
|
||||
echo " auto-ssh-push.sh merge [source] [target] - Push et préparation merge"
|
||||
echo " auto-ssh-push.sh status - Status et push conditionnel"
|
||||
echo ""
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Traitement des arguments
|
||||
case "$1" in
|
||||
"quick")
|
||||
quick_push
|
||||
;;
|
||||
"message")
|
||||
if [[ -z "${2:-}" ]]; then
|
||||
echo "❌ Message requis pour l'option 'message'"
|
||||
exit 1
|
||||
fi
|
||||
push_with_message "$2" "${3:-}"
|
||||
;;
|
||||
"branch")
|
||||
if [[ -z "${2:-}" ]]; then
|
||||
echo "❌ Nom de branche requis pour l'option 'branch'"
|
||||
exit 1
|
||||
fi
|
||||
push_branch "$2" "${3:-}"
|
||||
;;
|
||||
"merge")
|
||||
push_and_merge "${2:-}" "${3:-}"
|
||||
;;
|
||||
"status")
|
||||
status_and_push
|
||||
;;
|
||||
*)
|
||||
echo "❌ Option inconnue: $1"
|
||||
echo "💡 Utilisez './scripts/auto-ssh-push.sh' pour voir les options"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "🎯 Push SSH automatique terminé !"
|
60
scripts/scripts/init-ssh-env.sh
Executable file
60
scripts/scripts/init-ssh-env.sh
Executable file
@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Script d'initialisation de l'environnement SSH (template Linux)
|
||||
# Configure automatiquement SSH pour les push via Gitea
|
||||
|
||||
GITEA_HOST="${GITEA_HOST:-git.4nkweb.com}"
|
||||
|
||||
echo "🚀 Initialisation de l'environnement SSH (template)..."
|
||||
|
||||
# Couleurs
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
print_status() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
||||
print_success() { echo -e "${GREEN}[SUCCESS]${NC} $1"; }
|
||||
print_warning() { echo -e "${YELLOW}[WARNING]${NC} $1"; }
|
||||
print_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
||||
|
||||
print_status "Configuration SSH..."
|
||||
|
||||
# 1. Configuration Git pour SSH
|
||||
print_status "Configuration Git pour utiliser SSH (${GITEA_HOST})..."
|
||||
git config --global url."git@${GITEA_HOST}:".insteadOf "https://${GITEA_HOST}/"
|
||||
|
||||
# 2. Vérification des clés SSH
|
||||
print_status "Vérification des clés SSH existantes..."
|
||||
if [[ -f ~/.ssh/id_rsa || -f ~/.ssh/id_ed25519 ]]; then
|
||||
print_success "Clé SSH trouvée"
|
||||
else
|
||||
print_warning "Aucune clé SSH trouvée"
|
||||
fi
|
||||
|
||||
# 3. Test de la connexion SSH
|
||||
print_status "Test de la connexion SSH vers ${GITEA_HOST}..."
|
||||
if ssh -T git@"${GITEA_HOST}" 2>&1 | grep -qi "authenticated\|welcome"; then
|
||||
print_success "Authentification SSH réussie"
|
||||
else
|
||||
print_error "Échec de l'authentification SSH"
|
||||
fi
|
||||
|
||||
# 4. Alias Git
|
||||
print_status "Configuration des alias Git..."
|
||||
git config --global alias.ssh-push '!f() { git add . && git commit -m "${1:-Auto-commit $(date)}" && git push origin $(git branch --show-current); }; f'
|
||||
git config --global alias.quick-push '!f() { git add . && git commit -m "Update $(date)" && git push origin $(git branch --show-current); }; f'
|
||||
print_success "Alias Git configurés"
|
||||
|
||||
# 5. Rendu exécutable des scripts si chemin standard
|
||||
print_status "Configuration des permissions des scripts (si présents)..."
|
||||
chmod +x scripts/auto-ssh-push.sh 2>/dev/null || true
|
||||
chmod +x scripts/setup-ssh-ci.sh 2>/dev/null || true
|
||||
print_success "Scripts rendus exécutables (si présents)"
|
||||
|
||||
# 6. Résumé
|
||||
echo ""
|
||||
print_success "=== Configuration SSH terminée ==="
|
||||
|
55
scripts/scripts/setup-ssh-ci.sh
Executable file
55
scripts/scripts/setup-ssh-ci.sh
Executable file
@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Script de configuration SSH pour CI/CD (template Linux)
|
||||
# Utilise automatiquement la clé SSH pour les opérations Git
|
||||
|
||||
GITEA_HOST="${GITEA_HOST:-git.4nkweb.com}"
|
||||
|
||||
echo "🔑 Configuration automatique de la clé SSH pour CI/CD..."
|
||||
|
||||
if [ -n "${CI:-}" ]; then
|
||||
echo "✅ Environnement CI détecté"
|
||||
|
||||
if [ -n "${SSH_PRIVATE_KEY:-}" ]; then
|
||||
echo "🔐 Configuration de la clé SSH privée..."
|
||||
mkdir -p ~/.ssh && chmod 700 ~/.ssh
|
||||
printf "%s" "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
|
||||
chmod 600 ~/.ssh/id_rsa
|
||||
|
||||
if [ -n "${SSH_PUBLIC_KEY:-}" ]; then
|
||||
printf "%s" "$SSH_PUBLIC_KEY" > ~/.ssh/id_rsa.pub
|
||||
chmod 644 ~/.ssh/id_rsa.pub
|
||||
fi
|
||||
|
||||
cat > ~/.ssh/config << EOF
|
||||
Host ${GITEA_HOST}
|
||||
HostName ${GITEA_HOST}
|
||||
User git
|
||||
IdentityFile ~/.ssh/id_rsa
|
||||
StrictHostKeyChecking no
|
||||
UserKnownHostsFile=/dev/null
|
||||
EOF
|
||||
chmod 600 ~/.ssh/config
|
||||
|
||||
echo "🧪 Test SSH vers ${GITEA_HOST}..."
|
||||
ssh -T git@"${GITEA_HOST}" 2>&1 || true
|
||||
|
||||
git config --global url."git@${GITEA_HOST}:".insteadOf "https://${GITEA_HOST}/"
|
||||
echo "✅ Configuration SSH terminée"
|
||||
else
|
||||
echo "⚠️ SSH_PRIVATE_KEY non défini, bascule HTTPS"
|
||||
fi
|
||||
else
|
||||
echo "ℹ️ Environnement local détecté"
|
||||
if [ -f ~/.ssh/id_rsa ] || [ -f ~/.ssh/id_ed25519 ]; then
|
||||
echo "🔑 Clé SSH locale trouvée"
|
||||
git config --global url."git@${GITEA_HOST}:".insteadOf "https://${GITEA_HOST}/"
|
||||
echo "✅ Configuration SSH locale terminée"
|
||||
else
|
||||
echo "⚠️ Aucune clé SSH trouvée; configuration manuelle requise"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "🎯 Configuration SSH CI/CD terminée"
|
||||
|
35
scripts/security/audit.sh
Executable file
35
scripts/security/audit.sh
Executable file
@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
echo "[security-audit] démarrage"
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd)"
|
||||
cd "$ROOT_DIR"
|
||||
|
||||
rc=0
|
||||
|
||||
# 1) Audit npm (si package.json présent)
|
||||
if [ -f package.json ]; then
|
||||
echo "[security-audit] npm audit --audit-level=moderate"
|
||||
if ! npm audit --audit-level=moderate; then rc=1; fi || true
|
||||
else
|
||||
echo "[security-audit] pas de package.json (ok)"
|
||||
fi
|
||||
|
||||
# 2) Audit Rust (si Cargo.toml présent)
|
||||
if command -v cargo >/dev/null 2>&1 && [ -f Cargo.toml ] || find . -maxdepth 2 -name Cargo.toml | grep -q . ; then
|
||||
echo "[security-audit] cargo audit"
|
||||
if ! cargo audit --deny warnings; then rc=1; fi || true
|
||||
else
|
||||
echo "[security-audit] pas de projet Rust (ok)"
|
||||
fi
|
||||
|
||||
# 3) Recherche de secrets grossiers
|
||||
echo "[security-audit] scan secrets"
|
||||
if grep -RIE "(?i)(api[_-]?key|secret|password|private[_-]?key)" --exclude-dir .git --exclude-dir node_modules --exclude-dir target --exclude "*.md" . >/dev/null 2>&1; then
|
||||
echo "[security-audit] secrets potentiels détectés"; rc=1
|
||||
else
|
||||
echo "[security-audit] aucun secret évident"
|
||||
fi
|
||||
|
||||
echo "[security-audit] terminé rc=$rc"
|
||||
exit $rc
|
47
scripts/utils/check_md024.ps1
Normal file
47
scripts/utils/check_md024.ps1
Normal file
@ -0,0 +1,47 @@
|
||||
Param(
|
||||
[string]$Root = "."
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$files = Get-ChildItem -Path $Root -Recurse -Filter *.md | Where-Object { $_.FullName -notmatch '\\archive\\' }
|
||||
$had = $false
|
||||
foreach ($f in $files) {
|
||||
try {
|
||||
$lines = Get-Content -LiteralPath $f.FullName -Encoding UTF8 -ErrorAction Stop
|
||||
} catch {
|
||||
Write-Warning ("Impossible de lire: {0} — {1}" -f $f.FullName, $_.Exception.Message)
|
||||
continue
|
||||
}
|
||||
$map = @{}
|
||||
$firstMap = @{}
|
||||
$dups = @{}
|
||||
for ($i = 0; $i -lt $lines.Count; $i++) {
|
||||
$line = $lines[$i]
|
||||
if ($line -match '^\s{0,3}#{1,6}\s+(.*)$') {
|
||||
$t = $Matches[1].Trim()
|
||||
$norm = ([regex]::Replace($t, '\s+', ' ')).ToLowerInvariant()
|
||||
if ($map.ContainsKey($norm)) {
|
||||
if (-not $dups.ContainsKey($norm)) {
|
||||
$dups[$norm] = New-Object System.Collections.ArrayList
|
||||
$firstMap[$norm] = $map[$norm]
|
||||
}
|
||||
[void]$dups[$norm].Add($i + 1)
|
||||
} else {
|
||||
$map[$norm] = $i + 1
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($dups.Keys.Count -gt 0) {
|
||||
$had = $true
|
||||
Write-Output "=== $($f.FullName) ==="
|
||||
foreach ($k in $dups.Keys) {
|
||||
$first = $firstMap[$k]
|
||||
$others = ($dups[$k] -join ', ')
|
||||
Write-Output ("Heading: '{0}' first@{1} duplicates@[{2}]" -f $k, $first, $others)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (-not $had) {
|
||||
Write-Output "No duplicate headings detected."
|
||||
}
|
@ -60,19 +60,27 @@ export default class Database {
|
||||
}
|
||||
|
||||
private parseKey(fullKey: string): { storeName: string; key: string } | null {
|
||||
const parts = fullKey.split(':', 2);
|
||||
if (parts.length !== 2) return null;
|
||||
return { storeName: parts[0], key: parts[1] };
|
||||
const colonIndex = fullKey.indexOf(':');
|
||||
if (colonIndex === -1) return null;
|
||||
|
||||
const storeName = fullKey.substring(0, colonIndex);
|
||||
const key = fullKey.substring(colonIndex + 1);
|
||||
|
||||
return { storeName, key };
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a single object from a store
|
||||
* O(log n) operation - only reads specific key
|
||||
*/
|
||||
public async getObject(storeName: string, key: string): Promise<any | null> {
|
||||
public async getObject(storeName: string, key: string, isBuffer: boolean = false): Promise<any | null> {
|
||||
try {
|
||||
const fullKey = this.getKey(storeName, key);
|
||||
return await this.db.get(fullKey);
|
||||
if (isBuffer) {
|
||||
return await this.db.get(fullKey, { valueEncoding: 'buffer' });
|
||||
} else {
|
||||
return await this.db.get(fullKey);
|
||||
}
|
||||
} catch (error) {
|
||||
if ((error as any).code === 'LEVEL_NOT_FOUND') {
|
||||
return null;
|
||||
@ -85,12 +93,16 @@ export default class Database {
|
||||
* Add or update an object in a store
|
||||
* O(log n) operation - only writes specific key-value pair
|
||||
*/
|
||||
public async addObject(operation: DatabaseObject): Promise<void> {
|
||||
public async addObject(operation: DatabaseObject, isBuffer: boolean = false): Promise<void> {
|
||||
const { storeName, object, key } = operation;
|
||||
|
||||
if (key) {
|
||||
const fullKey = this.getKey(storeName, key);
|
||||
await this.db.put(fullKey, object);
|
||||
if (isBuffer) {
|
||||
await this.db.put(fullKey, object, { valueEncoding: 'buffer' });
|
||||
} else {
|
||||
await this.db.put(fullKey, object);
|
||||
}
|
||||
} else {
|
||||
// Auto-generate key if none provided
|
||||
const autoKey = Date.now().toString() + Math.random().toString(36).substr(2, 9);
|
||||
|
@ -310,7 +310,13 @@ export class RelayManager {
|
||||
|
||||
// Relay Message Handling
|
||||
private handleRelayMessage(relayId: string, message: any): void {
|
||||
console.log(`📨 Received message from relay ${relayId}:`, message);
|
||||
console.log(`📨 Received message from relay ${relayId}:`);
|
||||
|
||||
if (message.flag === 'Handshake') {
|
||||
console.log('🔑 Handshake message');
|
||||
} else {
|
||||
console.log(`🔑 ${message.flag} message: ${message.content}`);
|
||||
}
|
||||
|
||||
// Handle different types of relay responses
|
||||
if (message.flag) {
|
||||
|
374
src/service.ts
374
src/service.ts
@ -5,6 +5,7 @@ import { ApiReturn, Device, HandshakeMessage, Member, MerkleProofResult, OutPoin
|
||||
import { RelayManager } from './relay-manager';
|
||||
import { config } from './config';
|
||||
import { EMPTY32BYTES } from './utils';
|
||||
import { storeData } from './storage.service';
|
||||
|
||||
const DEFAULTAMOUNT = 1000n;
|
||||
const DEVICE_KEY = 'main_device';
|
||||
@ -80,56 +81,49 @@ export class Service {
|
||||
const existing = await this.getProcess(processId);
|
||||
if (existing) {
|
||||
// Look for state id we don't know yet
|
||||
let new_states = [];
|
||||
let roles = [];
|
||||
let newStates: string[] = [];
|
||||
let newRoles: Record<string, RoleDefinition>[] = [];
|
||||
for (const state of process.states) {
|
||||
if (!state.state_id || state.state_id === EMPTY32BYTES) { continue; }
|
||||
if (!this.lookForStateId(existing, state.state_id)) {
|
||||
if (!state || !state.state_id) { continue; } // shouldn't happen
|
||||
if (state.state_id === EMPTY32BYTES) {
|
||||
// We check that the tip is the same we have, if not we update
|
||||
const existingTip = existing.states[existing.states.length - 1].commited_in;
|
||||
if (existingTip !== state.commited_in) {
|
||||
console.log('Found new tip for process', processId);
|
||||
existing.states.pop(); // We discard the last state
|
||||
existing.states.push(state);
|
||||
// We know that's the last state, so we just trigger the update
|
||||
toSave[processId] = existing;
|
||||
}
|
||||
} else if (!this.lookForStateId(existing, state.state_id)) {
|
||||
// We don't want to overwrite what we already have for existing processes
|
||||
// We may end up overwriting the keys for example
|
||||
// So the process we're going to save needs to merge new states with what we already have
|
||||
const existingLastState = existing.states.pop();
|
||||
existing.states.push(state);
|
||||
existing.states.push(existingLastState);
|
||||
toSave[processId] = existing; // We mark it for update
|
||||
if (this.rolesContainsUs(state.roles)) {
|
||||
new_states.push(state.state_id);
|
||||
roles.push(state.roles);
|
||||
newStates.push(state.state_id);
|
||||
newRoles.push(state.roles);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (new_states.length != 0) {
|
||||
// We request the new states
|
||||
await this.requestDataFromPeers(processId, new_states, roles);
|
||||
toSave[processId] = process;
|
||||
if (newStates.length != 0) {
|
||||
await this.requestDataFromPeers(processId, newStates, newRoles);
|
||||
}
|
||||
|
||||
// Just to be sure check if that's a pairing process
|
||||
const lastCommitedState = this.getLastCommitedState(process);
|
||||
if (lastCommitedState && lastCommitedState.public_data && lastCommitedState.public_data['pairedAddresses']) {
|
||||
// This is a pairing process
|
||||
try {
|
||||
const pairedAddresses = this.decodeValue(lastCommitedState.public_data['pairedAddresses'] as unknown as number[]);
|
||||
// Are we part of it?
|
||||
if (pairedAddresses && pairedAddresses.length > 0 && pairedAddresses.includes(this.getDeviceAddress())) {
|
||||
// We save the process to db
|
||||
await this.saveProcessToDb(processId, process as Process);
|
||||
// We update the device
|
||||
await this.updateDevice();
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to check for pairing process:', e);
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise we're probably just in the initial loading at page initialization
|
||||
|
||||
// We may learn an update for this process
|
||||
// TODO maybe actually check if what the relay is sending us contains more information than what we have
|
||||
// relay should always have more info than us, but we never know
|
||||
// For now let's keep it simple and let the worker do the job
|
||||
} else {
|
||||
// We add it to db
|
||||
console.log(`Saving ${processId} to db`);
|
||||
toSave[processId] = process;
|
||||
}
|
||||
}
|
||||
|
||||
await this.batchSaveProcessesToDb(toSave);
|
||||
if (toSave && Object.keys(toSave).length > 0) {
|
||||
console.log('batch saving processes to db', toSave);
|
||||
await this.batchSaveProcessesToDb(toSave);
|
||||
}
|
||||
}
|
||||
}, 500)
|
||||
} catch (e) {
|
||||
@ -264,8 +258,6 @@ export class Service {
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get relay statistics from RelayManager.
|
||||
* @returns Statistics about connected relays
|
||||
@ -300,12 +292,53 @@ export class Service {
|
||||
}
|
||||
}
|
||||
|
||||
public async checkConnections(members: Member[]): Promise<void> {
|
||||
// If we're updating a process, we must call that after update especially if roles are part of it
|
||||
// We will take the roles from the last state, wheter it's commited or not
|
||||
public async checkConnections(process: Process): Promise<void> {
|
||||
const sharedSecret = await this.getAllSecretsFromDB();
|
||||
console.log('sharedSecret found', sharedSecret);
|
||||
if (process.states.length < 2) {
|
||||
throw new Error('Process doesn\'t have any state yet');
|
||||
}
|
||||
let roles = process.states[process.states.length - 2].roles;
|
||||
if (!roles) {
|
||||
throw new Error('No roles found');
|
||||
} else {
|
||||
console.log('roles found', roles);
|
||||
}
|
||||
let members: Set<Member> = new Set();
|
||||
for (const role of Object.values(roles!)) {
|
||||
console.log('role found', role);
|
||||
for (const member of role.members) {
|
||||
console.log('member found', member);
|
||||
// Check if we know the member that matches this id
|
||||
const memberAddresses = this.getAddressesForMemberId(member);
|
||||
console.log('memberAddresses found', memberAddresses);
|
||||
if (memberAddresses && memberAddresses.length != 0) {
|
||||
members.add({ sp_addresses: memberAddresses });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (members.size === 0) {
|
||||
// This must be a pairing process
|
||||
// Check if we have a pairedAddresses in the public data
|
||||
const publicData = process.states[0]?.public_data;
|
||||
if (!publicData || !publicData['pairedAddresses']) {
|
||||
throw new Error('Not a pairing process');
|
||||
}
|
||||
const decodedAddresses = this.decodeValue(publicData['pairedAddresses']);
|
||||
if (decodedAddresses.length === 0) {
|
||||
throw new Error('Not a pairing process');
|
||||
}
|
||||
members.add({ sp_addresses: decodedAddresses });
|
||||
}
|
||||
|
||||
// Ensure the amount is available before proceeding
|
||||
await this.getTokensFromFaucet();
|
||||
let unconnectedAddresses = [];
|
||||
let unconnectedAddresses = new Set<string>();
|
||||
const myAddress = this.getDeviceAddress();
|
||||
for (const member of members) {
|
||||
for (const member of Array.from(members)) {
|
||||
const sp_addresses = member.sp_addresses;
|
||||
if (!sp_addresses || sp_addresses.length === 0) continue;
|
||||
for (const address of sp_addresses) {
|
||||
@ -313,23 +346,23 @@ export class Service {
|
||||
if (address === myAddress) continue;
|
||||
const sharedSecret = await this.getSecretForAddress(address);
|
||||
if (!sharedSecret) {
|
||||
unconnectedAddresses.push(address);
|
||||
unconnectedAddresses.add(address);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (unconnectedAddresses && unconnectedAddresses.length != 0) {
|
||||
if (unconnectedAddresses && unconnectedAddresses.size != 0) {
|
||||
const apiResult = await this.connectAddresses(unconnectedAddresses);
|
||||
await this.handleApiReturn(apiResult);
|
||||
}
|
||||
}
|
||||
|
||||
public async connectAddresses(addresses: string[]): Promise<ApiReturn> {
|
||||
if (addresses.length === 0) {
|
||||
public async connectAddresses(addresses: Set<string>): Promise<ApiReturn> {
|
||||
if (addresses.size === 0) {
|
||||
throw new Error('Trying to connect to empty addresses list');
|
||||
}
|
||||
|
||||
try {
|
||||
return wasm.create_transaction(addresses, 1);
|
||||
return wasm.create_transaction(Array.from(addresses), 1);
|
||||
} catch (e) {
|
||||
console.error('Failed to connect member:', e);
|
||||
throw e;
|
||||
@ -516,18 +549,6 @@ export class Service {
|
||||
...wasm.encode_binary(publicSplitData.binaryData)
|
||||
};
|
||||
|
||||
let members: Set<Member> = new Set();
|
||||
for (const role of Object.values(roles!)) {
|
||||
for (const member of role.members) {
|
||||
// Check if we know the member that matches this id
|
||||
const memberAddresses = this.getAddressesForMemberId(member);
|
||||
if (memberAddresses && memberAddresses.length != 0) {
|
||||
members.add({ sp_addresses: memberAddresses });
|
||||
}
|
||||
}
|
||||
}
|
||||
await this.checkConnections([...members]);
|
||||
|
||||
const result = wasm.create_new_process (
|
||||
encodedPrivateData,
|
||||
roles,
|
||||
@ -536,8 +557,13 @@ export class Service {
|
||||
feeRate,
|
||||
this.getAllMembers()
|
||||
);
|
||||
|
||||
return(result);
|
||||
|
||||
if (result.updated_process) {
|
||||
await this.checkConnections(result.updated_process.current_process);
|
||||
return result;
|
||||
} else {
|
||||
throw new Error('Failed to create new process');
|
||||
}
|
||||
}
|
||||
|
||||
async parseCipher(message: string): Promise<void> {
|
||||
@ -606,6 +632,7 @@ export class Service {
|
||||
}
|
||||
|
||||
const result = wasm.create_update_message(process, stateId, this.membersList);
|
||||
await this.checkConnections(process);
|
||||
return result;
|
||||
} catch (error) {
|
||||
const errorMessage = error instanceof Error ? error.message : String(error || 'Unknown error');
|
||||
@ -624,7 +651,12 @@ export class Service {
|
||||
}
|
||||
|
||||
const result = wasm.validate_state(process, stateId, this.membersList);
|
||||
return result;
|
||||
if (result.updated_process) {
|
||||
await this.checkConnections(result.updated_process.current_process);
|
||||
return result;
|
||||
} else {
|
||||
throw new Error('Failed to validate state');
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMessage = error instanceof Error ? error.message : String(error || 'Unknown error');
|
||||
throw new Error(errorMessage);
|
||||
@ -633,32 +665,46 @@ export class Service {
|
||||
|
||||
// Core protocol method: Update Process
|
||||
async updateProcess(
|
||||
process: any,
|
||||
process: Process,
|
||||
privateData: Record<string, any>,
|
||||
publicData: Record<string, any>,
|
||||
roles: Record<string, any> | null
|
||||
roles: Record<string, RoleDefinition> | null
|
||||
): Promise<ApiReturn> {
|
||||
console.log(`🔄 Updating process ${process.states[0]?.state_id || 'unknown'}`);
|
||||
console.log(`🔄 Updating process ${process.states[0]?.commited_in || 'unknown'}`);
|
||||
console.log('Private data:', privateData);
|
||||
console.log('Public data:', publicData);
|
||||
console.log('Roles:', roles);
|
||||
|
||||
try {
|
||||
// Convert data to WASM format
|
||||
const newAttributes = wasm.encode_json(privateData);
|
||||
const newPublicData = wasm.encode_json(publicData);
|
||||
const newRoles = roles || process.states[0]?.roles || {};
|
||||
|
||||
// Use WASM function to update process
|
||||
const result = wasm.update_process(process, newAttributes, newRoles, newPublicData, this.membersList);
|
||||
if (!process || !process.states || process.states.length < 2) {
|
||||
throw new Error('Process not found');
|
||||
}
|
||||
|
||||
if (!roles || Object.keys(roles).length === 0) {
|
||||
const state = this.getLastCommitedState(process);
|
||||
if (state) {
|
||||
roles = state.roles;
|
||||
} else {
|
||||
roles = process.states[0]?.roles;
|
||||
}
|
||||
} else {
|
||||
console.log('Roles provided:', roles);
|
||||
}
|
||||
|
||||
const privateSplitData = this.splitData(privateData);
|
||||
const publicSplitData = this.splitData(publicData);
|
||||
const encodedPrivateData = {
|
||||
...wasm.encode_json(privateSplitData.jsonCompatibleData),
|
||||
...wasm.encode_binary(privateSplitData.binaryData)
|
||||
};
|
||||
const encodedPublicData = {
|
||||
...wasm.encode_json(publicSplitData.jsonCompatibleData),
|
||||
...wasm.encode_binary(publicSplitData.binaryData)
|
||||
};
|
||||
|
||||
try {
|
||||
const result = wasm.update_process(process, encodedPrivateData, roles, encodedPublicData, this.membersList);
|
||||
|
||||
if (result.updated_process) {
|
||||
// Update our cache
|
||||
this.processes.set(result.updated_process.process_id, result.updated_process.current_process);
|
||||
|
||||
// Save to database
|
||||
await this.saveProcessToDb(result.updated_process.process_id, result.updated_process.current_process);
|
||||
|
||||
await this.checkConnections(result.updated_process.current_process);
|
||||
return result;
|
||||
} else {
|
||||
throw new Error('Failed to update process');
|
||||
@ -685,7 +731,7 @@ export class Service {
|
||||
const newMyProcesses = new Set<string>();
|
||||
// MyProcesses automatically contains pairing process
|
||||
newMyProcesses.add(pairingProcessId);
|
||||
for (const [processId, process] of Object.entries(this.processes)) {
|
||||
for (const [processId, process] of this.processes.entries()) {
|
||||
try {
|
||||
const roles = this.getRoles(process);
|
||||
|
||||
@ -703,6 +749,47 @@ export class Service {
|
||||
}
|
||||
}
|
||||
|
||||
public async getProcessesData(filteredProcesses: Record<string, Process>): Promise<Record<string, any>> {
|
||||
const data: Record<string, any> = {};
|
||||
// Now we decrypt all we can in the processes
|
||||
for (const [processId, process] of Object.entries(filteredProcesses)) {
|
||||
// We also take the public data
|
||||
let lastState = this.getLastCommitedState(process);
|
||||
if (!lastState) {
|
||||
// fallback on the first state
|
||||
lastState = process.states[0];
|
||||
}
|
||||
const processData: Record<string, any> = {};
|
||||
for (const attribute of Object.keys(lastState.public_data)) {
|
||||
try {
|
||||
const value = this.decodeValue(lastState.public_data[attribute]);
|
||||
if (value !== null && value !== undefined) {
|
||||
processData[attribute] = value;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(`❌ Error decoding public data ${attribute} for process ${processId}:`, e);
|
||||
}
|
||||
}
|
||||
for (let i = process.states.length - 2; i >= 0; i--) {
|
||||
const state = process.states[i];
|
||||
for (const attribute of Object.keys(state.keys)) {
|
||||
if (processData[attribute] !== undefined && processData[attribute] !== null) continue;
|
||||
try {
|
||||
const value = await this.decryptAttribute(processId, state, attribute);
|
||||
if (value) {
|
||||
processData[attribute] = value;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(`❌ Error decrypting attribute ${attribute} for process ${processId}:`, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
data[processId] = processData;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
// Utility method: Get Process
|
||||
async getProcess(processId: string): Promise<any | null> {
|
||||
// First check in-memory cache
|
||||
@ -767,6 +854,25 @@ export class Service {
|
||||
}
|
||||
}
|
||||
|
||||
public async getAllSecretsFromDB(): Promise<SecretsStore> {
|
||||
try {
|
||||
const db = await Database.getInstance();
|
||||
const sharedSecrets: Record<string, string> = await db.dumpStore('shared_secrets');
|
||||
const unconfirmedSecrets = await db.dumpStore('unconfirmed_secrets');
|
||||
const secretsStore = {
|
||||
shared_secrets: sharedSecrets,
|
||||
unconfirmed_secrets: Object.values(unconfirmedSecrets),
|
||||
};
|
||||
return secretsStore;
|
||||
} catch (e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public loadSecretsInWasm(secretsStore: SecretsStore) {
|
||||
wasm.set_shared_secrets(JSON.stringify(secretsStore));
|
||||
}
|
||||
|
||||
// Utility method: Create a test process
|
||||
async createTestProcess(processId: string): Promise<any> {
|
||||
console.log(`🔧 Creating test process: ${processId}`);
|
||||
@ -952,37 +1058,35 @@ export class Service {
|
||||
}
|
||||
|
||||
// Blob and data storage methods
|
||||
async saveBlobToDb(hash: string, data: Blob) {
|
||||
async saveBufferToDb(hash: string, data: Buffer) {
|
||||
const db = await Database.getInstance();
|
||||
try {
|
||||
await db.addObject({
|
||||
storeName: 'data',
|
||||
object: data,
|
||||
key: hash,
|
||||
});
|
||||
}, true);
|
||||
} catch (e) {
|
||||
console.error(`Failed to save data to db: ${e}`);
|
||||
}
|
||||
}
|
||||
|
||||
async getBlobFromDb(hash: string): Promise<Blob | null> {
|
||||
async getBufferFromDb(hash: string): Promise<Buffer | null> {
|
||||
const db = await Database.getInstance();
|
||||
try {
|
||||
return await db.getObject('data', hash);
|
||||
return await db.getObject('data', hash, true);
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async saveDataToStorage(hash: string, data: Blob, ttl: number | null) {
|
||||
console.log('💾 Saving data to storage:', hash);
|
||||
// TODO: Implement actual storage service
|
||||
// const storages = [STORAGEURL];
|
||||
// try {
|
||||
// await storeData(storages, hash, data, ttl);
|
||||
// } catch (e) {
|
||||
// console.error(`Failed to store data with hash ${hash}: ${e}`);
|
||||
// }
|
||||
async saveDataToStorage(hash: string, data: Buffer, ttl: number | null, storageUrls: string[]) {
|
||||
console.log('💾 Saving data', hash, 'to storage', storageUrls);
|
||||
try {
|
||||
await storeData(storageUrls, hash, data, ttl);
|
||||
} catch (e) {
|
||||
console.error(`Failed to store data with hash ${hash}: ${e}`);
|
||||
}
|
||||
}
|
||||
|
||||
async saveDiffsToDb(diffs: any[]) {
|
||||
@ -1000,6 +1104,11 @@ export class Service {
|
||||
}
|
||||
}
|
||||
|
||||
async getDiffsFromDb(): Promise<Record<string, UserDiff>> {
|
||||
const db = await Database.getInstance();
|
||||
return await db.dumpStore('diffs');
|
||||
}
|
||||
|
||||
// Utility methods for data conversion
|
||||
hexToBlob(hexString: string): Blob {
|
||||
const uint8Array = this.hexToUInt8Array(hexString);
|
||||
@ -1017,6 +1126,10 @@ export class Service {
|
||||
return uint8Array;
|
||||
}
|
||||
|
||||
hexToBuffer(hexString: string): Buffer {
|
||||
return Buffer.from(this.hexToUInt8Array(hexString));
|
||||
}
|
||||
|
||||
public async handleApiReturn(apiReturn: ApiReturn) {
|
||||
// Check for errors in the returned objects
|
||||
if (apiReturn.new_tx_to_send && apiReturn.new_tx_to_send.error) {
|
||||
@ -1081,9 +1194,9 @@ export class Service {
|
||||
|
||||
if (updatedProcess.encrypted_data && Object.keys(updatedProcess.encrypted_data).length != 0) {
|
||||
for (const [hash, cipher] of Object.entries(updatedProcess.encrypted_data)) {
|
||||
const blob = this.hexToBlob(cipher);
|
||||
const buffer = this.hexToBuffer(cipher);
|
||||
try {
|
||||
await this.saveBlobToDb(hash, blob);
|
||||
await this.saveBufferToDb(hash, buffer);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
@ -1104,11 +1217,27 @@ export class Service {
|
||||
|
||||
if (apiReturn.push_to_storage && apiReturn.push_to_storage.length != 0) {
|
||||
for (const hash of apiReturn.push_to_storage) {
|
||||
const blob = await this.getBlobFromDb(hash);
|
||||
if (blob) {
|
||||
await this.saveDataToStorage(hash, blob, null);
|
||||
const buffer = await this.getBufferFromDb(hash);
|
||||
if (buffer) {
|
||||
// Look up the storage url for the hash
|
||||
// Find the field for this hash, then look up the roles to see what storage urls are associated
|
||||
let storageUrls = new Set<string>();
|
||||
const diffs = await this.getDiffsFromDb();
|
||||
const diff = Object.values(diffs).find((diff: UserDiff) => diff.value_commitment === hash);
|
||||
if (diff) {
|
||||
for (const role of Object.values(diff.roles)) {
|
||||
for (const rule of Object.values(role.validation_rules)) {
|
||||
if (rule.fields.includes(diff.field)) {
|
||||
for (const storageUrl of role.storages) {
|
||||
storageUrls.add(storageUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
await this.saveDataToStorage(hash, buffer, null, Array.from(storageUrls));
|
||||
} else {
|
||||
console.error('Failed to get data from db');
|
||||
console.error('Failed to get data from db for hash:', hash);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1207,11 +1336,10 @@ export class Service {
|
||||
}
|
||||
|
||||
if (hash && key) {
|
||||
const blob = await this.getBlobFromDb(hash);
|
||||
if (blob) {
|
||||
const buffer = await this.getBufferFromDb(hash);
|
||||
if (buffer) {
|
||||
// Decrypt the data
|
||||
const buf = await blob.arrayBuffer();
|
||||
const cipher = new Uint8Array(buf);
|
||||
const cipher = new Uint8Array(buffer);
|
||||
|
||||
const keyUIntArray = this.hexToUInt8Array(key);
|
||||
|
||||
@ -1220,7 +1348,7 @@ export class Service {
|
||||
if (clear) {
|
||||
// deserialize the result to get the actual data
|
||||
const decoded = wasm.decode_value(clear);
|
||||
return decoded;
|
||||
return this.convertMapsToObjects(decoded);
|
||||
} else {
|
||||
throw new Error('decrypt_data returned null');
|
||||
}
|
||||
@ -1235,13 +1363,49 @@ export class Service {
|
||||
|
||||
decodeValue(value: number[]): any | null {
|
||||
try {
|
||||
return wasm.decode_value(new Uint8Array(value));
|
||||
const decoded = wasm.decode_value(new Uint8Array(value));
|
||||
return this.convertMapsToObjects(decoded);
|
||||
} catch (e) {
|
||||
console.error(`Failed to decode value: ${e}`);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convertit récursivement les Map en objets sérialisables
|
||||
*/
|
||||
private convertMapsToObjects(obj: any): any {
|
||||
if (obj === null || obj === undefined) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
if (obj instanceof Map) {
|
||||
const result: any = {};
|
||||
for (const [key, value] of obj.entries()) {
|
||||
result[key] = this.convertMapsToObjects(value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
if (obj instanceof Set) {
|
||||
return Array.from(obj).map(item => this.convertMapsToObjects(item));
|
||||
}
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
return obj.map(item => this.convertMapsToObjects(item));
|
||||
}
|
||||
|
||||
if (typeof obj === 'object') {
|
||||
const result: any = {};
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
result[key] = this.convertMapsToObjects(value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
public async updateDevice(): Promise<void> {
|
||||
let myPairingProcessId: string;
|
||||
try {
|
||||
|
@ -3,7 +3,7 @@ import { MessageType } from './models';
|
||||
import { config } from './config';
|
||||
import { Service } from './service';
|
||||
import { ApiReturn, Process } from '../pkg/sdk_client';
|
||||
import { EMPTY32BYTES } from './utils';
|
||||
import { EMPTY32BYTES, splitPrivateData } from './utils';
|
||||
|
||||
interface ServerMessageEvent {
|
||||
data: {
|
||||
@ -42,6 +42,52 @@ class SimpleProcessHandlers {
|
||||
return apiKey === this.apiKey;
|
||||
}
|
||||
|
||||
async handleCreateProcess(event: ServerMessageEvent): Promise<ServerResponse> {
|
||||
if (event.data.type !== MessageType.CREATE_PROCESS) {
|
||||
throw new Error('Invalid message type');
|
||||
}
|
||||
|
||||
if (!this.service.isPaired()) {
|
||||
throw new Error('Device not paired');
|
||||
}
|
||||
|
||||
try {
|
||||
const { processData, privateFields, roles, exclusionRules, apiKey } = event.data;
|
||||
|
||||
if (!apiKey || !this.validateApiKey(apiKey)) {
|
||||
throw new Error('Invalid API key');
|
||||
}
|
||||
|
||||
const { privateData, publicData } = splitPrivateData(processData, privateFields);
|
||||
|
||||
const createProcessReturn = await this.service.createProcess(privateData, publicData, roles);
|
||||
if (!createProcessReturn.updated_process) {
|
||||
throw new Error('Empty updated_process in createProcessReturn');
|
||||
}
|
||||
console.log('🚀 ~ handleCreateProcess ~ createProcessReturn:', createProcessReturn);
|
||||
const processId = createProcessReturn.updated_process.process_id;
|
||||
const process = createProcessReturn.updated_process.current_process;
|
||||
await this.service.handleApiReturn(createProcessReturn);
|
||||
|
||||
const processCreated = {
|
||||
processId,
|
||||
process,
|
||||
processData,
|
||||
}
|
||||
|
||||
return {
|
||||
type: MessageType.PROCESS_CREATED,
|
||||
processCreated,
|
||||
messageId: event.data.messageId
|
||||
};
|
||||
} catch (e) {
|
||||
const errorMessage = e instanceof Error ? e.message : String(e || 'Unknown error');
|
||||
// Remove redundant "Error:" prefix and simplify the message
|
||||
const cleanMessage = errorMessage.replace(/^Error:\s*/, '');
|
||||
throw new Error(cleanMessage);
|
||||
}
|
||||
}
|
||||
|
||||
async handleNotifyUpdate(event: ServerMessageEvent): Promise<ServerResponse> {
|
||||
if (event.data.type !== MessageType.NOTIFY_UPDATE) {
|
||||
throw new Error('Invalid message type');
|
||||
@ -216,71 +262,70 @@ class SimpleProcessHandlers {
|
||||
throw new Error('Invalid message type');
|
||||
}
|
||||
|
||||
const processes = this.service.getProcesses();
|
||||
const myProcesses = await this.service.getMyProcesses();
|
||||
|
||||
if (!myProcesses || myProcesses.length === 0) {
|
||||
throw new Error('No my processes found');
|
||||
if (!this.service.isPaired()) {
|
||||
throw new Error('Device not paired');
|
||||
}
|
||||
|
||||
const filteredProcesses: Record<string, Process> = {};
|
||||
for (const processId of myProcesses) {
|
||||
const process = processes.get(processId);
|
||||
console.log(processId, ':', process);
|
||||
try {
|
||||
const processes = this.service.getProcesses();
|
||||
const myProcesses = await this.service.getMyProcesses();
|
||||
|
||||
if (process) {
|
||||
filteredProcesses[processId] = process;
|
||||
if (!myProcesses || myProcesses.length === 0) {
|
||||
throw new Error('No my processes found');
|
||||
}
|
||||
}
|
||||
|
||||
const data: Record<string, any> = {};
|
||||
// Now we decrypt all we can in the processes
|
||||
for (const [processId, process] of Object.entries(filteredProcesses)) {
|
||||
// We also take the public data
|
||||
const lastState = this.service.getLastCommitedState(process);
|
||||
if (!lastState) {
|
||||
console.error(`❌ Process ${processId} doesn't have a commited state`);
|
||||
continue;
|
||||
}
|
||||
const processData: Record<string, any> = {};
|
||||
for (const attribute of Object.keys(lastState.public_data)) {
|
||||
try {
|
||||
const value = this.service.decodeValue(lastState.public_data[attribute]);
|
||||
if (value) {
|
||||
processData[attribute] = value;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(`❌ Error decoding public data ${attribute} for process ${processId}:`, e);
|
||||
const filteredProcesses: Record<string, Process> = {};
|
||||
for (const processId of myProcesses) {
|
||||
const process = processes.get(processId);
|
||||
|
||||
if (process) {
|
||||
filteredProcesses[processId] = process;
|
||||
} else {
|
||||
console.error(`Process ${processId} not found`); // should not happen
|
||||
}
|
||||
}
|
||||
for (let i = process.states.length - 2; i >= 0; i--) {
|
||||
const state = process.states[i];
|
||||
for (const attribute of Object.keys(state.keys)) {
|
||||
if (processData[attribute] !== undefined && processData[attribute] !== null) continue;
|
||||
try {
|
||||
const value = await this.service.decryptAttribute(processId, state, attribute);
|
||||
if (value) {
|
||||
processData[attribute] = value;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(`❌ Error decrypting attribute ${attribute} for process ${processId}:`, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
data[processId] = processData;
|
||||
|
||||
const data = await this.service.getProcessesData(filteredProcesses);
|
||||
|
||||
return {
|
||||
type: MessageType.PROCESSES_RETRIEVED,
|
||||
processes: filteredProcesses,
|
||||
data,
|
||||
messageId: event.data.messageId
|
||||
};
|
||||
} catch (e) {
|
||||
const errorMessage = e instanceof Error ? e.message : String(e || 'Unknown error');
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
async handleGetPairingId(event: ServerMessageEvent): Promise<ServerResponse> {
|
||||
if (event.data.type !== MessageType.GET_PAIRING_ID) {
|
||||
throw new Error('Invalid message type');
|
||||
}
|
||||
|
||||
return {
|
||||
type: MessageType.PROCESSES_RETRIEVED,
|
||||
processes: filteredProcesses,
|
||||
data,
|
||||
messageId: event.data.messageId
|
||||
};
|
||||
if (!this.service.isPaired()) {
|
||||
throw new Error('Device not paired');
|
||||
}
|
||||
|
||||
try {
|
||||
const pairingId = this.service.getPairingProcessId();
|
||||
return {
|
||||
type: MessageType.GET_PAIRING_ID,
|
||||
pairingId,
|
||||
messageId: event.data.messageId
|
||||
};
|
||||
} catch (e) {
|
||||
const errorMessage = e instanceof Error ? e.message : String(e || 'Unknown error');
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
async handleMessage(event: ServerMessageEvent): Promise<ServerResponse> {
|
||||
try {
|
||||
switch (event.data.type) {
|
||||
case MessageType.CREATE_PROCESS:
|
||||
return await this.handleCreateProcess(event);
|
||||
case MessageType.NOTIFY_UPDATE:
|
||||
return await this.handleNotifyUpdate(event);
|
||||
case MessageType.VALIDATE_STATE:
|
||||
@ -289,6 +334,8 @@ class SimpleProcessHandlers {
|
||||
return await this.handleUpdateProcess(event);
|
||||
case MessageType.GET_MY_PROCESSES:
|
||||
return await this.handleGetMyProcesses(event);
|
||||
case MessageType.GET_PAIRING_ID:
|
||||
return await this.handleGetPairingId(event);
|
||||
default:
|
||||
throw new Error(`Unhandled message type: ${event.data.type}`);
|
||||
}
|
||||
@ -353,15 +400,14 @@ export class Server {
|
||||
if (!processId || !stateId) {
|
||||
throw new Error('Failed to get process id or state id');
|
||||
}
|
||||
// now pair the device before continuing
|
||||
service.pairDevice(processId, [service.getDeviceAddress()]);
|
||||
await service.handleApiReturn(pairingResult);
|
||||
const udpateResult = await service.createPrdUpdate(processId, stateId);
|
||||
await service.handleApiReturn(udpateResult);
|
||||
const approveResult = await service.approveChange(processId, stateId);
|
||||
await service.handleApiReturn(approveResult);
|
||||
|
||||
// now pair the device
|
||||
service.pairDevice(processId, [service.getDeviceAddress()]);
|
||||
|
||||
// Update the device in the database
|
||||
const device = service.dumpDeviceFromMemory();
|
||||
if (device) {
|
||||
@ -380,6 +426,9 @@ export class Server {
|
||||
|
||||
// Get all processes from database
|
||||
await service.getAllProcessesFromDb();
|
||||
const secretsStore = await service.getAllSecretsFromDB();
|
||||
|
||||
service.loadSecretsInWasm(secretsStore);
|
||||
|
||||
// Connect to relays
|
||||
await service.connectToRelaysAndWaitForHandshake();
|
||||
|
111
src/storage.service.ts
Normal file
111
src/storage.service.ts
Normal file
@ -0,0 +1,111 @@
|
||||
import axios, { AxiosResponse } from 'axios';
|
||||
|
||||
export async function storeData(servers: string[], key: string, value: Buffer, ttl: number | null): Promise<AxiosResponse | null> {
|
||||
for (const server of servers) {
|
||||
try {
|
||||
// Use key in the URL path instead of query parameters
|
||||
let url = `${server}/store/${key}`;
|
||||
|
||||
// Add ttl as query parameter if provided
|
||||
if (ttl !== null) {
|
||||
const urlObj = new URL(url);
|
||||
urlObj.searchParams.append('ttl', ttl.toString());
|
||||
url = urlObj.toString();
|
||||
}
|
||||
|
||||
// Send the encrypted ArrayBuffer as the raw request body.
|
||||
const response = await axios.post(url, value, {
|
||||
headers: {
|
||||
'Content-Type': 'application/octet-stream'
|
||||
},
|
||||
});
|
||||
console.log('Data stored successfully:', key);
|
||||
if (response.status !== 200) {
|
||||
console.error('Received response status', response.status);
|
||||
continue;
|
||||
}
|
||||
return response;
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError(error) && error.response?.status === 409) {
|
||||
return null;
|
||||
}
|
||||
console.error('Error storing data:', error);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export async function retrieveData(servers: string[], key: string): Promise<ArrayBuffer | null> {
|
||||
for (const server of servers) {
|
||||
try {
|
||||
// Handle relative paths (for development proxy) vs absolute URLs (for production)
|
||||
const url = server.startsWith('/')
|
||||
? `${server}/retrieve/${key}` // Relative path - use as-is for proxy
|
||||
: new URL(`${server}/retrieve/${key}`).toString(); // Absolute URL - construct properly
|
||||
|
||||
console.log('Retrieving data', key,' from:', url);
|
||||
// When fetching the data from the server:
|
||||
const response = await axios.get(url, {
|
||||
responseType: 'arraybuffer'
|
||||
});
|
||||
|
||||
if (response.status === 200) {
|
||||
// Validate that we received an ArrayBuffer
|
||||
if (response.data instanceof ArrayBuffer) {
|
||||
return response.data;
|
||||
} else {
|
||||
console.error('Server returned non-ArrayBuffer data:', typeof response.data);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
console.error(`Server ${server} returned status ${response.status}`);
|
||||
continue;
|
||||
}
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError(error)) {
|
||||
if (error.response?.status === 404) {
|
||||
console.log(`Data not found on server ${server} for key ${key}`);
|
||||
continue; // Try next server
|
||||
} else if (error.response?.status) {
|
||||
console.error(`Server ${server} error ${error.response.status}:`, error.response.statusText);
|
||||
continue;
|
||||
} else {
|
||||
console.error(`Network error connecting to ${server}:`, error.message);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
console.error(`Unexpected error retrieving data from ${server}:`, error);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
interface TestResponse {
|
||||
key: string;
|
||||
value: boolean;
|
||||
}
|
||||
|
||||
export async function testData(servers: string[], key: string): Promise<Record<string, boolean | null> | null> {
|
||||
const res: Record<string, boolean | null> = {};
|
||||
for (const server of servers) {
|
||||
res[server] = null;
|
||||
try {
|
||||
const response = await axios.get(`${server}/test/${key}`);
|
||||
if (response.status !== 200) {
|
||||
console.error(`${server}: Test response status: ${response.status}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
const data: TestResponse = response.data;
|
||||
|
||||
res[server] = data.value;
|
||||
} catch (error) {
|
||||
console.error('Error retrieving data:', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
15
src/utils.ts
15
src/utils.ts
@ -1,6 +1,21 @@
|
||||
// Server-specific utility functions
|
||||
export const EMPTY32BYTES = String('').padStart(64, '0');
|
||||
|
||||
export function splitPrivateData(data: Record<string, any>, privateFields: string[]): { privateData: Record<string, any>, publicData: Record<string, any> } {
|
||||
const privateData: Record<string, any> = {};
|
||||
const publicData: Record<string, any> = {};
|
||||
|
||||
for (const [key, value] of Object.entries(data)) {
|
||||
if (privateFields.includes(key)) {
|
||||
privateData[key] = value;
|
||||
} else {
|
||||
publicData[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return { privateData, publicData };
|
||||
}
|
||||
|
||||
export function isValid32ByteHex(value: string): boolean {
|
||||
// Check if the value is a valid 32-byte hex string (64 characters)
|
||||
const hexRegex = /^[0-9a-fA-F]{64}$/;
|
||||
|
Loading…
x
Reference in New Issue
Block a user