@egen-civitas/esm-embed-testing 0.3.0 → 0.5.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 CHANGED
@@ -1,5 +1,46 @@
1
1
  # @egen-civitas/esm-embed-testing
2
2
 
3
+ ## 0.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 721c7f8: Droits d'iframe négociés et voie unique SDK.
8
+
9
+ - **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`.
10
+ - **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.
11
+ - **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.
12
+ - **client** : documentation (les droits se demandent dans `egen-config.json`), le manifeste s'appelle désormais `egen-config.json`.
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [721c7f8]
17
+ - Updated dependencies [721c7f8]
18
+ - @egen-civitas/esm-embed-protocol@0.5.0
19
+ - @egen-civitas/esm-embed-host@0.5.0
20
+ - @egen-civitas/esm-embed-client@0.3.1
21
+
22
+ ## 0.4.0
23
+
24
+ ### Minor Changes
25
+
26
+ - 3300bac: Toasts partagés : le Core est l'afficheur, l'app notifie en temps réel sans doublon. Politique d'opérateur dans le grant `notifications` (`exclusive`, défaut vrai ; `rate`, défaut 10 par 10 s), `id` de dédoublonnage, réponse `{ displayed }`, anti-spam `RATE_LIMITED`. Client : `egen.notify(toast, local?)` (point d'entrée unique, repli local si le Core n'affiche pas), `egen.coreDisplaysNotifications`, hook `useEgenNotify`. Hôte : le fournisseur peut répondre `false` (doublon). Testing : hôte de test, conformité et vérificateur couvrent le modèle.
27
+ - b2d283e: Retrait radical de l'ancienne couche d'assistance par agent. Elle était trop rigide et sera reconstruite sur une base saine, selon la nouvelle architecture documentée dans le dépôt Core (dossier de documentation de l'intégration de l'agent).
28
+
29
+ - **Packages supprimés** : les sept packages de l'ancienne couche (configuration, canal, contexte, événements, extensions, outils, façade). Le tag `pre-retrait-assistance-2026-11-25` conserve l'état précédent.
30
+ - `esm-framework` : ne ré-exporte plus la façade de l'ancienne couche. **Rupture** pour tout consommateur qui l'importait via `esm-framework`.
31
+ - `esm-styleguide` : le dossier `assistant/` est supprimé (orbe, robot 3D, scène Spline, saisie de prompt, fond d'érosion, modale « verre d'eau », audio), ainsi que les jetons CSS `--ui-*` dédiés à cette couche et les dépendances `three`, `@react-three/fiber`, `@splinetool/*`.
32
+ - `esm-app-shell` : le pont des variables d'environnement de l'ancienne couche vers `window` est supprimé (configuration, gabarit `index.ejs`, bootstrap natif). Le garde-fou des ponts ne porte plus que sur `EGEN_TENANT_*`.
33
+ - `rspack-config` : le préfixe de variable publique de l'ancienne couche est retiré de `PUBLIC_ENV_PREFIXES`.
34
+ - `esm-embed-*` : la capacité d'outils pilotés par un agent est retirée du catalogue du SDK embed (protocole, hôte, client, simulateur et vérificateur de test).
35
+
36
+ ### Patch Changes
37
+
38
+ - Updated dependencies [3300bac]
39
+ - Updated dependencies [b2d283e]
40
+ - @egen-civitas/esm-embed-protocol@0.4.0
41
+ - @egen-civitas/esm-embed-client@0.3.0
42
+ - @egen-civitas/esm-embed-host@0.4.0
43
+
3
44
  ## 0.3.0
4
45
 
5
46
  ### Minor Changes
package/README.md CHANGED
@@ -21,7 +21,7 @@ expect(sim.notifications).toEqual([{ kind: 'success', title: 'OK' }]);
21
21
  sim.emit.locale('en'); // le Core pousse un changement
22
22
  ```
23
23
 
24
- `sim.calls` (journal des services sollicités), `sim.published`, `sim.tools` + `sim.invokeTool()` (agent IA), `sim.emit.*`.
24
+ `sim.calls` (journal des services sollicités), `sim.published`, `sim.emit.*`.
25
25
 
26
26
  ## 2. Suite de conformité
27
27
 
@@ -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-app.json
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
 
@@ -10,7 +10,7 @@ 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-app.json [--shell https://egen.exemple.org] [--probe] [--allow-localhost]
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
16
  --probe interroge l'URL de l'app (en-têtes X-Frame-Options / CSP)
@@ -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-app.json] [--port 4100] [--strict] [--session session.json]
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-app.json de l'app (les capacités demandées sont approuvées, sauf --strict)
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
- /** Manifeste `egen-app.json` déjà lu. */
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;
@@ -1 +1 @@
1
- {"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../src/check.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,yCAAyC;IACzC,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,CAuD1E;AAED,eAAO,MAAM,SAAS,GAAI,QAAQ,UAAU,EAAE,YAA4C,CAAC"}
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,CA6D1E;AAED,eAAO,MAAM,SAAS,GAAI,QAAQ,UAAU,EAAE,YAA4C,CAAC"}
package/dist/check.js CHANGED
@@ -152,9 +152,15 @@ function _ts_generator(thisArg, body) {
152
152
  }
