@egen-civitas/esm-embed-testing 0.4.0 → 0.6.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 +30 -0
- package/README.md +1 -1
- package/bin/egen-embed-check.mjs +2 -2
- package/bin/egen-embed-sim.mjs +2 -2
- package/dist/check.d.ts +1 -1
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +178 -2
- package/dist/server.d.ts +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +4 -1
- package/dist/test-host.d.ts +6 -2
- package/dist/test-host.d.ts.map +1 -1
- package/dist/test-host.js +3 -1
- package/package.json +4 -4
- package/src/check.ts +58 -1
- package/src/server.ts +8 -4
- package/src/test-host.ts +7 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @egen-civitas/esm-embed-testing
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 2a240fc: `egen-embed-check --probe` vérifie aussi la déclaration publiée à `<url>/egen-config.json` (voie normale, doc 17 §7) : présence (404 = information sur le second recours), absence de redirection, JSON et forme valides selon le protocole, écart avec la déclaration contrôlée (champs nommés) et rappel `Cache-Control: no-store` (le Core fige son SHA-256).
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [1e9983d]
|
|
12
|
+
- @egen-civitas/esm-embed-protocol@0.5.1
|
|
13
|
+
|
|
14
|
+
## 0.5.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- 721c7f8: Droits d'iframe négociés et voie unique SDK.
|
|
19
|
+
|
|
20
|
+
- **protocole** : bloc `iframe` (`sandbox[]`, `allow[]`) dans la déclaration `egen-config.json` (demande) et dans le plafond approuvé ; listes blanches strictes (`IFRAME_SANDBOX_TOKENS`, `IFRAME_ALLOW_TOKENS`, jamais de `allow-top-navigation*`) ; `validateIframeRights`, `effectiveIframe` (demande ∩ plafond), `sanitizeIframeRights` ; `config` publique validée (≤ 8 Ko) ; `ApprovedGrants` accepte `iframe`. **Breaking** : `SUPPORTED_PROTOCOLS` ne contient plus que `2` (le protocole 1 / pont 1.1 est retiré) ; `negotiateProtocol(1)` → `null`.
|
|
21
|
+
- **hôte** : option `iframe` (droits effectifs) qui étend le socle et pose les attributs `sandbox` et `allow`, avec revalidation par liste blanche. **Breaking** : l'option `sandbox` est remplacée par `iframe` ; l'option `legacy` et le pont 1.1 (`handleLegacy`, `legacySend`) sont retirés ; la poignée de main ne propose plus que le protocole 2.
|
|
22
|
+
- **testing** : `createTestHost` accepte `manifestIframe` et expose `iframe` (droits effectifs) ; `egen-embed-check` valide la forme `iframe`, rappelle l'approbation requise et signale les permissions sensibles ; le simulateur applique les droits d'iframe.
|
|
23
|
+
- **client** : documentation (les droits se demandent dans `egen-config.json`), le manifeste s'appelle désormais `egen-config.json`.
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Updated dependencies [721c7f8]
|
|
28
|
+
- Updated dependencies [721c7f8]
|
|
29
|
+
- @egen-civitas/esm-embed-protocol@0.5.0
|
|
30
|
+
- @egen-civitas/esm-embed-host@0.5.0
|
|
31
|
+
- @egen-civitas/esm-embed-client@0.3.1
|
|
32
|
+
|
|
3
33
|
## 0.4.0
|
|
4
34
|
|
|
5
35
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ defineConformance(myConnectFn, { describe, it, expect }); // SDK officiel ou imp
|
|
|
34
34
|
## 3. Simulateur de Shell dans le navigateur
|
|
35
35
|
|
|
36
36
|
```bash
|
|
37
|
-
npx egen-embed-sim --app http://localhost:3000 --manifest egen-
|
|
37
|
+
npx egen-embed-sim --app http://localhost:3000 --manifest egen-config.json
|
|
38
38
|
# → déclarez dans l'app : hostOrigins: ['http://127.0.0.1:4100']
|
|
39
39
|
```
|
|
40
40
|
|
package/bin/egen-embed-check.mjs
CHANGED
|
@@ -10,10 +10,10 @@ const opt = (n) => {
|
|
|
10
10
|
if (args.includes('--help') || !opt('--manifest')) {
|
|
11
11
|
console.log(`egen-embed-check — vérifie une app embarquée (manifeste, capacités, intégrabilité en iframe)
|
|
12
12
|
|
|
13
|
-
Usage : egen-embed-check --manifest egen-
|
|
13
|
+
Usage : egen-embed-check --manifest egen-config.json [--shell https://egen.exemple.org] [--probe] [--allow-localhost]
|
|
14
14
|
|
|
15
15
|
--shell origine du Shell EGEN (contrôle CSP frame-ancestors)
|
|
16
|
-
--probe interroge l'URL de l'app
|
|
16
|
+
--probe interroge l'URL de l'app : en-têtes X-Frame-Options / CSP, et déclaration publiée à <url>/egen-config.json
|
|
17
17
|
--allow-localhost tolère http://localhost (développement)
|
|
18
18
|
|
|
19
19
|
Code de sortie : 1 si au moins une erreur.`);
|
package/bin/egen-embed-sim.mjs
CHANGED
|
@@ -10,10 +10,10 @@ const opt = (name) => {
|
|
|
10
10
|
if (args.includes('--help') || !opt('--app')) {
|
|
11
11
|
console.log(`egen-embed-sim — simulateur de Shell EGEN pour développer une app embarquée sans le Core
|
|
12
12
|
|
|
13
|
-
Usage : egen-embed-sim --app <url> [--manifest egen-
|
|
13
|
+
Usage : egen-embed-sim --app <url> [--manifest egen-config.json] [--port 4100] [--strict] [--session session.json]
|
|
14
14
|
|
|
15
15
|
--app URL de l'app embarquée (ex. http://localhost:3000)
|
|
16
|
-
--manifest manifeste egen-
|
|
16
|
+
--manifest manifeste egen-config.json de l'app (les capacités demandées sont approuvées, sauf --strict)
|
|
17
17
|
--strict n'approuver que les capacités « par défaut » (voir doc 17 §5)
|
|
18
18
|
--session fichier JSON de la session simulée`);
|
|
19
19
|
process.exit(opt('--app') ? 0 : 1);
|
package/dist/check.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export interface CheckIssue {
|
|
|
3
3
|
message: string;
|
|
4
4
|
}
|
|
5
5
|
export interface CheckOptions {
|
|
6
|
-
/**
|
|
6
|
+
/** Déclaration `egen-config.json` déjà lue. */
|
|
7
7
|
manifest: unknown;
|
|
8
8
|
/** Origine du Shell EGEN (ex. `https://egen.exemple.org`) : active le contrôle d'intégration en iframe. */
|
|
9
9
|
shellOrigin?: string;
|
package/dist/check.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../src/check.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../src/check.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,+CAA+C;IAC/C,QAAQ,EAAE,OAAO,CAAC;IAClB,2GAA2G;IAC3G,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2FAA2F;IAC3F,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B;AAED,+HAA+H;AAC/H,wBAAsB,aAAa,CAAC,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CA8D1E;AAED,eAAO,MAAM,SAAS,GAAI,QAAQ,UAAU,EAAE,YAA4C,CAAC"}
|
package/dist/check.js
CHANGED
|
@@ -35,12 +35,40 @@ function _async_to_generator(fn) {
|
|
|
35
35
|
});
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
+
function _define_property(obj, key, value) {
|
|
39
|
+
if (key in obj) {
|
|
40
|
+
Object.defineProperty(obj, key, {
|
|
41
|
+
value: value,
|
|
42
|
+
enumerable: true,
|
|
43
|
+
configurable: true,
|
|
44
|
+
writable: true
|
|
45
|
+
});
|
|
46
|
+
} else {
|
|
47
|
+
obj[key] = value;
|
|
48
|
+
}
|
|
49
|
+
return obj;
|
|
50
|
+
}
|
|
38
51
|
function _iterable_to_array(iter) {
|
|
39
52
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
40
53
|
}
|
|
41
54
|
function _non_iterable_spread() {
|
|
42
55
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
43
56
|
}
|
|
57
|
+
function _object_spread(target) {
|
|
58
|
+
for(var i = 1; i < arguments.length; i++){
|
|
59
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
60
|
+
var ownKeys = Object.keys(source);
|
|
61
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
62
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
63
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
ownKeys.forEach(function(key) {
|
|
67
|
+
_define_property(target, key, source[key]);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return target;
|
|
71
|
+
}
|
|
44
72
|
function _to_consumable_array(arr) {
|
|
45
73
|
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
46
74
|
}
|
|
@@ -152,9 +180,15 @@ function _ts_generator(thisArg, body) {
|
|
|
152
180
|
}
|
|
153
181
|
}
|
|
154
182
|
import { CAPABILITIES, patternCovers, validateManifest } from '@egen-civitas/esm-embed-protocol';
|
|
183
|
+
/** Permissions `allow` donnant accès à des capteurs ou à l'écran de l'utilisateur. */ var SENSITIVE_PERMISSIONS = new Set([
|
|
184
|
+
'camera',
|
|
185
|
+
'microphone',
|
|
186
|
+
'geolocation',
|
|
187
|
+
'display-capture'
|
|
188
|
+
]);
|
|
155
189
|
/** Vérificateur d'app embarquée (`egen-embed-check`) : manifeste, hygiène des capacités demandées, intégrabilité en iframe. */ export function checkEmbedApp(o) {
|
|
156
190
|
return _async_to_generator(function() {
|
|
157
|
-
var _m_extensions, _m_extensions1, _caps_events, _caps_extensions, issues, add, r, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _$e, m, caps, needApproval, pub, own, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, p, slots, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _$e1, discover, _o_fetchImpl, f, _res_headers_get, _exec_, _exec, res, xfo, csp, fa, tokens, e;
|
|
191
|
+
var _ref, _ref1, _m_extensions, _m_extensions1, _caps_events, _asked_sandbox, _asked_allow, _caps_extensions, issues, add, r, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _$e, m, caps, needApproval, pub, own, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, p, asked, _asked_sandbox1, _asked_allow1, _asked_allow2, list, sensitive, slots, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _$e1, discover, _o_fetchImpl, f, _res_headers_get, _exec_, _exec, res, xfo, csp, fa, tokens, e;
|
|
158
192
|
return _ts_generator(this, function(_state) {
|
|
159
193
|
switch(_state.label){
|
|
160
194
|
case 0:
|
|
@@ -226,6 +260,20 @@ import { CAPABILITIES, patternCovers, validateManifest } from '@egen-civitas/esm
|
|
|
226
260
|
}
|
|
227
261
|
}
|
|
228
262
|
if (caps.notifications) add('info', "Notifications : le Core affiche les toasts (par défaut seul). N'affichez pas les vôtres : appelez egen.notify(toast, local) et ne rendez votre composant de toasts que si !egen.coreDisplaysNotifications");
|
|
263
|
+
asked = m.iframe;
|
|
264
|
+
if (asked && (((_ref = (_asked_sandbox = asked.sandbox) === null || _asked_sandbox === void 0 ? void 0 : _asked_sandbox.length) !== null && _ref !== void 0 ? _ref : 0) > 0 || ((_ref1 = (_asked_allow = asked.allow) === null || _asked_allow === void 0 ? void 0 : _asked_allow.length) !== null && _ref1 !== void 0 ? _ref1 : 0) > 0)) {
|
|
265
|
+
;
|
|
266
|
+
list = _to_consumable_array(((_asked_sandbox1 = asked.sandbox) !== null && _asked_sandbox1 !== void 0 ? _asked_sandbox1 : []).map(function(t) {
|
|
267
|
+
return "sandbox:".concat(t);
|
|
268
|
+
})).concat(_to_consumable_array(((_asked_allow1 = asked.allow) !== null && _asked_allow1 !== void 0 ? _asked_allow1 : []).map(function(t) {
|
|
269
|
+
return "allow:".concat(t);
|
|
270
|
+
})));
|
|
271
|
+
add('info', "Droits d'iframe demand\xe9s : l'op\xe9rateur doit les approuver (grants.iframe), sinon ils seront refus\xe9s : ".concat(list.join(', ')));
|
|
272
|
+
sensitive = ((_asked_allow2 = asked.allow) !== null && _asked_allow2 !== void 0 ? _asked_allow2 : []).filter(function(t) {
|
|
273
|
+
return SENSITIVE_PERMISSIONS.has(t);
|
|
274
|
+
});
|
|
275
|
+
if (sensitive.length) add('warn', "Permissions sensibles demand\xe9es (".concat(sensitive.join(', '), ") : \xe0 justifier aupr\xe8s de l'op\xe9rateur, elles ne sont jamais accord\xe9es par d\xe9faut"));
|
|
276
|
+
}
|
|
229
277
|
slots = _to_consumable_array(new Set(((_m_extensions = m.extensions) !== null && _m_extensions !== void 0 ? _m_extensions : []).map(function(e) {
|
|
230
278
|
return e.slot;
|
|
231
279
|
})));
|
|
@@ -257,7 +305,7 @@ import { CAPABILITIES, patternCovers, validateManifest } from '@egen-civitas/esm
|
|
|
257
305
|
if (m.technology === 'nextjs' && m.navigation.mode === 'none') add('info', 'Next.js avec navigation « none » : l’URL du Core ne reflétera pas la page courante (partage de lien, F5)');
|
|
258
306
|
if (!o.probe) return [
|
|
259
307
|
3,
|
|
260
|
-
|
|
308
|
+
6
|
|
261
309
|
];
|
|
262
310
|
f = (_o_fetchImpl = o.fetchImpl) !== null && _o_fetchImpl !== void 0 ? _o_fetchImpl : fetch;
|
|
263
311
|
_state.label = 1;
|
|
@@ -301,6 +349,16 @@ import { CAPABILITIES, patternCovers, validateManifest } from '@egen-civitas/esm
|
|
|
301
349
|
4
|
|
302
350
|
];
|
|
303
351
|
case 4:
|
|
352
|
+
return [
|
|
353
|
+
4,
|
|
354
|
+
probeDeclaration(f, m, add, {
|
|
355
|
+
allowInsecureLocalhost: o.allowInsecureLocalhost
|
|
356
|
+
})
|
|
357
|
+
];
|
|
358
|
+
case 5:
|
|
359
|
+
_state.sent();
|
|
360
|
+
_state.label = 6;
|
|
361
|
+
case 6:
|
|
304
362
|
return [
|
|
305
363
|
2,
|
|
306
364
|
issues
|
|
@@ -314,3 +372,121 @@ export var hasErrors = function hasErrors(issues) {
|
|
|
314
372
|
return i.level === 'error';
|
|
315
373
|
});
|
|
316
374
|
};
|
|
375
|
+
var sameJson = function sameJson(a, b) {
|
|
376
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
377
|
+
};
|
|
378
|
+
/**
|
|
379
|
+
* Voie normale (doc 17 §7) : l'app sert elle-même `<url>/egen-config.json`. On vérifie qu'il est publié, valide,
|
|
380
|
+
* identique à la déclaration contrôlée, et jamais mis en cache (le Core en fige le SHA-256).
|
|
381
|
+
*/ function probeDeclaration(f, m, add, manifestOptions) {
|
|
382
|
+
return _async_to_generator(function() {
|
|
383
|
+
var declared, _res_headers_get, res, served, unused, result, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _$e, drift, cache, e;
|
|
384
|
+
return _ts_generator(this, function(_state) {
|
|
385
|
+
switch(_state.label){
|
|
386
|
+
case 0:
|
|
387
|
+
declared = "".concat(m.url.replace(/\/+$/, ''), "/egen-config.json");
|
|
388
|
+
_state.label = 1;
|
|
389
|
+
case 1:
|
|
390
|
+
_state.trys.push([
|
|
391
|
+
1,
|
|
392
|
+
7,
|
|
393
|
+
,
|
|
394
|
+
8
|
|
395
|
+
]);
|
|
396
|
+
return [
|
|
397
|
+
4,
|
|
398
|
+
f(declared, {
|
|
399
|
+
redirect: 'manual',
|
|
400
|
+
signal: AbortSignal.timeout(10000)
|
|
401
|
+
})
|
|
402
|
+
];
|
|
403
|
+
case 2:
|
|
404
|
+
res = _state.sent();
|
|
405
|
+
if (res.status === 404) {
|
|
406
|
+
add('info', "/egen-config.json n'est pas publié à la racine de l'app : voie normale = l'app sert sa déclaration ; sinon l'opérateur la déclare côté Core (second recours, `declaration` dans external-apps.json)");
|
|
407
|
+
return [
|
|
408
|
+
2
|
|
409
|
+
];
|
|
410
|
+
}
|
|
411
|
+
if (res.status >= 300) {
|
|
412
|
+
add('warn', "/egen-config.json r\xe9pond HTTP ".concat(res.status, " : le Core doit pouvoir le lire directement (pas de redirection)"));
|
|
413
|
+
return [
|
|
414
|
+
2
|
|
415
|
+
];
|
|
416
|
+
}
|
|
417
|
+
_state.label = 3;
|
|
418
|
+
case 3:
|
|
419
|
+
_state.trys.push([
|
|
420
|
+
3,
|
|
421
|
+
5,
|
|
422
|
+
,
|
|
423
|
+
6
|
|
424
|
+
]);
|
|
425
|
+
return [
|
|
426
|
+
4,
|
|
427
|
+
res.json()
|
|
428
|
+
];
|
|
429
|
+
case 4:
|
|
430
|
+
served = _state.sent();
|
|
431
|
+
return [
|
|
432
|
+
3,
|
|
433
|
+
6
|
|
434
|
+
];
|
|
435
|
+
case 5:
|
|
436
|
+
unused = _state.sent();
|
|
437
|
+
add('error', '/egen-config.json publié : JSON invalide');
|
|
438
|
+
return [
|
|
439
|
+
2
|
|
440
|
+
];
|
|
441
|
+
case 6:
|
|
442
|
+
result = validateManifest(served, manifestOptions);
|
|
443
|
+
if (!result.ok) {
|
|
444
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
445
|
+
try {
|
|
446
|
+
for(_iterator = result.errors[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
447
|
+
_$e = _step.value;
|
|
448
|
+
add('error', "/egen-config.json publi\xe9 invalide : ".concat(_$e));
|
|
449
|
+
}
|
|
450
|
+
} catch (err) {
|
|
451
|
+
_didIteratorError = true;
|
|
452
|
+
_iteratorError = err;
|
|
453
|
+
} finally{
|
|
454
|
+
try {
|
|
455
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
456
|
+
_iterator.return();
|
|
457
|
+
}
|
|
458
|
+
} finally{
|
|
459
|
+
if (_didIteratorError) {
|
|
460
|
+
throw _iteratorError;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
return [
|
|
465
|
+
2
|
|
466
|
+
];
|
|
467
|
+
}
|
|
468
|
+
drift = Object.keys(_object_spread({}, m, result.manifest)).filter(function(k) {
|
|
469
|
+
return !sameJson(m[k], result.manifest[k]);
|
|
470
|
+
});
|
|
471
|
+
if (drift.length) add('warn', "La d\xe9claration publi\xe9e diff\xe8re de celle contr\xf4l\xe9e (champs : ".concat(drift.join(', '), ")"));
|
|
472
|
+
cache = (_res_headers_get = res.headers.get('cache-control')) !== null && _res_headers_get !== void 0 ? _res_headers_get : '';
|
|
473
|
+
if (!/no-store|no-cache|max-age=0/i.test(cache)) add('info', "/egen-config.json sans « Cache-Control: no-store » : le Core fige son SHA-256, une version en cache provoque un rejet au démarrage");
|
|
474
|
+
return [
|
|
475
|
+
3,
|
|
476
|
+
8
|
|
477
|
+
];
|
|
478
|
+
case 7:
|
|
479
|
+
e = _state.sent();
|
|
480
|
+
add('warn', "/egen-config.json injoignable (".concat(e.message, ")"));
|
|
481
|
+
return [
|
|
482
|
+
3,
|
|
483
|
+
8
|
|
484
|
+
];
|
|
485
|
+
case 8:
|
|
486
|
+
return [
|
|
487
|
+
2
|
|
488
|
+
];
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
})();
|
|
492
|
+
}
|
package/dist/server.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export interface SimulatorOptions {
|
|
|
4
4
|
app: string;
|
|
5
5
|
port?: number;
|
|
6
6
|
host?: string;
|
|
7
|
-
/**
|
|
7
|
+
/** Déclaration `egen-config.json` de l'app (objet déjà lu). Sans manifeste : l'opérateur simulé définit seul. */
|
|
8
8
|
manifest?: unknown;
|
|
9
9
|
/** Approuver toutes les capacités demandées (défaut) ou seulement celles « par défaut » (`strict`). */
|
|
10
10
|
strict?: boolean;
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AAOtD,MAAM,WAAW,gBAAgB;IAC/B,4DAA4D;IAC5D,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AAOtD,MAAM,WAAW,gBAAgB;IAC/B,4DAA4D;IAC5D,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iHAAiH;IACjH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uGAAuG;IACvG,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAoBD,wBAAsB,cAAc,CAAC,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CA0C5E"}
|
package/dist/server.js
CHANGED
|
@@ -164,6 +164,8 @@ function approvedFor(manifest, strict) {
|
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
+
// droits d'iframe : la demande de l'app est approuvée telle quelle (le simulateur joue l'opérateur indulgent)
|
|
168
|
+
if (manifest.iframe) out.iframe = manifest.iframe;
|
|
167
169
|
return out;
|
|
168
170
|
}
|
|
169
171
|
export function startSimulator(o) {
|
|
@@ -184,6 +186,7 @@ export function startSimulator(o) {
|
|
|
184
186
|
app: appUrl.href,
|
|
185
187
|
moduleName: (_ref = manifest === null || manifest === void 0 ? void 0 : manifest.name) !== null && _ref !== void 0 ? _ref : '@acme/esm-sim-app',
|
|
186
188
|
manifestCapabilities: manifest === null || manifest === void 0 ? void 0 : manifest.capabilities,
|
|
189
|
+
manifestIframe: manifest === null || manifest === void 0 ? void 0 : manifest.iframe,
|
|
187
190
|
approved: approvedFor(manifest, !!o.strict),
|
|
188
191
|
extensions: {
|
|
189
192
|
'topbar-nav-slot': [
|
|
@@ -310,4 +313,4 @@ export function startSimulator(o) {
|
|
|
310
313
|
});
|
|
311
314
|
})();
|
|
312
315
|
}
|
|
313
|
-
var PAGE = "<!doctype html><html lang=\"fr\"><head><meta charset=\"utf-8\"><title>EGEN — simulateur de Shell</title>\n<meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n<script type=\"importmap\">{\"imports\":{\"@egen-civitas/esm-embed-protocol\":\"/vendor/protocol/index.js\"}}</script>\n<style>\n:root{color-scheme:light dark;--b:#d0d7de;font-family:system-ui,sans-serif}\nbody{margin:0;display:grid;grid-template-columns:1fr 360px;height:100vh}\n#stage{min-width:0;display:flex}#stage iframe{flex:1;border:0}\naside{border-left:1px solid var(--b);padding:12px;overflow:auto;font-size:13px}\nbutton{margin:2px 4px 2px 0;padding:4px 8px;cursor:pointer}\npre{white-space:pre-wrap;word-break:break-word;font-size:12px;max-height:50vh;overflow:auto;border:1px solid var(--b);padding:6px;border-radius:6px}\n.toast{border:1px solid var(--b);border-radius:6px;padding:6px;margin:4px 0}\nh1{font-size:14px;margin:0 0 8px}h2{font-size:12px;margin:12px 0 4px;text-transform:uppercase;opacity:.7}\n</style></head><body>\n<div id=\"stage\"></div>\n<aside><h1>Simulateur de Shell EGEN</h1>\n<div id=\"info\"></div>\n<h2>Pousser vers l'app</h2>\n<button id=\"locale\">Langue fr/en</button><button id=\"event\">\xc9v\xe9nement core.sim.ping</button><button id=\"ext\">Changer les extensions de topbar-nav-slot</button>\n<h2>Notifications</h2><div id=\"toasts\"></div>\n<h2>Journal des \xe9changes</h2><pre id=\"log\"></pre></aside>\n<script type=\"module\">\nimport { effectiveGrants } from '@egen-civitas/esm-embed-protocol';\nimport { createEmbedHost } from '/vendor/host/index.js';\nconst cfg = await (await fetch('/api/config')).json();\nconst $ = (id) => document.getElementById(id);\nconst log = (...a) => { $('log').textContent = new Date().toLocaleTimeString() + ' ' + a.map((x) => typeof x === 'string' ? x : JSON.stringify(x)).join(' ') + '\\n' + $('log').textContent; };\nconst watch = (v) => { const s = new Set(); return { get: () => v, subscribe: (cb) => (s.add(cb), () => s.delete(cb)), set: (n) => { v = n; s.forEach((f) => f(n)); } }; };\nconst locale = watch('fr'), tenant = watch({ id: 'sim-tenant' }), conf = watch({});\nconst topics = new Map(), seenToasts = new Set();\nconst extState = new Map(Object.entries(cfg.extensions)), extSubs = new Map();\nconst wrap = (cap, p) => Object.fromEntries(Object.entries(p).map(([k, f]) => [k, typeof f === 'function' ? (...a) => { log('←', cap + '.' + k, a); return f(...a); } : f]));\nconst providers = {\n locale: wrap('locale', locale), tenant: wrap('tenant', tenant), config: wrap('config', conf),\n flags: wrap('flags', { isEnabled: () => true }),\n extensions: { list: (slot) => { log('← extensions.list', slot); return extState.get(slot) || []; }, subscribe: (slot, cb) => { const s = extSubs.get(slot) || new Set(); s.add(cb); extSubs.set(slot, s); return () => s.delete(cb); } },\n events: { publish: (t, p, c) => { log('← events.publish', t, p, 'de', c.moduleName); (topics.get(t) || []).forEach((f) => f(p)); }, subscribe: (t, cb) => { log('← events.subscribe', t); const l = topics.get(t) || []; l.push(cb); topics.set(t, l); return () => topics.set(t, (topics.get(t) || []).filter((f) => f !== cb)); } },\n notifications: { show: (n, c) => { log('← notifications.show', n, 'de', c.moduleName); if (n.id && seenToasts.has(n.id)) return false; if (n.id) seenToasts.add(n.id); const d = document.createElement('div'); d.className = 'toast'; d.textContent = '[' + n.kind + '] ' + cfg.moduleName + ' \xb7 ' + n.title + (n.subtitle ? ' — ' + n.subtitle : ''); $('toasts').prepend(d); return true; } },\n dialogs: { confirm: (d) => { log('← dialogs.confirm', d); return confirm(d.title + '\\n\\n' + d.message); } },\n telemetry: { log: (...a) => log('← telemetry.log', a.slice(0, 3)), metric: (...a) => log('← telemetry.metric', a.slice(0, 3)) },\n};\nconst grants = effectiveGrants(cfg.manifestCapabilities, cfg.approved);\n$('info').innerHTML = '<b>App</b> ' + cfg.app + '<br><b>Module</b> ' + cfg.moduleName + '<br><b>hostOrigins \xe0 d\xe9clarer dans l’app</b> <code>' + location.origin + '</code><br><b>Capacit\xe9s accord\xe9es</b> ' + Object.keys(grants).join(', ');\nconst host = createEmbedHost({ moduleName: cfg.moduleName, src: cfg.app, grants, providers, onConnect: (g, d) => log('✔ connect\xe9', { accord\xe9es: g.map((x) => x.id), refus\xe9es: d }), onClose: (r) => log('✖ ferm\xe9', r) });\nhost.mount($('stage'));\n$('locale').onclick = () => locale.set(locale.get() === 'fr' ? 'en' : 'fr');\n$('event').onclick = () => (topics.get('core.sim.ping') || []).forEach((f) => f({ at: Date.now() }));\n$('ext').onclick = () => { const n = [{ name: 'nav-' + Math.floor(Math.random() * 100), moduleName: '@egen/esm-demo-app', meta: { label: 'Nouvelle extension' } }]; extState.set('topbar-nav-slot', n); (extSubs.get('topbar-nav-slot') || []).forEach((f) => f(n)); };\n</script></body></html>";
|
|
316
|
+
var PAGE = "<!doctype html><html lang=\"fr\"><head><meta charset=\"utf-8\"><title>EGEN — simulateur de Shell</title>\n<meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n<script type=\"importmap\">{\"imports\":{\"@egen-civitas/esm-embed-protocol\":\"/vendor/protocol/index.js\"}}</script>\n<style>\n:root{color-scheme:light dark;--b:#d0d7de;font-family:system-ui,sans-serif}\nbody{margin:0;display:grid;grid-template-columns:1fr 360px;height:100vh}\n#stage{min-width:0;display:flex}#stage iframe{flex:1;border:0}\naside{border-left:1px solid var(--b);padding:12px;overflow:auto;font-size:13px}\nbutton{margin:2px 4px 2px 0;padding:4px 8px;cursor:pointer}\npre{white-space:pre-wrap;word-break:break-word;font-size:12px;max-height:50vh;overflow:auto;border:1px solid var(--b);padding:6px;border-radius:6px}\n.toast{border:1px solid var(--b);border-radius:6px;padding:6px;margin:4px 0}\nh1{font-size:14px;margin:0 0 8px}h2{font-size:12px;margin:12px 0 4px;text-transform:uppercase;opacity:.7}\n</style></head><body>\n<div id=\"stage\"></div>\n<aside><h1>Simulateur de Shell EGEN</h1>\n<div id=\"info\"></div>\n<h2>Pousser vers l'app</h2>\n<button id=\"locale\">Langue fr/en</button><button id=\"event\">\xc9v\xe9nement core.sim.ping</button><button id=\"ext\">Changer les extensions de topbar-nav-slot</button>\n<h2>Notifications</h2><div id=\"toasts\"></div>\n<h2>Journal des \xe9changes</h2><pre id=\"log\"></pre></aside>\n<script type=\"module\">\nimport { effectiveGrants, effectiveIframe } from '@egen-civitas/esm-embed-protocol';\nimport { createEmbedHost } from '/vendor/host/index.js';\nconst cfg = await (await fetch('/api/config')).json();\nconst $ = (id) => document.getElementById(id);\nconst log = (...a) => { $('log').textContent = new Date().toLocaleTimeString() + ' ' + a.map((x) => typeof x === 'string' ? x : JSON.stringify(x)).join(' ') + '\\n' + $('log').textContent; };\nconst watch = (v) => { const s = new Set(); return { get: () => v, subscribe: (cb) => (s.add(cb), () => s.delete(cb)), set: (n) => { v = n; s.forEach((f) => f(n)); } }; };\nconst locale = watch('fr'), tenant = watch({ id: 'sim-tenant' }), conf = watch({});\nconst topics = new Map(), seenToasts = new Set();\nconst extState = new Map(Object.entries(cfg.extensions)), extSubs = new Map();\nconst wrap = (cap, p) => Object.fromEntries(Object.entries(p).map(([k, f]) => [k, typeof f === 'function' ? (...a) => { log('←', cap + '.' + k, a); return f(...a); } : f]));\nconst providers = {\n locale: wrap('locale', locale), tenant: wrap('tenant', tenant), config: wrap('config', conf),\n flags: wrap('flags', { isEnabled: () => true }),\n extensions: { list: (slot) => { log('← extensions.list', slot); return extState.get(slot) || []; }, subscribe: (slot, cb) => { const s = extSubs.get(slot) || new Set(); s.add(cb); extSubs.set(slot, s); return () => s.delete(cb); } },\n events: { publish: (t, p, c) => { log('← events.publish', t, p, 'de', c.moduleName); (topics.get(t) || []).forEach((f) => f(p)); }, subscribe: (t, cb) => { log('← events.subscribe', t); const l = topics.get(t) || []; l.push(cb); topics.set(t, l); return () => topics.set(t, (topics.get(t) || []).filter((f) => f !== cb)); } },\n notifications: { show: (n, c) => { log('← notifications.show', n, 'de', c.moduleName); if (n.id && seenToasts.has(n.id)) return false; if (n.id) seenToasts.add(n.id); const d = document.createElement('div'); d.className = 'toast'; d.textContent = '[' + n.kind + '] ' + cfg.moduleName + ' \xb7 ' + n.title + (n.subtitle ? ' — ' + n.subtitle : ''); $('toasts').prepend(d); return true; } },\n dialogs: { confirm: (d) => { log('← dialogs.confirm', d); return confirm(d.title + '\\n\\n' + d.message); } },\n telemetry: { log: (...a) => log('← telemetry.log', a.slice(0, 3)), metric: (...a) => log('← telemetry.metric', a.slice(0, 3)) },\n};\nconst grants = effectiveGrants(cfg.manifestCapabilities, cfg.approved);\nconst iframe = effectiveIframe(cfg.manifestIframe, cfg.approved.iframe);\n$('info').innerHTML = '<b>App</b> ' + cfg.app + '<br><b>Module</b> ' + cfg.moduleName + '<br><b>hostOrigins \xe0 d\xe9clarer dans l’app</b> <code>' + location.origin + '</code><br><b>Capacit\xe9s accord\xe9es</b> ' + Object.keys(grants).join(', ') + '<br><b>Droits d’iframe accord\xe9s</b> ' + (iframe.sandbox.concat(iframe.allow).join(', ') || 'socle seul');\nconst host = createEmbedHost({ moduleName: cfg.moduleName, src: cfg.app, grants, iframe, providers, onConnect: (g, d) => log('✔ connect\xe9', { accord\xe9es: g.map((x) => x.id), refus\xe9es: d }), onClose: (r) => log('✖ ferm\xe9', r) });\nhost.mount($('stage'));\n$('locale').onclick = () => locale.set(locale.get() === 'fr' ? 'en' : 'fr');\n$('event').onclick = () => (topics.get('core.sim.ping') || []).forEach((f) => f({ at: Date.now() }));\n$('ext').onclick = () => { const n = [{ name: 'nav-' + Math.floor(Math.random() * 100), moduleName: '@egen/esm-demo-app', meta: { label: 'Nouvelle extension' } }]; extState.set('topbar-nav-slot', n); (extSubs.get('topbar-nav-slot') || []).forEach((f) => f(n)); };\n</script></body></html>";
|
package/dist/test-host.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ApprovedGrants, type CapabilityId, type GrantConfig } from '@egen-civitas/esm-embed-protocol';
|
|
1
|
+
import { type ApprovedGrants, type CapabilityId, type EffectiveIframeRights, type GrantConfig, type IframeRights } from '@egen-civitas/esm-embed-protocol';
|
|
2
2
|
import type { ConnectOptions } from '@egen-civitas/esm-embed-client';
|
|
3
3
|
import { HostConnection, type ExtensionInfo } from '@egen-civitas/esm-embed-host';
|
|
4
4
|
export interface TestHostOptions {
|
|
@@ -7,7 +7,9 @@ export interface TestHostOptions {
|
|
|
7
7
|
origin?: string;
|
|
8
8
|
/** Capacités demandées par le manifeste de l'app (défaut : aucune demande explicite = l'opérateur définit seul). */
|
|
9
9
|
manifestCapabilities?: Partial<Record<CapabilityId, GrantConfig>>;
|
|
10
|
-
/**
|
|
10
|
+
/** Droits d'iframe demandés par l'app (`iframe` de `egen-config.json`). */
|
|
11
|
+
manifestIframe?: IframeRights;
|
|
12
|
+
/** Plafond fixé par l'opérateur (défaut : rien d'approuvé hors capacités « par défaut » ; `iframe` : plafond des droits d'iframe). */
|
|
11
13
|
approved?: ApprovedGrants;
|
|
12
14
|
tenant?: {
|
|
13
15
|
id: string | null;
|
|
@@ -32,6 +34,8 @@ export interface TestHost {
|
|
|
32
34
|
/** À passer à `connectToEgen({ ...host.connectOptions, capabilities: [...] })`. */
|
|
33
35
|
connectOptions: Pick<ConnectOptions, 'moduleName' | 'hostOrigins' | 'window' | 'host' | 'timeoutMs'>;
|
|
34
36
|
connection: HostConnection;
|
|
37
|
+
/** Droits d'iframe que le Core appliquerait (`demande ∩ plafond`) : de quoi vérifier ce que l'app obtient réellement. */
|
|
38
|
+
iframe: EffectiveIframeRights;
|
|
35
39
|
/** Journal des services du Core sollicités par l'app. */
|
|
36
40
|
calls: CallRecord[];
|
|
37
41
|
notifications: Array<{
|
package/dist/test-host.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-host.d.ts","sourceRoot":"","sources":["../src/test-host.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"test-host.d.ts","sourceRoot":"","sources":["../src/test-host.ts"],"names":[],"mappings":"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"}
|
package/dist/test-host.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { effectiveGrants } from '@egen-civitas/esm-embed-protocol';
|
|
1
|
+
import { effectiveGrants, effectiveIframe } from '@egen-civitas/esm-embed-protocol';
|
|
2
2
|
import { createBus, HostConnection } from '@egen-civitas/esm-embed-host';
|
|
3
3
|
function watchable(initial) {
|
|
4
4
|
var value = initial;
|
|
@@ -31,6 +31,7 @@ function watchable(initial) {
|
|
|
31
31
|
*/ export function createTestHost() {
|
|
32
32
|
var o = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
33
33
|
var _o_moduleName, _o_origin, _o_tenant, _o_locale, _o_extensions, _o_config, _o_approved;
|
|
34
|
+
var _o_approved1;
|
|
34
35
|
var moduleName = (_o_moduleName = o.moduleName) !== null && _o_moduleName !== void 0 ? _o_moduleName : '@acme/esm-test-app';
|
|
35
36
|
var origin = (_o_origin = o.origin) !== null && _o_origin !== void 0 ? _o_origin : 'https://shell.test';
|
|
36
37
|
var calls = [];
|
|
@@ -196,6 +197,7 @@ function watchable(initial) {
|
|
|
196
197
|
timeoutMs: 500
|
|
197
198
|
},
|
|
198
199
|
connection: connection,
|
|
200
|
+
iframe: effectiveIframe(o.manifestIframe, (_o_approved1 = o.approved) === null || _o_approved1 === void 0 ? void 0 : _o_approved1.iframe),
|
|
199
201
|
calls: calls,
|
|
200
202
|
notifications: notifications,
|
|
201
203
|
published: published,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@egen-civitas/esm-embed-testing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "Développer et tester une app embarquée sans le Core : hôte de test en mémoire, suite de conformité du protocole v2, simulateur de Shell (egen-embed-sim).",
|
|
6
6
|
"type": "module",
|
|
@@ -76,9 +76,9 @@
|
|
|
76
76
|
"vitest": "^4.1.2"
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
|
-
"@egen-civitas/esm-embed-client": "^0.3.
|
|
80
|
-
"@egen-civitas/esm-embed-host": "^0.
|
|
81
|
-
"@egen-civitas/esm-embed-protocol": "^0.
|
|
79
|
+
"@egen-civitas/esm-embed-client": "^0.3.1",
|
|
80
|
+
"@egen-civitas/esm-embed-host": "^0.5.0",
|
|
81
|
+
"@egen-civitas/esm-embed-protocol": "^0.5.1"
|
|
82
82
|
},
|
|
83
83
|
"bin": {
|
|
84
84
|
"egen-embed-check": "bin/egen-embed-check.mjs",
|
package/src/check.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { CAPABILITIES, patternCovers, validateManifest, type EmbedManifest } from '@egen-civitas/esm-embed-protocol';
|
|
2
2
|
|
|
3
|
+
/** Permissions `allow` donnant accès à des capteurs ou à l'écran de l'utilisateur. */
|
|
4
|
+
const SENSITIVE_PERMISSIONS = new Set(['camera', 'microphone', 'geolocation', 'display-capture']);
|
|
5
|
+
|
|
3
6
|
export interface CheckIssue {
|
|
4
7
|
level: 'error' | 'warn' | 'info';
|
|
5
8
|
message: string;
|
|
6
9
|
}
|
|
7
10
|
|
|
8
11
|
export interface CheckOptions {
|
|
9
|
-
/**
|
|
12
|
+
/** Déclaration `egen-config.json` déjà lue. */
|
|
10
13
|
manifest: unknown;
|
|
11
14
|
/** Origine du Shell EGEN (ex. `https://egen.exemple.org`) : active le contrôle d'intégration en iframe. */
|
|
12
15
|
shellOrigin?: string;
|
|
@@ -42,6 +45,13 @@ export async function checkEmbedApp(o: CheckOptions): Promise<CheckIssue[]> {
|
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
if (caps.notifications) add('info', "Notifications : le Core affiche les toasts (par défaut seul). N'affichez pas les vôtres : appelez egen.notify(toast, local) et ne rendez votre composant de toasts que si !egen.coreDisplaysNotifications");
|
|
48
|
+
const asked = m.iframe;
|
|
49
|
+
if (asked && ((asked.sandbox?.length ?? 0) > 0 || (asked.allow?.length ?? 0) > 0)) {
|
|
50
|
+
const list = [...(asked.sandbox ?? []).map((t) => `sandbox:${t}`), ...(asked.allow ?? []).map((t) => `allow:${t}`)];
|
|
51
|
+
add('info', `Droits d'iframe demandés : l'opérateur doit les approuver (grants.iframe), sinon ils seront refusés : ${list.join(', ')}`);
|
|
52
|
+
const sensitive = (asked.allow ?? []).filter((t) => SENSITIVE_PERMISSIONS.has(t));
|
|
53
|
+
if (sensitive.length) add('warn', `Permissions sensibles demandées (${sensitive.join(', ')}) : à justifier auprès de l'opérateur, elles ne sont jamais accordées par défaut`);
|
|
54
|
+
}
|
|
45
55
|
const slots = [...new Set((m.extensions ?? []).map((e) => e.slot))];
|
|
46
56
|
if (slots.length) add('info', `Contributions d'extension : l'opérateur doit approuver les slots (extensions.contribute) : ${slots.join(', ')}`);
|
|
47
57
|
for (const e of m.extensions ?? []) if (e.view) add('info', `Extension « ${e.name} » : la vue ${e.view} sera affichée dans une iframe du Core (frame-ancestors à autoriser pour le Shell, hauteur via navigation.resize)`);
|
|
@@ -69,8 +79,55 @@ export async function checkEmbedApp(o: CheckOptions): Promise<CheckIssue[]> {
|
|
|
69
79
|
} catch (e) {
|
|
70
80
|
add('warn', `URL de l'app injoignable (${(e as Error).message})`);
|
|
71
81
|
}
|
|
82
|
+
await probeDeclaration(f, m, add, { allowInsecureLocalhost: o.allowInsecureLocalhost });
|
|
72
83
|
}
|
|
73
84
|
return issues;
|
|
74
85
|
}
|
|
75
86
|
|
|
76
87
|
export const hasErrors = (issues: CheckIssue[]) => issues.some((i) => i.level === 'error');
|
|
88
|
+
|
|
89
|
+
const sameJson = (a: unknown, b: unknown) => JSON.stringify(a) === JSON.stringify(b);
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Voie normale (doc 17 §7) : l'app sert elle-même `<url>/egen-config.json`. On vérifie qu'il est publié, valide,
|
|
93
|
+
* identique à la déclaration contrôlée, et jamais mis en cache (le Core en fige le SHA-256).
|
|
94
|
+
*/
|
|
95
|
+
async function probeDeclaration(
|
|
96
|
+
f: typeof fetch,
|
|
97
|
+
m: EmbedManifest,
|
|
98
|
+
add: (level: CheckIssue['level'], message: string) => void,
|
|
99
|
+
manifestOptions: Parameters<typeof validateManifest>[1]
|
|
100
|
+
): Promise<void> {
|
|
101
|
+
const declared = `${m.url.replace(/\/+$/, '')}/egen-config.json`;
|
|
102
|
+
try {
|
|
103
|
+
const res = await f(declared, { redirect: 'manual', signal: AbortSignal.timeout(10_000) });
|
|
104
|
+
if (res.status === 404) {
|
|
105
|
+
add('info', "/egen-config.json n'est pas publié à la racine de l'app : voie normale = l'app sert sa déclaration ; sinon l'opérateur la déclare côté Core (second recours, `declaration` dans external-apps.json)");
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (res.status >= 300) {
|
|
109
|
+
add('warn', `/egen-config.json répond HTTP ${res.status} : le Core doit pouvoir le lire directement (pas de redirection)`);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
let served: unknown;
|
|
113
|
+
try {
|
|
114
|
+
served = await res.json();
|
|
115
|
+
} catch {
|
|
116
|
+
add('error', '/egen-config.json publié : JSON invalide');
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const result = validateManifest(served, manifestOptions);
|
|
120
|
+
if (!result.ok) {
|
|
121
|
+
for (const e of result.errors) add('error', `/egen-config.json publié invalide : ${e}`);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const drift = Object.keys({ ...(m as object), ...(result.manifest as object) }).filter(
|
|
125
|
+
(k) => !sameJson((m as unknown as Record<string, unknown>)[k], (result.manifest as unknown as Record<string, unknown>)[k])
|
|
126
|
+
);
|
|
127
|
+
if (drift.length) add('warn', `La déclaration publiée diffère de celle contrôlée (champs : ${drift.join(', ')})`);
|
|
128
|
+
const cache = res.headers.get('cache-control') ?? '';
|
|
129
|
+
if (!/no-store|no-cache|max-age=0/i.test(cache)) add('info', "/egen-config.json sans « Cache-Control: no-store » : le Core fige son SHA-256, une version en cache provoque un rejet au démarrage");
|
|
130
|
+
} catch (e) {
|
|
131
|
+
add('warn', `/egen-config.json injoignable (${(e as Error).message})`);
|
|
132
|
+
}
|
|
133
|
+
}
|
package/src/server.ts
CHANGED
|
@@ -10,7 +10,7 @@ export interface SimulatorOptions {
|
|
|
10
10
|
app: string;
|
|
11
11
|
port?: number;
|
|
12
12
|
host?: string;
|
|
13
|
-
/**
|
|
13
|
+
/** Déclaration `egen-config.json` de l'app (objet déjà lu). Sans manifeste : l'opérateur simulé définit seul. */
|
|
14
14
|
manifest?: unknown;
|
|
15
15
|
/** Approuver toutes les capacités demandées (défaut) ou seulement celles « par défaut » (`strict`). */
|
|
16
16
|
strict?: boolean;
|
|
@@ -35,6 +35,8 @@ function approvedFor(manifest: EmbedManifest | undefined, strict: boolean): Appr
|
|
|
35
35
|
const asked = manifest.capabilities[id];
|
|
36
36
|
if (asked !== undefined && !CAPABILITIES[id].defaultGrant) out[id] = asked;
|
|
37
37
|
}
|
|
38
|
+
// droits d'iframe : la demande de l'app est approuvée telle quelle (le simulateur joue l'opérateur indulgent)
|
|
39
|
+
if (manifest.iframe) out.iframe = manifest.iframe;
|
|
38
40
|
return out;
|
|
39
41
|
}
|
|
40
42
|
|
|
@@ -50,6 +52,7 @@ export async function startSimulator(o: SimulatorOptions): Promise<Simulator> {
|
|
|
50
52
|
app: appUrl.href,
|
|
51
53
|
moduleName: manifest?.name ?? '@acme/esm-sim-app',
|
|
52
54
|
manifestCapabilities: manifest?.capabilities,
|
|
55
|
+
manifestIframe: manifest?.iframe,
|
|
53
56
|
approved: approvedFor(manifest, !!o.strict),
|
|
54
57
|
extensions: { 'topbar-nav-slot': [{ name: 'nav-demo', moduleName: '@egen/esm-demo-app', order: 1, meta: { label: 'Démo', route: 'demo' } }] },
|
|
55
58
|
};
|
|
@@ -102,7 +105,7 @@ h1{font-size:14px;margin:0 0 8px}h2{font-size:12px;margin:12px 0 4px;text-transf
|
|
|
102
105
|
<h2>Notifications</h2><div id="toasts"></div>
|
|
103
106
|
<h2>Journal des échanges</h2><pre id="log"></pre></aside>
|
|
104
107
|
<script type="module">
|
|
105
|
-
import { effectiveGrants } from '@egen-civitas/esm-embed-protocol';
|
|
108
|
+
import { effectiveGrants, effectiveIframe } from '@egen-civitas/esm-embed-protocol';
|
|
106
109
|
import { createEmbedHost } from '/vendor/host/index.js';
|
|
107
110
|
const cfg = await (await fetch('/api/config')).json();
|
|
108
111
|
const $ = (id) => document.getElementById(id);
|
|
@@ -122,8 +125,9 @@ const providers = {
|
|
|
122
125
|
telemetry: { log: (...a) => log('← telemetry.log', a.slice(0, 3)), metric: (...a) => log('← telemetry.metric', a.slice(0, 3)) },
|
|
123
126
|
};
|
|
124
127
|
const grants = effectiveGrants(cfg.manifestCapabilities, cfg.approved);
|
|
125
|
-
|
|
126
|
-
|
|
128
|
+
const iframe = effectiveIframe(cfg.manifestIframe, cfg.approved.iframe);
|
|
129
|
+
$('info').innerHTML = '<b>App</b> ' + cfg.app + '<br><b>Module</b> ' + cfg.moduleName + '<br><b>hostOrigins à déclarer dans l’app</b> <code>' + location.origin + '</code><br><b>Capacités accordées</b> ' + Object.keys(grants).join(', ') + '<br><b>Droits d’iframe accordés</b> ' + (iframe.sandbox.concat(iframe.allow).join(', ') || 'socle seul');
|
|
130
|
+
const host = createEmbedHost({ moduleName: cfg.moduleName, src: cfg.app, grants, iframe, providers, onConnect: (g, d) => log('✔ connecté', { accordées: g.map((x) => x.id), refusées: d }), onClose: (r) => log('✖ fermé', r) });
|
|
127
131
|
host.mount($('stage'));
|
|
128
132
|
$('locale').onclick = () => locale.set(locale.get() === 'fr' ? 'en' : 'fr');
|
|
129
133
|
$('event').onclick = () => (topics.get('core.sim.ping') || []).forEach((f) => f({ at: Date.now() }));
|
package/src/test-host.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { effectiveGrants, type ApprovedGrants, type CapabilityId, type GrantConfig } from '@egen-civitas/esm-embed-protocol';
|
|
1
|
+
import { effectiveGrants, effectiveIframe, type ApprovedGrants, type CapabilityId, type EffectiveIframeRights, type GrantConfig, type IframeRights } from '@egen-civitas/esm-embed-protocol';
|
|
2
2
|
import type { ConnectOptions } from '@egen-civitas/esm-embed-client';
|
|
3
3
|
import { createBus, HostConnection, type ExtensionInfo, type HostProviders } from '@egen-civitas/esm-embed-host';
|
|
4
4
|
|
|
@@ -8,7 +8,9 @@ export interface TestHostOptions {
|
|
|
8
8
|
origin?: string;
|
|
9
9
|
/** Capacités demandées par le manifeste de l'app (défaut : aucune demande explicite = l'opérateur définit seul). */
|
|
10
10
|
manifestCapabilities?: Partial<Record<CapabilityId, GrantConfig>>;
|
|
11
|
-
/**
|
|
11
|
+
/** Droits d'iframe demandés par l'app (`iframe` de `egen-config.json`). */
|
|
12
|
+
manifestIframe?: IframeRights;
|
|
13
|
+
/** Plafond fixé par l'opérateur (défaut : rien d'approuvé hors capacités « par défaut » ; `iframe` : plafond des droits d'iframe). */
|
|
12
14
|
approved?: ApprovedGrants;
|
|
13
15
|
tenant?: { id: string | null };
|
|
14
16
|
locale?: string;
|
|
@@ -29,6 +31,8 @@ export interface TestHost {
|
|
|
29
31
|
/** À passer à `connectToEgen({ ...host.connectOptions, capabilities: [...] })`. */
|
|
30
32
|
connectOptions: Pick<ConnectOptions, 'moduleName' | 'hostOrigins' | 'window' | 'host' | 'timeoutMs'>;
|
|
31
33
|
connection: HostConnection;
|
|
34
|
+
/** Droits d'iframe que le Core appliquerait (`demande ∩ plafond`) : de quoi vérifier ce que l'app obtient réellement. */
|
|
35
|
+
iframe: EffectiveIframeRights;
|
|
32
36
|
/** Journal des services du Core sollicités par l'app. */
|
|
33
37
|
calls: CallRecord[];
|
|
34
38
|
notifications: Array<{ id?: string; kind: string; title: string; subtitle?: string }>;
|
|
@@ -176,6 +180,7 @@ export function createTestHost(o: TestHostOptions = {}): TestHost {
|
|
|
176
180
|
return {
|
|
177
181
|
connectOptions: { moduleName, hostOrigins: [origin], window: appWindow as any, host: hostWindow as any, timeoutMs: 500 },
|
|
178
182
|
connection,
|
|
183
|
+
iframe: effectiveIframe(o.manifestIframe, o.approved?.iframe),
|
|
179
184
|
calls,
|
|
180
185
|
notifications,
|
|
181
186
|
published,
|