@egen-civitas/esm-embed-host 0.6.0 → 0.7.1
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 +16 -0
- package/dist/host.d.ts +2 -0
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +23 -4
- package/package.json +3 -3
- package/src/host.ts +34 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @egen-civitas/esm-embed-host
|
|
2
2
|
|
|
3
|
+
## 0.7.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [d74087b]
|
|
8
|
+
- @egen-civitas/esm-embed-protocol@0.7.0
|
|
9
|
+
|
|
10
|
+
## 0.7.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- b3c354a: Plus d'échec muet de la poignée de main.
|
|
15
|
+
|
|
16
|
+
- **hôte** : un message de l'iframe dont le **nom de module** ne correspond pas à celui verrouillé côté Core, ou dont l'**origine** diffère de celle déclarée, est toujours ignoré (aucun changement de sécurité) mais est désormais signalé par un `console.warn` explicite (une fois par cause) qui nomme les deux valeurs et la correction (`yarn external:sync`, URL déclarée). Option `logger`. Les messages d'une autre fenêtre ou hors protocole restent ignorés sans bruit.
|
|
17
|
+
- **client** : au dépassement du délai, `connectToEgen` écrit un avertissement qui liste les causes probables (nom du module, origines du Shell, URL déclarée, hôte v2) avec le nom et les origines utilisés. Option `log`. Aucun avertissement hors iframe ni en cas de connexion réussie.
|
|
18
|
+
|
|
3
19
|
## 0.6.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
package/dist/host.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ export interface EmbedHostOptions {
|
|
|
23
23
|
navigation?: NavigationOptions;
|
|
24
24
|
/** Navigation demandée par l'app vers le Core (défaut : `singleSpaNavigate`). */
|
|
25
25
|
onNavigate?: (to: string) => void;
|
|
26
|
+
/** Où écrire les diagnostics de poignée de main (défaut : `console`). */
|
|
27
|
+
logger?: Pick<Console, 'warn'>;
|
|
26
28
|
/**
|
|
27
29
|
* L'app signale une page introuvable (`navigation.notFound`) : le Shell affiche SA page 404 à la place de l'app.
|
|
28
30
|
* `path` est le chemin de l'app, normalisé et débarrassé des paramètres sensibles (`null` : la page courante de l'app).
|
package/dist/host.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4D,KAAK,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,KAAK,eAAe,EAAE,KAAK,YAAY,EAAE,KAAK,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAEjN,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAwH,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC/K,OAAO,KAAK,EAAE,aAAa,EAAS,MAAM,gBAAgB,CAAC;AAG3D,MAAM,WAAW,gBAAgB;IAC/B,sDAAsD;IACtD,UAAU,EAAE,MAAM,CAAC;IACnB,8CAA8C;IAC9C,GAAG,EAAE,MAAM,CAAC;IACZ,iEAAiE;IACjE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,+EAA+E;IAC/E,MAAM,EAAE,eAAe,CAAC;IACxB,SAAS,EAAE,aAAa,CAAC;IACzB;;;OAGG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kGAAkG;IAClG,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,iFAAiF;IACjF,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,yEAAyE;IACzE,MAAM,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC/B;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,KAAK,IAAI,CAAC;IACrD,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,CAAC,OAAO,EAAE,iBAAiB,EAAE,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAC;IAC3E,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAC;IACpC,KAAK,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAAC;IAChC,2IAA2I;IAC3I,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/C,OAAO,IAAI,IAAI,CAAC;CACjB;AAKD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,gBAAgB,GAAG,SAAS,CA6KjE"}
|
package/dist/host.js
CHANGED
|
@@ -203,7 +203,7 @@ function _ts_generator(thisArg, body) {
|
|
|
203
203
|
};
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
|
-
import { sanitizeIframeRights } from '@egen-civitas/esm-embed-protocol';
|
|
206
|
+
import { EGEN_EMBED_PROTOCOL, parseEnvelope, sanitizeIframeRights } from '@egen-civitas/esm-embed-protocol';
|
|
207
207
|
import { createBus } from './bus.js';
|
|
208
208
|
import { HostConnection } from './connection.js';
|
|
209
209
|
import { buildCoreUrl, buildEmbedSrc, coreSubpath, createRateLimiter, stripSensitive, toAppPath, toCorePath, normalizeAppPath } from './navigation.js';
|
|
@@ -218,7 +218,7 @@ import { buildCoreUrl, buildEmbedSrc, coreSubpath, createRateLimiter, stripSensi
|
|
|
218
218
|
* événements de cycle de vie. Une seule voie : le protocole 2 (SDK `esm-embed-client`).
|
|
219
219
|
* Sécurité : messages acceptés seulement de l'iframe elle-même ET de l'origine autorisée ; envoi toujours avec une origine explicite.
|
|
220
220
|
*/ export function createEmbedHost(opts) {
|
|
221
|
-
var _opts_window, _opts_navigation_mode, _opts_navigation_mode1, _currentCorePath, _toAppPath, _opts_allowedOrigin, _opts_title, _opts_minHeight;
|
|
221
|
+
var _opts_window, _opts_navigation_mode, _opts_navigation_mode1, _currentCorePath, _toAppPath, _opts_allowedOrigin, _opts_title, _opts_minHeight, _opts_logger;
|
|
222
222
|
var win = (_opts_window = opts.window) !== null && _opts_window !== void 0 ? _opts_window : window;
|
|
223
223
|
var doc = win.document;
|
|
224
224
|
var nav = opts.navigation && ((_opts_navigation_mode = opts.navigation.mode) !== null && _opts_navigation_mode !== void 0 ? _opts_navigation_mode : 'history') !== 'none' ? _object_spread_props(_object_spread({}, opts.navigation), {
|
|
@@ -311,9 +311,28 @@ import { buildCoreUrl, buildEmbedSrc, coreSubpath, createRateLimiter, stripSensi
|
|
|
311
311
|
onConnect: opts.onConnect,
|
|
312
312
|
onClose: opts.onClose
|
|
313
313
|
});
|
|
314
|
+
// Diagnostics : sans eux, un nom de module ou une origine qui ne correspond pas à la déclaration verrouillée côté Core
|
|
315
|
+
// fait échouer la poignée de main EN SILENCE (l'app attend 5 s puis se replie en mode autonome, sans la moindre trace).
|
|
316
|
+
var logger = (_opts_logger = opts.logger) !== null && _opts_logger !== void 0 ? _opts_logger : console;
|
|
317
|
+
var warned = new Set();
|
|
318
|
+
var warnOnce = function warnOnce(key, message) {
|
|
319
|
+
if (warned.has(key)) return;
|
|
320
|
+
warned.add(key);
|
|
321
|
+
logger.warn(message);
|
|
322
|
+
};
|
|
314
323
|
var onMessage = function onMessage(event) {
|
|
315
|
-
if (event.source !== iframe.contentWindow
|
|
316
|
-
|
|
324
|
+
if (event.source !== iframe.contentWindow) return; // une autre fenêtre : ignorée sans bruit
|
|
325
|
+
var envelope = parseEnvelope(event.data);
|
|
326
|
+
if (event.origin !== origin) {
|
|
327
|
+
if ((envelope === null || envelope === void 0 ? void 0 : envelope.egen) === EGEN_EMBED_PROTOCOL) {
|
|
328
|
+
warnOnce("origin:".concat(event.origin), "[egen-embed] \xab ".concat(opts.moduleName, " \xbb : message ignor\xe9, l'iframe parle depuis ").concat(event.origin, " alors que le Core attend ").concat(origin, ". ") + "Ouvrir l'app par l'URL d\xe9clar\xe9e (\xab url \xbb de l'entr\xe9e embed / de egen-config.json) ou corriger cette URL.");
|
|
329
|
+
}
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
var handled = connection.handle(event.data);
|
|
333
|
+
if (!handled && (envelope === null || envelope === void 0 ? void 0 : envelope.egen) === EGEN_EMBED_PROTOCOL && envelope.moduleName !== opts.moduleName) {
|
|
334
|
+
warnOnce("name:".concat(envelope.moduleName), "[egen-embed] message ignor\xe9 : l'app s'annonce \xab ".concat(envelope.moduleName, " \xbb mais le Core attend \xab ").concat(opts.moduleName, " \xbb. ") + "La d\xe9claration verrouill\xe9e c\xf4t\xe9 Core est p\xe9rim\xe9e, ou l'app utilise un autre nom que celui de son egen-config.json : " + "relancer \xab yarn external:sync \xbb apr\xe8s tout changement de d\xe9claration.");
|
|
335
|
+
}
|
|
317
336
|
};
|
|
318
337
|
return {
|
|
319
338
|
iframe: iframe,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@egen-civitas/esm-embed-host",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "Hôte (côté Shell/Core) des applications embarquées : iframe sécurisée, poignée de main v2, grants, fournisseurs de capacités, navigation partagée, compatibilité du pont 1.1.",
|
|
6
6
|
"type": "module",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@egen-civitas/esm-embed-client": "^0.
|
|
60
|
+
"@egen-civitas/esm-embed-client": "^0.8.0",
|
|
61
61
|
"@swc/cli": "0.8.1",
|
|
62
62
|
"@swc/core": "1.15.21",
|
|
63
63
|
"@types/node": "^20",
|
|
@@ -69,6 +69,6 @@
|
|
|
69
69
|
"vitest": "^4.1.2"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@egen-civitas/esm-embed-protocol": "^0.
|
|
72
|
+
"@egen-civitas/esm-embed-protocol": "^0.7.0"
|
|
73
73
|
}
|
|
74
74
|
}
|
package/src/host.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sanitizeIframeRights, type CapabilityDenied, type CapabilityGranted, type EffectiveGrants, type IframeRights, type Limits } from '@egen-civitas/esm-embed-protocol';
|
|
1
|
+
import { EGEN_EMBED_PROTOCOL, parseEnvelope, sanitizeIframeRights, type CapabilityDenied, type CapabilityGranted, type EffectiveGrants, type IframeRights, type Limits } from '@egen-civitas/esm-embed-protocol';
|
|
2
2
|
import { createBus } from './bus.js';
|
|
3
3
|
import { HostConnection } from './connection.js';
|
|
4
4
|
import { buildCoreUrl, buildEmbedSrc, coreSubpath, createRateLimiter, stripSensitive, toAppPath, toCorePath, normalizeAppPath, type NavigationOptions } from './navigation.js';
|
|
@@ -26,6 +26,8 @@ export interface EmbedHostOptions {
|
|
|
26
26
|
navigation?: NavigationOptions;
|
|
27
27
|
/** Navigation demandée par l'app vers le Core (défaut : `singleSpaNavigate`). */
|
|
28
28
|
onNavigate?: (to: string) => void;
|
|
29
|
+
/** Où écrire les diagnostics de poignée de main (défaut : `console`). */
|
|
30
|
+
logger?: Pick<Console, 'warn'>;
|
|
29
31
|
/**
|
|
30
32
|
* L'app signale une page introuvable (`navigation.notFound`) : le Shell affiche SA page 404 à la place de l'app.
|
|
31
33
|
* `path` est le chemin de l'app, normalisé et débarrassé des paramètres sensibles (`null` : la page courante de l'app).
|
|
@@ -136,9 +138,38 @@ export function createEmbedHost(opts: EmbedHostOptions): EmbedHost {
|
|
|
136
138
|
onClose: opts.onClose,
|
|
137
139
|
});
|
|
138
140
|
|
|
141
|
+
// Diagnostics : sans eux, un nom de module ou une origine qui ne correspond pas à la déclaration verrouillée côté Core
|
|
142
|
+
// fait échouer la poignée de main EN SILENCE (l'app attend 5 s puis se replie en mode autonome, sans la moindre trace).
|
|
143
|
+
const logger = opts.logger ?? console;
|
|
144
|
+
const warned = new Set<string>();
|
|
145
|
+
const warnOnce = (key: string, message: string) => {
|
|
146
|
+
if (warned.has(key)) return;
|
|
147
|
+
warned.add(key);
|
|
148
|
+
logger.warn(message);
|
|
149
|
+
};
|
|
150
|
+
|
|
139
151
|
const onMessage = (event: MessageEvent) => {
|
|
140
|
-
if (event.source !== iframe.contentWindow
|
|
141
|
-
|
|
152
|
+
if (event.source !== iframe.contentWindow) return; // une autre fenêtre : ignorée sans bruit
|
|
153
|
+
const envelope = parseEnvelope(event.data);
|
|
154
|
+
if (event.origin !== origin) {
|
|
155
|
+
if (envelope?.egen === EGEN_EMBED_PROTOCOL) {
|
|
156
|
+
warnOnce(
|
|
157
|
+
`origin:${event.origin}`,
|
|
158
|
+
`[egen-embed] « ${opts.moduleName} » : message ignoré, l'iframe parle depuis ${event.origin} alors que le Core attend ${origin}. ` +
|
|
159
|
+
`Ouvrir l'app par l'URL déclarée (« url » de l'entrée embed / de egen-config.json) ou corriger cette URL.`
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const handled = connection.handle(event.data);
|
|
165
|
+
if (!handled && envelope?.egen === EGEN_EMBED_PROTOCOL && envelope.moduleName !== opts.moduleName) {
|
|
166
|
+
warnOnce(
|
|
167
|
+
`name:${envelope.moduleName}`,
|
|
168
|
+
`[egen-embed] message ignoré : l'app s'annonce « ${envelope.moduleName} » mais le Core attend « ${opts.moduleName} ». ` +
|
|
169
|
+
`La déclaration verrouillée côté Core est périmée, ou l'app utilise un autre nom que celui de son egen-config.json : ` +
|
|
170
|
+
`relancer « yarn external:sync » après tout changement de déclaration.`
|
|
171
|
+
);
|
|
172
|
+
}
|
|
142
173
|
};
|
|
143
174
|
|
|
144
175
|
return {
|