@egen-civitas/esm-embed-host 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +4 -1
- package/package.json +3 -3
- package/src/table.ts +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @egen-civitas/esm-embed-host
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 18cec62: Sécurité : `api.fetch` avec `path` est désormais **deny-by-default** (liste `paths` obligatoire dans le grant, normalisation anti-contournement : `..`, `%2e`, `//`…) pour qu'une app embarquée ne puisse pas appeler tout l'API du Core avec la session de l'utilisateur ; `negotiateCapabilities` ignore les entrées malformées ; tests de fuzz déterministes. Outillage : `egen-embed-check` (manifeste, capacités, `frame-ancestors`).
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [18cec62]
|
|
12
|
+
- @egen-civitas/esm-embed-protocol@0.2.0
|
|
13
|
+
|
|
3
14
|
## 0.1.0
|
|
4
15
|
|
|
5
16
|
### Minor Changes
|
package/dist/table.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../src/table.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../src/table.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,iBAAiB,EACtB,KAAK,YAAY,EAEjB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACtB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,KAAK,EAA6B,aAAa,EAAE,MAAM,gBAAgB,C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mbedError, pickFields, topicAllowed } from '@egen-civitas/esm-embed-protocol';
|
|
187
|
+
import { CAPABILITIES, DEFAULT_SESSION_FIELDS, EmbedError, pathAllowed, pickFields, topicAllowed } from '@egen-civitas/esm-embed-protocol';
|
|
188
188
|
/** Capacités que l'hôte sait servir avec ces fournisseurs. `navigation`, `lifecycle` et `telemetry` sont toujours servies. */ export function availableCapabilities(p) {
|
|
189
189
|
var s = new Set([
|
|
190
190
|
'navigation',
|
|
@@ -472,12 +472,15 @@ function normOrigin(u) {
|
|
|
472
472
|
var headers = list(cfg, 'headers').map(function(h) {
|
|
473
473
|
return h.toLowerCase();
|
|
474
474
|
});
|
|
475
|
+
var paths = list(cfg, 'paths');
|
|
475
476
|
table.api = {
|
|
476
477
|
fetch: function fetch(req) {
|
|
477
478
|
return _async_to_generator(function() {
|
|
478
479
|
var _req_headers, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, h;
|
|
479
480
|
return _ts_generator(this, function(_state) {
|
|
480
481
|
if (req.url !== undefined && !hosts.includes(normOrigin(req.url))) throw denied("Hôte non autorisé par le grant de l'app");
|
|
482
|
+
// Sans liste de chemins (deny-by-default) une app ne peut PAS appeler l'API du Core avec la session de l'utilisateur.
|
|
483
|
+
if (req.path !== undefined && !pathAllowed(paths, req.path)) throw denied("Chemin d'API non autoris\xe9 par le grant de l'app : ".concat(req.path));
|
|
481
484
|
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
482
485
|
try {
|
|
483
486
|
for(_iterator = Object.keys((_req_headers = req.headers) !== null && _req_headers !== void 0 ? _req_headers : {})[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@egen-civitas/esm-embed-host",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "Hôte (côté Shell/Core) des applications embarquées : iframe sécurisée, poignée de main v2, grants, fournisseurs de capacités, navigation partagée, compatibilité du pont 1.1.",
|
|
6
6
|
"type": "module",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@egen-civitas/esm-embed-client": "^0.1.
|
|
60
|
+
"@egen-civitas/esm-embed-client": "^0.1.1",
|
|
61
61
|
"@swc/cli": "0.8.1",
|
|
62
62
|
"@swc/core": "1.15.21",
|
|
63
63
|
"@types/node": "^20",
|
|
@@ -69,6 +69,6 @@
|
|
|
69
69
|
"vitest": "^4.1.2"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@egen-civitas/esm-embed-protocol": "^0.
|
|
72
|
+
"@egen-civitas/esm-embed-protocol": "^0.2.0"
|
|
73
73
|
}
|
|
74
74
|
}
|
package/src/table.ts
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
CAPABILITIES,
|
|
3
3
|
DEFAULT_SESSION_FIELDS,
|
|
4
4
|
EmbedError,
|
|
5
|
+
pathAllowed,
|
|
5
6
|
pickFields,
|
|
6
7
|
topicAllowed,
|
|
7
8
|
type CapabilityGranted,
|
|
@@ -121,9 +122,12 @@ export function createCapabilityTable(o: TableOptions): { table: HandlerTable; s
|
|
|
121
122
|
const cfg = cfgOf.get('api');
|
|
122
123
|
const hosts = list(cfg, 'hosts').map(normOrigin);
|
|
123
124
|
const headers = list(cfg, 'headers').map((h) => h.toLowerCase());
|
|
125
|
+
const paths = list(cfg, 'paths');
|
|
124
126
|
table.api = {
|
|
125
127
|
fetch: async (req: ApiRequest) => {
|
|
126
128
|
if (req.url !== undefined && !hosts.includes(normOrigin(req.url))) throw denied("Hôte non autorisé par le grant de l'app");
|
|
129
|
+
// Sans liste de chemins (deny-by-default) une app ne peut PAS appeler l'API du Core avec la session de l'utilisateur.
|
|
130
|
+
if (req.path !== undefined && !pathAllowed(paths, req.path)) throw denied(`Chemin d'API non autorisé par le grant de l'app : ${req.path}`);
|
|
127
131
|
for (const h of Object.keys(req.headers ?? {})) if (!headers.includes(h.toLowerCase())) throw denied(`En-tête non autorisé : ${h}`);
|
|
128
132
|
return p.api!.fetch(req, ctx);
|
|
129
133
|
},
|