153
153
  }
154
154
  import { CAPABILITIES, patternCovers, validateManifest } from '@egen-civitas/esm-embed-protocol';
155
+ /** Permissions `allow` donnant accès à des capteurs ou à l'écran de l'utilisateur. */ var SENSITIVE_PERMISSIONS = new Set([
156
+ 'camera',
157
+ 'microphone',
158
+ 'geolocation',
159
+ 'display-capture'
160
+ ]);
155
161
  /** 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
162
  return _async_to_generator(function() {
157
- var _m_extensions, _m_extensions1, _caps_events, _caps_aitools, _caps_extensions, issues, add, r, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _$e, m, caps, needApproval, pub, own, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, p, tools, slots, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _$e1, discover, _o_fetchImpl, f, _res_headers_get, _exec_, _exec, res, xfo, csp, fa, tokens, e;
163
+ 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
164
  return _ts_generator(this, function(_state) {
159
165
  switch(_state.label){
160
166
  case 0:
@@ -225,10 +231,21 @@ import { CAPABILITIES, patternCovers, validateManifest } from '@egen-civitas/esm
225
231
  }
226
232
  }
227
233
  }
228
- tools = (_caps_aitools = caps['ai-tools']) === null || _caps_aitools === void 0 ? void 0 : _caps_aitools.tools;
229
- if (Array.isArray(tools) && tools.some(function(t) {
230
- return !String(t).includes('.');
231
- })) add('warn', 'ai-tools.tools : préférer des noms d’outils préfixés (ex. studio.apply) pour éviter les collisions');
234
+ 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");
235
+ asked = m.iframe;
236
+ 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)) {
237
+ ;
238
+ list = _to_consumable_array(((_asked_sandbox1 = asked.sandbox) !== null && _asked_sandbox1 !== void 0 ? _asked_sandbox1 : []).map(function(t) {
239
+ return "sandbox:".concat(t);
240
+ })).concat(_to_consumable_array(((_asked_allow1 = asked.allow) !== null && _asked_allow1 !== void 0 ? _asked_allow1 : []).map(function(t) {
241
+ return "allow:".concat(t);
242
+ })));
243
+ add('info', "Droits d'iframe demand\xe9s : l'op\xe9rateur doit les approuver (grants.iframe), sinon ils seront refus\xe9s : ".concat(list.join(', ')));
244
+ sensitive = ((_asked_allow2 = asked.allow) !== null && _asked_allow2 !== void 0 ? _asked_allow2 : []).filter(function(t) {
245
+ return SENSITIVE_PERMISSIONS.has(t);
246
+ });
247
+ 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"));
248
+ }
232
249
  slots = _to_consumable_array(new Set(((_m_extensions = m.extensions) !== null && _m_extensions !== void 0 ? _m_extensions : []).map(function(e) {
233
250
  return e.slot;
234
251
  })));
@@ -1 +1 @@
1
- {"version":3,"file":"conformance.d.ts","sourceRoot":"","sources":["../src/conformance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAGjF,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;AAEzE,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAC7C,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;IACvD,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC;CAC7B;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,cAAc,GAAG,IAAI,CAwF7E"}
1
+ {"version":3,"file":"conformance.d.ts","sourceRoot":"","sources":["../src/conformance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAGjF,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;AAEzE,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAC7C,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;IACvD,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC;CAC7B;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,cAAc,GAAG,IAAI,CA4H7E"}
@@ -526,6 +526,175 @@ import { createTestHost } from './test-host.js';
526
526
  });
527
527
  })();
528
528
  });
529
+ it('toasts : le Core affiche seul, l’app n’affiche pas les siens (notify sans doublon)', function() {
530
+ return _async_to_generator(function() {
531
+ var sim, c, local;
532
+ return _ts_generator(this, function(_state) {
533
+ switch(_state.label){
534
+ case 0:
535
+ sim = createTestHost({
536
+ manifestCapabilities: {
537
+ notifications: {}
538
+ },
539
+ approved: {
540
+ notifications: {}
541
+ }
542
+ });
543
+ return [
544
+ 4,
545
+ connect(_object_spread_props(_object_spread({}, sim.connectOptions), {
546
+ capabilities: [
547
+ 'notifications'
548
+ ]
549
+ }))
550
+ ];
551
+ case 1:
552
+ c = _state.sent();
553
+ local = [];
554
+ expect(c.coreDisplaysNotifications).toBe(true);
555
+ return [
556
+ 4,
557
+ c.notify({
558
+ kind: 'success',
559
+ title: 'Enregistré',
560
+ id: 't1'
561
+ }, function(t) {
562
+ return local.push(t);
563
+ })
564
+ ];
565
+ case 2:
566
+ _state.sent();
567
+ return [
568
+ 4,
569
+ c.notify({
570
+ kind: 'success',
571
+ title: 'Enregistré',
572
+ id: 't1'
573
+ }, function(t) {
574
+ return local.push(t);
575
+ })
576
+ ];
577
+ case 3:
578
+ _state.sent();
579
+ expect(local).toEqual([]);
580
+ expect(sim.notifications).toHaveLength(1); // le doublon (même id) n'est pas réaffiché par le Core
581
+ c.close();
582
+ sim.destroy();
583
+ return [
584
+ 2
585
+ ];
586
+ }
587
+ });
588
+ })();
589
+ });
590
+ it('toasts : sans approbation, l’app affiche elle-même (jamais de perte, jamais de doublon)', function() {
591
+ return _async_to_generator(function() {
592
+ var sim, c, local;
593
+ return _ts_generator(this, function(_state) {
594
+ switch(_state.label){
595
+ case 0:
596
+ sim = createTestHost();
597
+ return [
598
+ 4,
599
+ connect(_object_spread_props(_object_spread({}, sim.connectOptions), {
600
+ capabilities: [
601
+ 'notifications'
602
+ ]
603
+ }))
604
+ ];
605
+ case 1:
606
+ c = _state.sent();
607
+ local = [];
608
+ expect(c.coreDisplaysNotifications).toBe(false);
609
+ return [
610
+ 4,
611
+ c.notify({
612
+ kind: 'info',
613
+ title: 'x'
614
+ }, function(t) {
615
+ return local.push(t);
616
+ })
617
+ ];
618
+ case 2:
619
+ _state.sent();
620
+ expect(local).toHaveLength(1);
621
+ expect(sim.notifications).toHaveLength(0);
622
+ c.close();
623
+ sim.destroy();
624
+ return [
625
+ 2
626
+ ];
627
+ }
628
+ });
629
+ })();
630
+ });
631
+ it('toasts : anti-spam (rate) — au-delà, abandonné, ni Core ni local', function() {
632
+ return _async_to_generator(function() {
633
+ var sim, c, local, i;
634
+ return _ts_generator(this, function(_state) {
635
+ switch(_state.label){
636
+ case 0:
637
+ sim = createTestHost({
638
+ manifestCapabilities: {
639
+ notifications: {}
640
+ },
641
+ approved: {
642
+ notifications: {
643
+ rate: {
644
+ max: 2,
645
+ perSeconds: 60
646
+ }
647
+ }
648
+ }
649
+ });
650
+ return [
651
+ 4,
652
+ connect(_object_spread_props(_object_spread({}, sim.connectOptions), {
653
+ capabilities: [
654
+ 'notifications'
655
+ ]
656
+ }))
657
+ ];
658
+ case 1:
659
+ c = _state.sent();
660
+ local = [];
661
+ i = 0;
662
+ _state.label = 2;
663
+ case 2:
664
+ if (!(i < 5)) return [
665
+ 3,
666
+ 5
667
+ ];
668
+ return [
669
+ 4,
670
+ c.notify({
671
+ kind: 'info',
672
+ title: "t".concat(i)
673
+ }, function(t) {
674
+ return local.push(t);
675
+ })
676
+ ];
677
+ case 3:
678
+ _state.sent();
679
+ _state.label = 4;
680
+ case 4:
681
+ i++;
682
+ return [
683
+ 3,
684
+ 2
685
+ ];
686
+ case 5:
687
+ expect(sim.notifications).toHaveLength(2);
688
+ expect(local).toEqual([]);
689
+ c.close();
690
+ sim.destroy();
691
+ return [
692
+ 2
693
+ ];
694
+ }
695
+ });
696
+ })();
697
+ });
529
698
  it('fermeture : appels suivants rejetés', function() {
530
699
  return _async_to_generator(function() {
531
700
  var sim, c;
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
- /** Manifeste `egen-app.json` de l'app (objet déjà lu). Sans manifeste : l'opérateur simulé définit seul. */
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;
@@ -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,4GAA4G;IAC5G,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;AAkBD,wBAAsB,cAAc,CAAC,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CAyC5E"}
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();\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) => { log('← notifications.show', n); const d = document.createElement('div'); d.className = 'toast'; d.textContent = '[' + n.kind + '] ' + n.title + (n.subtitle ? ' — ' + n.subtitle : ''); $('toasts').prepend(d); } },\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 aiTools: { register: (m, t) => log('← ai-tools.register', t.map((x) => x.name)), unregister: (m, n) => log('← ai-tools.unregister', n) },\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>";
@@ -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
- /** Plafond fixé par l'opérateur (défaut : rien d'approuvé hors capacités « par défaut »). */
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,9 +34,12 @@ 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<{
42
+ id?: string;
38
43
  kind: string;
39
44
  title: string;
40
45
  subtitle?: string;
@@ -44,9 +49,6 @@ export interface TestHost {
44
49
  payload: unknown;
45
50
  from: string;
46
51
  }>;
47
- tools: Map<string, {
48
- description: string;
49
- }>;
50
52
  /** Pousse un changement vers l'app (comme le ferait le Core). */
51
53
  emit: {
52
54
  tenant(v: {
@@ -59,8 +61,6 @@ export interface TestHost {
59
61
  goto(path: string): void;
60
62
  visibility(visible: boolean): void;
61
63
  };
62
- /** L'agent IA appelle un outil déclaré par l'app. */
63
- invokeTool(name: string, args?: Record<string, unknown>): Promise<unknown>;
64
64
  destroy(): void;
65
65
  }
66
66
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"test-host.d.ts","sourceRoot":"","sources":["../src/test-host.ts"],"names":[],"mappings":"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"}
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,132 +1,4 @@
1
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
- try {
3
- var info = gen[key](arg);
4
- var value = info.value;
5
- } catch (error) {
6
- reject(error);
7
- return;
8
- }
9
- if (info.done) {
10
- resolve(value);
11
- } else {
12
- Promise.resolve(value).then(_next, _throw);
13
- }
14
- }
15
- function _async_to_generator(fn) {
16
- return function() {
17
- var self = this, args = arguments;
18
- return new Promise(function(resolve, reject) {
19
- var gen = fn.apply(self, args);
20
- function _next(value) {
21
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
- }
23
- function _throw(err) {
24
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
- }
26
- _next(undefined);
27
- });
28
- };
29
- }
30
- function _ts_generator(thisArg, body) {
31
- var f, y, t, _ = {
32
- label: 0,
33
- sent: function() {
34
- if (t[0] & 1) throw t[1];
35
- return t[1];
36
- },
37
- trys: [],
38
- ops: []
39
- }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
40
- return d(g, "next", {
41
- value: verb(0)
42
- }), d(g, "throw", {
43
- value: verb(1)
44
- }), d(g, "return", {
45
- value: verb(2)
46
- }), typeof Symbol === "function" && d(g, Symbol.iterator, {
47
- value: function() {
48
- return this;
49
- }
50
- }), g;
51
- function verb(n) {
52
- return function(v) {
53
- return step([
54
- n,
55
- v
56
- ]);
57
- };
58
- }
59
- function step(op) {
60
- if (f) throw new TypeError("Generator is already executing.");
61
- while(g && (g = 0, op[0] && (_ = 0)), _)try {
62
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
63
- if (y = 0, t) op = [
64
- op[0] & 2,
65
- t.value
66
- ];
67
- switch(op[0]){
68
- case 0:
69
- case 1:
70
- t = op;
71
- break;
72
- case 4:
73
- _.label++;
74
- return {
75
- value: op[1],
76
- done: false
77
- };
78
- case 5:
79
- _.label++;
80
- y = op[1];
81
- op = [
82
- 0
83
- ];
84
- continue;
85
- case 7:
86
- op = _.ops.pop();
87
- _.trys.pop();
88
- continue;
89
- default:
90
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
91
- _ = 0;
92
- continue;
93
- }
94
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
95
- _.label = op[1];
96
- break;
97
- }
98
- if (op[0] === 6 && _.label < t[1]) {
99
- _.label = t[1];
100
- t = op;
101
- break;
102
- }
103
- if (t && _.label < t[2]) {
104
- _.label = t[2];
105
- _.ops.push(op);
106
- break;
107
- }
108
- if (t[2]) _.ops.pop();
109
- _.trys.pop();
110
- continue;
111
- }
112
- op = body.call(thisArg, _);
113
- } catch (e) {
114
- op = [
115
- 6,
116
- e
117
- ];
118
- y = 0;
119
- } finally{
120
- f = t = 0;
121
- }
122
- if (op[0] & 5) throw op[1];
123
- return {
124
- value: op[0] ? op[1] : void 0,
125
- done: true
126
- };
127
- }
128
- }
129
- import { effectiveGrants } from '@egen-civitas/esm-embed-protocol';
1
+ import { effectiveGrants, effectiveIframe } from '@egen-civitas/esm-embed-protocol';
130
2
  import { createBus, HostConnection } from '@egen-civitas/esm-embed-host';
