@egen-civitas/esm-embed-testing 0.4.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,24 @@
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
+
3
22
  ## 0.4.0
4
23
 
5
24
  ### 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-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,CAsD1E;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_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;
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:
@@ -226,6 +232,20 @@ import { CAPABILITIES, patternCovers, validateManifest } from '@egen-civitas/esm
226
232
  }
227
233
  }
228
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
+ }
229
249
  slots = _to_consumable_array(new Set(((_m_extensions = m.extensions) !== null && _m_extensions !== void 0 ? _m_extensions : []).map(function(e) {
230
250
  return e.slot;
231
251
  })));
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(), 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>";
@@ -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,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<{
@@ -1 +1 @@
1
- {"version":3,"file":"test-host.d.ts","sourceRoot":"","sources":["../src/test-host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC7H,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAa,cAAc,EAAE,KAAK,aAAa,EAAsB,MAAM,8BAA8B,CAAC;AAEjH,MAAM,WAAW,eAAe;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oHAAoH;IACpH,oBAAoB,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC;IAClE,6FAA6F;IAC7F,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,MAAM,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,2EAA2E;IAC3E,UAAU,CAAC,EA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U,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC;QACtD,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;QACzC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;QAC9C,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;KACpC,CAAC;IACF,OAAO,IAAI,IAAI,CAAC;CACjB;AAeD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,CAAC,GAAE,eAAoB,GAAG,QAAQ,CA8HhE"}
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.4.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.3.0",
80
- "@egen-civitas/esm-embed-host": "^0.4.0",
81
- "@egen-civitas/esm-embed-protocol": "^0.4.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;
@@ -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)`);
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,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
- $('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(', ');
126
- 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) });
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
- /** 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,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,