diff --git a/.env.exemple b/.env.exemple index bf2c0c4..6e83993 100644 --- a/.env.exemple +++ b/.env.exemple @@ -61,6 +61,16 @@ DECLINED='4000 0025 0000 3155' ENABLE_SUBSCRIPTION_STUB=true CORS_ALLOWED_ORIGINS=http://local.4nkweb.com:3000,https://dev4.4nkweb.com +core_url="http://bitcoin:38332" +ws_url="0.0.0.0:8090" +wallet_name="default" +network="signet" +blindbit_url="http://blindbit:8000" +zmq_url="tcp://bitcoin:29000" +storage="https://dev4.4nkweb.com/storage" +data_dir="/home/bitcoin/.4nk" +bitcoin_data_dir="/home/bitcoin/.bitcoin" + # ================================= /!\ sensible ======================== # Configuration IDNOT diff --git a/docs/ANALYSE.md b/docs/ANALYSE.md new file mode 100644 index 0000000..c180aed --- /dev/null +++ b/docs/ANALYSE.md @@ -0,0 +1,42 @@ +## Analyse détaillée + +### Périmètre + +Backend minimal Express TypeScript, endpoints tests et scripts utilitaires. + +### Stack + +- **Runtime**: Node.js (TS → JS via `tsc`) +- **Framework**: Express 4, CORS, dotenv +- **DB**: `pg` (PostgreSQL) +- **Paiement**: Stripe SDK +- **Messaging**: Mailchimp transactional + +### Build et exécution + +- Scripts: `build`, `start`, `dev` (ts-node), `watch`, scénarios `test:*` spécifiques. +- Dépendance locale: `sdk-signer-client` (path `../sdk-signer-client`). +- Docker: clone/compile `sdk-signer-client` via SSH, build app, prune deps dev, exécution `npm start`. + +### Variables d’environnement + +- À documenter dans `.env` (non listées ici). Recommandé d’ajouter `.env.example`. + +### Ports + +- 8080 (exposé par Compose parent). + +### Risques et points d’attention + +- Dépendance relative `../sdk-signer-client` fragile hors CI; Docker règle via clone SSH mais nécessite agent/clé. +- Node 19‑alpine dans le builder: préférer LTS. +- Tests utilitaires JS isolés; aligner avec `tests/` et ajouter assertions/rapports. + +### Actions proposées + +- Externaliser `sdk-signer-client` en dépendance Git contrôlée (tag/commit) ou package binaire local packagé. +- Standardiser Node LTS et CI (lint, tests, build, audit sécurité). +- Fournir `.env.example` et documenter variables requises. + + + diff --git a/src/controllers/idnot.controller.ts b/src/controllers/idnot.controller.ts index 4c1001b..35dd3c0 100644 --- a/src/controllers/idnot.controller.ts +++ b/src/controllers/idnot.controller.ts @@ -113,28 +113,28 @@ export class IdNotController { Logger.info('IdNot using rattachements API with sub', { sub: payload.sub }); const rattachementsJson = await IdNotService.getUserRattachements(payload.sub); const results: any[] = Array.isArray(rattachementsJson?.result) ? rattachementsJson.result : []; - + if (results.length === 0) { throw new ForbiddenError('User not attached to an office'); } - + // Get the first rattachement const rattachement = results[0]; - + // Fetch entite and personne data separately if not present let entiteData = rattachement.entite; let personneData = rattachement.personne; - + if (!entiteData && rattachement.entiteUrl) { Logger.info('IdNot fetching entite data', { entiteUrl: rattachement.entiteUrl }); entiteData = await IdNotService.getEntiteData(rattachement.entiteUrl); } - + if (!personneData && rattachement.personneUrl) { Logger.info('IdNot fetching personne data', { personneUrl: rattachement.personneUrl }); personneData = await IdNotService.getPersonneData(rattachement.personneUrl); } - + const userData = { ...rattachement, entite: entiteData, diff --git a/src/services/idnot/index.ts b/src/services/idnot/index.ts index 460aede..a3d43fc 100644 --- a/src/services/idnot/index.ts +++ b/src/services/idnot/index.ts @@ -244,7 +244,7 @@ export class IdNotService { const url = `${IDNOT_ANNUARY_BASE_URL}${entiteUrl}?${searchParams}`; const response = await fetch(url, { method: 'GET' }); - + if (!response.ok) { const text = await response.text().catch(() => ''); Logger.error('IdNot getEntiteData failed', { @@ -255,7 +255,7 @@ export class IdNotService { }); throw new Error(`Failed to fetch entite data: ${response.status} ${response.statusText}`); } - + return response.json(); } @@ -272,7 +272,7 @@ export class IdNotService { const url = `${IDNOT_ANNUARY_BASE_URL}${personneUrl}?${searchParams}`; const response = await fetch(url, { method: 'GET' }); - + if (!response.ok) { const text = await response.text().catch(() => ''); Logger.error('IdNot getPersonneData failed', { @@ -283,7 +283,7 @@ export class IdNotService { }); throw new Error(`Failed to fetch personne data: ${response.status} ${response.statusText}`); } - + return response.json(); }