@lab-anssi/lib 1.5.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.js +2 -3
- package/dist/serveur/serveurLab.d.ts +4 -2
- package/dist/serveur/serveurLab.js +32 -1
- package/package.json +2 -2
- package/dist/serveur/adaptateurEnvironnementServeurLab.d.ts +0 -2
- package/dist/serveur/adaptateurEnvironnementServeurLab.js +0 -34
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ app.get('/', (req, res) => {res.json({})});
|
|
|
29
29
|
La configuration serveur peut-être construite automatiquement à partir des variables d'environnement :
|
|
30
30
|
|
|
31
31
|
```
|
|
32
|
-
const config =
|
|
32
|
+
const config = configurationServeurLabEnvironnement();
|
|
33
33
|
const app = creeServeurLab(config);
|
|
34
34
|
app.get('/', (req, res) => {res.json({})});
|
|
35
35
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,4 @@ export { type EntreeTableDesMatieres, type PageHtmlCrisp, type ResumeArticleCris
|
|
|
2
2
|
export { CmsCrisp } from './cms/cmsCrisp';
|
|
3
3
|
export { AdaptateurProfilAnssi } from './profilAnssi/adaptateurProfilAnssi';
|
|
4
4
|
export { ErreurArticleCrispIntrouvable } from './erreurs';
|
|
5
|
-
export { type ConfigurationServeurLab } from './serveur/serveurLab';
|
|
6
|
-
export { creeServeurLab } from './serveur/serveurLab';
|
|
7
|
-
export { adaptateurEnvironnementServeurLab } from './serveur/adaptateurEnvironnementServeurLab';
|
|
5
|
+
export { type ConfigurationServeurLab, creeServeurLab, configurationServeurLabEnvironnement, } from './serveur/serveurLab';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.configurationServeurLabEnvironnement = exports.creeServeurLab = exports.ErreurArticleCrispIntrouvable = exports.AdaptateurProfilAnssi = exports.CmsCrisp = void 0;
|
|
4
4
|
var cmsCrisp_1 = require("./cms/cmsCrisp");
|
|
5
5
|
Object.defineProperty(exports, "CmsCrisp", { enumerable: true, get: function () { return cmsCrisp_1.CmsCrisp; } });
|
|
6
6
|
var adaptateurProfilAnssi_1 = require("./profilAnssi/adaptateurProfilAnssi");
|
|
@@ -9,5 +9,4 @@ var erreurs_1 = require("./erreurs");
|
|
|
9
9
|
Object.defineProperty(exports, "ErreurArticleCrispIntrouvable", { enumerable: true, get: function () { return erreurs_1.ErreurArticleCrispIntrouvable; } });
|
|
10
10
|
var serveurLab_1 = require("./serveur/serveurLab");
|
|
11
11
|
Object.defineProperty(exports, "creeServeurLab", { enumerable: true, get: function () { return serveurLab_1.creeServeurLab; } });
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, "adaptateurEnvironnementServeurLab", { enumerable: true, get: function () { return adaptateurEnvironnementServeurLab_1.adaptateurEnvironnementServeurLab; } });
|
|
12
|
+
Object.defineProperty(exports, "configurationServeurLabEnvironnement", { enumerable: true, get: function () { return serveurLab_1.configurationServeurLabEnvironnement; } });
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Express } from 'express';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
declare const creeServeurLab: (config: ConfigurationServeurLab) => Express;
|
|
3
|
+
type ConfigurationServeurLab = {
|
|
4
4
|
reseau: {
|
|
5
5
|
trustProxy: number | string;
|
|
6
6
|
maxRequetesParMinute: number;
|
|
7
7
|
ipAutorisees: string[] | false;
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
|
+
declare const configurationServeurLabEnvironnement: () => ConfigurationServeurLab;
|
|
11
|
+
export { configurationServeurLabEnvironnement, creeServeurLab, ConfigurationServeurLab, };
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.creeServeurLab = void 0;
|
|
6
|
+
exports.creeServeurLab = exports.configurationServeurLabEnvironnement = void 0;
|
|
7
7
|
const express_ipfilter_1 = require("express-ipfilter");
|
|
8
8
|
const express_rate_limit_1 = __importDefault(require("express-rate-limit"));
|
|
9
9
|
const creeServeurLab = (config) => {
|
|
@@ -46,3 +46,34 @@ const creeServeurLab = (config) => {
|
|
|
46
46
|
return app;
|
|
47
47
|
};
|
|
48
48
|
exports.creeServeurLab = creeServeurLab;
|
|
49
|
+
const configurationServeurLabEnvironnement = () => {
|
|
50
|
+
return {
|
|
51
|
+
reseau: {
|
|
52
|
+
trustProxy: trustProxy(),
|
|
53
|
+
maxRequetesParMinute: maxRequetesParMinute(),
|
|
54
|
+
ipAutorisees: process.env.SERVEUR_ADRESSES_IP_AUTORISEES?.split(',') ?? false,
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
exports.configurationServeurLabEnvironnement = configurationServeurLabEnvironnement;
|
|
59
|
+
const trustProxy = () => {
|
|
60
|
+
const trustProxyEnChaine = process.env.SERVEUR_TRUST_PROXY || '0';
|
|
61
|
+
const trustProxyEnNombre = Number(trustProxyEnChaine);
|
|
62
|
+
if (isNaN(trustProxyEnNombre)) {
|
|
63
|
+
console.warn(`Attention ! SERVEUR_TRUST_PROXY positionné à ${trustProxyEnChaine}`);
|
|
64
|
+
return trustProxyEnChaine;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
return trustProxyEnNombre;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const maxRequetesParMinute = () => {
|
|
71
|
+
const maxEnChaine = process.env.SERVEUR_MAX_REQUETES_PAR_MINUTE || '600';
|
|
72
|
+
const maxEnNombre = Number(maxEnChaine);
|
|
73
|
+
if (isNaN(maxEnNombre)) {
|
|
74
|
+
throw new Error(`SERVEUR_MAX_REQUETES_PAR_MINUTE n'est pas un nombre : ${maxEnChaine}`);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
return maxEnNombre;
|
|
78
|
+
}
|
|
79
|
+
};
|
package/package.json
CHANGED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.adaptateurEnvironnementServeurLab = void 0;
|
|
4
|
-
const trustProxy = () => {
|
|
5
|
-
const trustProxyEnChaine = process.env.SERVEUR_TRUST_PROXY || '0';
|
|
6
|
-
const trustProxyEnNombre = Number(trustProxyEnChaine);
|
|
7
|
-
if (isNaN(trustProxyEnNombre)) {
|
|
8
|
-
console.warn(`Attention ! SERVEUR_TRUST_PROXY positionné à ${trustProxyEnChaine}`);
|
|
9
|
-
return trustProxyEnChaine;
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
return trustProxyEnNombre;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
const maxRequetesParMinute = () => {
|
|
16
|
-
const maxEnChaine = process.env.SERVEUR_MAX_REQUETES_PAR_MINUTE || '600';
|
|
17
|
-
const maxEnNombre = Number(maxEnChaine);
|
|
18
|
-
if (isNaN(maxEnNombre)) {
|
|
19
|
-
throw new Error(`SERVEUR_MAX_REQUETES_PAR_MINUTE n'est pas un nombre : ${maxEnChaine}`);
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
return maxEnNombre;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
const adaptateurEnvironnementServeurLab = () => {
|
|
26
|
-
return {
|
|
27
|
-
reseau: {
|
|
28
|
-
trustProxy: trustProxy(),
|
|
29
|
-
maxRequetesParMinute: maxRequetesParMinute(),
|
|
30
|
-
ipAutorisees: process.env.SERVEUR_ADRESSES_IP_AUTORISEES?.split(',') ?? false,
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
exports.adaptateurEnvironnementServeurLab = adaptateurEnvironnementServeurLab;
|