131
3
  function watchable(initial) {
132
4
  var value = initial;
@@ -159,13 +31,12 @@ function watchable(initial) {
159
31
  */ export function createTestHost() {
160
32
  var o = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
161
33
  var _o_moduleName, _o_origin, _o_tenant, _o_locale, _o_extensions, _o_config, _o_approved;
34
+ var _o_approved1;
162
35
  var moduleName = (_o_moduleName = o.moduleName) !== null && _o_moduleName !== void 0 ? _o_moduleName : '@acme/esm-test-app';
163
36
  var origin = (_o_origin = o.origin) !== null && _o_origin !== void 0 ? _o_origin : 'https://shell.test';
164
37
  var calls = [];
165
38
  var notifications = [];
166
39
  var published = [];
167
- var tools = new Map();
168
- var toolInvokers = new Map();
169
40
  var log = function log(cap, method) {
170
41
  for(var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
171
42
  args[_key - 2] = arguments[_key];
@@ -247,7 +118,12 @@ function watchable(initial) {
247
118
  notifications: {
248
119
  show: function show(n) {
249
120
  log('notifications', 'show', n);
121
+ // même dédoublonnage que le Core : un `id` déjà affiché n'est pas réaffiché
122
+ if (n.id && notifications.some(function(x) {
123
+ return x.id === n.id;
124
+ })) return false;
250
125
  notifications.push(n);
126
+ return true;
251
127
  }
252
128
  },
253
129
  dialogs: {
@@ -264,59 +140,6 @@ function watchable(initial) {
264
140
  metric: function metric(n, v, t) {
265
141
  return log('telemetry', 'metric', n, v, t);
266
142
  }
267
- },
268
- aiTools: {
269
- register: function register(_m, list, invoke) {
270
- log('ai-tools', 'register', list.map(function(t) {
271
- return t.name;
272
- }));
273
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
274
- try {
275
- for(var _iterator = list[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
276
- var t = _step.value;
277
- tools.set(t.name, {
278
- description: t.description
279
- });
280
- toolInvokers.set(t.name, invoke);
281
- }
282
- } catch (err) {
283
- _didIteratorError = true;
284
- _iteratorError = err;
285
- } finally{
286
- try {
287
- if (!_iteratorNormalCompletion && _iterator.return != null) {
288
- _iterator.return();
289
- }
290
- } finally{
291
- if (_didIteratorError) {
292
- throw _iteratorError;
293
- }
294
- }
295
- }
296
- },
297
- unregister: function unregister(_m, names) {
298
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
299
- try {
300
- for(var _iterator = names[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
301
- var n = _step.value;
302
- tools.delete(n);
303
- toolInvokers.delete(n);
304
- }
305
- } catch (err) {
306
- _didIteratorError = true;
307
- _iteratorError = err;
308
- } finally{
309
- try {
310
- if (!_iteratorNormalCompletion && _iterator.return != null) {
311
- _iterator.return();
312
- }
313
- } finally{
314
- if (_didIteratorError) {
315
- throw _iteratorError;
316
- }
317
- }
318
- }
319
- }
320
143
  }
321
144
  };
322
145
  var appWindow = new EventTarget();
@@ -374,10 +197,10 @@ function watchable(initial) {
374
197
  timeoutMs: 500
375
198
  },
376
199
  connection: connection,
200
+ iframe: effectiveIframe(o.manifestIframe, (_o_approved1 = o.approved) === null || _o_approved1 === void 0 ? void 0 : _o_approved1.iframe),
377
201
  calls: calls,
378
202
  notifications: notifications,
379
203
  published: published,
380
- tools: tools,
381
204
  emit: {
382
205
  tenant: function tenant1(v) {
383
206
  return tenant.set(v);
@@ -411,20 +234,6 @@ function watchable(initial) {
411
234
  return channel.emit('visibility', v);
412
235
  }
413
236
  },
414
- invokeTool: function invokeTool(name) {
415
- var args = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
416
- return _async_to_generator(function() {
417
- var inv;
418
- return _ts_generator(this, function(_state) {
419
- inv = toolInvokers.get(name);
420
- if (!inv) throw new Error("Outil non enregistr\xe9 : ".concat(name));
421
- return [
422
- 2,
423
- inv(name, args)
424
- ];
425
- });
426
- })();
427
- },
428
237
  destroy: function destroy() {
429
238
  return connection.destroy();
430
239
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@egen-civitas/esm-embed-testing",
3
- "version": "0.3.0",
3
+ "version": "0.5.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.2.0",
80
- "@egen-civitas/esm-embed-host": "^0.3.0",
81
- "@egen-civitas/esm-embed-protocol": "^0.3.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.0"
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
- /** Manifeste `egen-app.json` déjà lu. */
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;
@@ -40,9 +43,15 @@ export async function checkEmbedApp(o: CheckOptions): Promise<CheckIssue[]> {
40
43
  else if (!patternCovers(own, String(p).replace(/\.\*$/, '.x'))) add('warn', `events.publish : « ${p} » sort de l'espace conseillé ${own}`);
41
44
  }
42
45
  }
43
- const tools = caps['ai-tools']?.tools;
44
- if (Array.isArray(tools) && tools.some((t) => !String(t).includes('.'))) add('warn', 'ai-tools.tools : préférer des noms d’outils préfixés (ex. studio.apply) pour éviter les collisions');
45
46
 
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
+ }
46
55
  const slots = [...new Set((m.extensions ?? []).map((e) => e.slot))];
47
56
  if (slots.length) add('info', `Contributions d'extension : l'opérateur doit approuver les slots (extensions.contribute) : ${slots.join(', ')}`);
48
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)`);
@@ -93,6 +93,42 @@ export function defineConformance(connect: ConnectFn, t: ConformanceApi): void {
93
93
  sim.destroy();
94
94
  });
95
95
 
96
+ it('toasts : le Core affiche seul, l’app n’affiche pas les siens (notify sans doublon)', async () => {
97
+ const sim = createTestHost({ manifestCapabilities: { notifications: {} }, approved: { notifications: {} } });
98
+ const c = await connect({ ...sim.connectOptions, capabilities: ['notifications'] });
99
+ const local: unknown[] = [];
100
+ expect(c.coreDisplaysNotifications).toBe(true);
101
+ await c.notify({ kind: 'success', title: 'Enregistré', id: 't1' }, (t) => local.push(t));
102
+ await c.notify({ kind: 'success', title: 'Enregistré', id: 't1' }, (t) => local.push(t));
103
+ expect(local).toEqual([]);
104
+ expect(sim.notifications).toHaveLength(1); // le doublon (même id) n'est pas réaffiché par le Core
105
+ c.close();
106
+ sim.destroy();
107
+ });
108
+
109
+ it('toasts : sans approbation, l’app affiche elle-même (jamais de perte, jamais de doublon)', async () => {
110
+ const sim = createTestHost();
111
+ const c = await connect({ ...sim.connectOptions, capabilities: ['notifications'] });
112
+ const local: unknown[] = [];
113
+ expect(c.coreDisplaysNotifications).toBe(false);
114
+ await c.notify({ kind: 'info', title: 'x' }, (t) => local.push(t));
115
+ expect(local).toHaveLength(1);
116
+ expect(sim.notifications).toHaveLength(0);
117
+ c.close();
118
+ sim.destroy();
119
+ });
120
+
121
+ it('toasts : anti-spam (rate) — au-delà, abandonné, ni Core ni local', async () => {
122
+ const sim = createTestHost({ manifestCapabilities: { notifications: {} }, approved: { notifications: { rate: { max: 2, perSeconds: 60 } } } });
123
+ const c = await connect({ ...sim.connectOptions, capabilities: ['notifications'] });
124
+ const local: unknown[] = [];
125
+ for (let i = 0; i < 5; i++) await c.notify({ kind: 'info', title: `t${i}` }, (t) => local.push(t));
126
+ expect(sim.notifications).toHaveLength(2);
127
+ expect(local).toEqual([]);
128
+ c.close();
129
+ sim.destroy();
130
+ });
131
+
96
132
  it('fermeture : appels suivants rejetés', async () => {
97
133
  const sim = createTestHost();
98
134
  const c = await connect({ ...sim.connectOptions, capabilities: ['tenant'] });
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
- /** Manifeste `egen-app.json` de l'app (objet déjà lu). Sans manifeste : l'opérateur simulé définit seul. */
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,14 +105,14 @@ 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);
109
112
  const log = (...a) => { $('log').textContent = new Date().toLocaleTimeString() + ' ' + a.map((x) => typeof x === 'string' ? x : JSON.stringify(x)).join(' ') + '\\n' + $('log').textContent; };
110
113
  const 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)); } }; };
111
114
  const locale = watch('fr'), tenant = watch({ id: 'sim-tenant' }), conf = watch({});
112
- const topics = new Map();
115
+ const topics = new Map(), seenToasts = new Set();
113
116
  const extState = new Map(Object.entries(cfg.extensions)), extSubs = new Map();
114
117
  const wrap = (cap, p) => Object.fromEntries(Object.entries(p).map(([k, f]) => [k, typeof f === 'function' ? (...a) => { log('←', cap + '.' + k, a); return f(...a); } : f]));
115
118
  const providers = {
@@ -117,14 +120,14 @@ const providers = {
117
120
  flags: wrap('flags', { isEnabled: () => true }),
118
121
  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); } },
119
122
  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)); } },
120
- notifications: { show: (n) => { log('← notifications.show', n); const d = document.createElement('div'); d.className = 'toast'; d.textContent = '[' + n.kind + '] ' + n.title + (n.subtitle ? ' — ' + n.subtitle : ''); $('toasts').prepend(d); } },
123
+ 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 + ' · ' + n.title + (n.subtitle ? ' — ' + n.subtitle : ''); $('toasts').prepend(d); return true; } },
121
124
  dialogs: { confirm: (d) => { log('← dialogs.confirm', d); return confirm(d.title + '\\n\\n' + d.message); } },
122
125
  telemetry: { log: (...a) => log('← telemetry.log', a.slice(0, 3)), metric: (...a) => log('← telemetry.metric', a.slice(0, 3)) },
123
- aiTools: { register: (m, t) => log('← ai-tools.register', t.map((x) => x.name)), unregister: (m, n) => log('← ai-tools.unregister', n) },
124
126
  };
125
127
  const grants = effectiveGrants(cfg.manifestCapabilities, cfg.approved);
126
- $('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(', ');
127
- const host = createEmbedHost({ moduleName: cfg.moduleName, src: cfg.app, grants, providers, onConnect: (g, d) => log('✔ connecté', { accordées: g.map((x) => x.id), refusées: d }), onClose: (r) => log('✖ fermé', r) });
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) });
128
131
  host.mount($('stage'));
129
132
  $('locale').onclick = () => locale.set(locale.get() === 'fr' ? 'en' : 'fr');
130
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
- /** Plafond fixé par l'opérateur (défaut : rien d'approuvé hors capacités « par défaut »). */
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,11 +31,12 @@ 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
- notifications: Array<{ kind: string; title: string; subtitle?: string }>;
38
+ notifications: Array<{ id?: string; kind: string; title: string; subtitle?: string }>;
35
39
  published: Array<{ topic: string; payload: unknown; from: string }>;
36
- tools: Map<string, { description: string }>;
37
40
  /** Pousse un changement vers l'app (comme le ferait le Core). */
38
41
  emit: {
39
42
  tenant(v: { id: string | null }): void;
@@ -44,8 +47,6 @@ export interface TestHost {
44
47
  goto(path: string): void;
45
48
  visibility(visible: boolean): void;
46
49
  };
47
- /** L'agent IA appelle un outil déclaré par l'app. */
48
- invokeTool(name: string, args?: Record<string, unknown>): Promise<unknown>;
49
50
  destroy(): void;
50
51
  }
51
52
 
@@ -77,8 +78,6 @@ export function createTestHost(o: TestHostOptions = {}): TestHost {
77
78
  const calls: CallRecord[] = [];
78
79
  const notifications: TestHost['notifications'] = [];
79
80
  const published: TestHost['published'] = [];
80
- const tools = new Map<string, { description: string }>();
81
- const toolInvokers = new Map<string, (name: string, args: Record<string, unknown>) => Promise<unknown>>();
82
81
  const log = (cap: string, method: string, ...args: unknown[]) => void calls.push({ cap, method, args });
83
82
 
84
83
  const tenant = watchable(o.tenant ?? { id: null });
@@ -136,7 +135,10 @@ export function createTestHost(o: TestHostOptions = {}): TestHost {
136
135
  notifications: {
137
136
  show: (n) => {
138
137
  log('notifications', 'show', n);
138
+ // même dédoublonnage que le Core : un `id` déjà affiché n'est pas réaffiché
139
+ if (n.id && notifications.some((x) => x.id === n.id)) return false;
139
140
  notifications.push(n);
141
+ return true;
140
142
  },
141
143
  },
142
144
  dialogs: {
@@ -146,21 +148,6 @@ export function createTestHost(o: TestHostOptions = {}): TestHost {
146
148
  },
147
149
  },
148
150
  telemetry: { log: (l, m, c) => log('telemetry', 'log', l, m, c), metric: (n, v, t) => log('telemetry', 'metric', n, v, t) },
149
- aiTools: {
150
- register: (_m, list, invoke) => {
151
- log('ai-tools', 'register', list.map((t) => t.name));
152
- for (const t of list) {
153
- tools.set(t.name, { description: t.description });
154
- toolInvokers.set(t.name, invoke);
155
- }
156
- },
157
- unregister: (_m, names) => {
158
- for (const n of names) {
159
- tools.delete(n);
160
- toolInvokers.delete(n);
161
- }
162
- },
163
- },
164
151
  };
165
152
 
166
153
  const appWindow = new EventTarget();
@@ -193,10 +180,10 @@ export function createTestHost(o: TestHostOptions = {}): TestHost {
193
180
  return {
194
181
  connectOptions: { moduleName, hostOrigins: [origin], window: appWindow as any, host: hostWindow as any, timeoutMs: 500 },
195
182
  connection,
183
+ iframe: effectiveIframe(o.manifestIframe, o.approved?.iframe),
196
184
  calls,
197
185
  notifications,
198
186
  published,
199
- tools,
200
187
  emit: {
201
188
  tenant: (v) => tenant.set(v),
202
189
  locale: (v) => locale.set(v),
@@ -209,11 +196,6 @@ export function createTestHost(o: TestHostOptions = {}): TestHost {
209
196
  goto: (path) => channel.emit('goto', { path, seq: Date.now() }),
210
197
  visibility: (v) => channel.emit('visibility', v),
211
198
  },
212
- invokeTool: async (name, args = {}) => {
213
- const inv = toolInvokers.get(name);
214
- if (!inv) throw new Error(`Outil non enregistré : ${name}`);
215
- return inv(name, args);
216
- },
217
199
  destroy: () => connection.destroy(),
218
200
  };
219
201
  }