@egen-civitas/esm-embed-testing 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,29 @@
1
+ # @egen-civitas/esm-embed-testing
2
+
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 18cec62: Sécurité : `api.fetch` avec `path` est désormais **deny-by-default** (liste `paths` obligatoire dans le grant, normalisation anti-contournement : `..`, `%2e`, `//`…) pour qu'une app embarquée ne puisse pas appeler tout l'API du Core avec la session de l'utilisateur ; `negotiateCapabilities` ignore les entrées malformées ; tests de fuzz déterministes. Outillage : `egen-embed-check` (manifeste, capacités, `frame-ancestors`).
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [18cec62]
12
+ - @egen-civitas/esm-embed-protocol@0.2.0
13
+ - @egen-civitas/esm-embed-host@0.2.0
14
+ - @egen-civitas/esm-embed-client@0.1.1
15
+
16
+ ## 0.1.0
17
+
18
+ ### Minor Changes
19
+
20
+ - d70760d: Nouveau paquet : hôte de test en mémoire (`createTestHost`), suite de conformité du protocole v2 (`defineConformance`), simulateur de Shell (`egen-embed-sim`).
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies [10f0584]
25
+ - Updated dependencies [744cd20]
26
+ - Updated dependencies [cf9d90d]
27
+ - @egen-civitas/esm-embed-client@0.1.0
28
+ - @egen-civitas/esm-embed-protocol@0.1.0
29
+ - @egen-civitas/esm-embed-host@0.1.0
package/README.md CHANGED
@@ -1,3 +1,41 @@
1
- # Temporary Holding Version
1
+ # @egen-civitas/esm-embed-testing
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Développer et tester une app embarquée **sans le Core**. Spécification : `docs/integration-apps/17-sdk-embed-protocole-v2.md` (dépôt Core).
4
+
5
+ ## 1. Hôte de test en mémoire (tests unitaires de votre app)
6
+
7
+ Un vrai `HostConnection` (mêmes grants, mêmes refus, même dispatch fermé que le Core), sans navigateur :
8
+
9
+ ```ts
10
+ import { connectToEgen } from '@egen-civitas/esm-embed-client';
11
+ import { createTestHost } from '@egen-civitas/esm-embed-testing';
12
+
13
+ const sim = createTestHost({
14
+ session: { authenticated: true, user: { display: 'Sam' } },
15
+ manifestCapabilities: { notifications: {} },
16
+ approved: { notifications: {} },
17
+ });
18
+ const egen = await connectToEgen({ ...sim.connectOptions, capabilities: ['session', 'notifications'] });
19
+ await egen.notifications.show({ kind: 'success', title: 'OK' });
20
+ expect(sim.notifications).toEqual([{ kind: 'success', title: 'OK' }]);
21
+ sim.emit.theme({ mode: 'dark', tokens: { '--primary': '#000' } }); // le Core pousse un changement
22
+ ```
23
+
24
+ `sim.calls` (journal des services sollicités), `sim.published`, `sim.tools` + `sim.invokeTool()` (agent IA), `sim.emit.*`.
25
+
26
+ ## 2. Suite de conformité
27
+
28
+ ```ts
29
+ import { describe, it, expect } from 'vitest';
30
+ import { defineConformance } from '@egen-civitas/esm-embed-testing';
31
+ defineConformance(myConnectFn, { describe, it, expect }); // SDK officiel ou implémentation tierce de même forme
32
+ ```
33
+
34
+ ## 3. Simulateur de Shell dans le navigateur
35
+
36
+ ```bash
37
+ npx egen-embed-sim --app http://localhost:3000 --manifest egen-app.json
38
+ # → déclarez dans l'app : hostOrigins: ['http://127.0.0.1:4100']
39
+ ```
40
+
41
+ Page avec votre app dans une iframe, l'hôte EGEN réel (`esm-embed-host`), des boutons (thème, langue, session, événement) et le journal de tous les échanges. Par défaut les capacités demandées par le manifeste sont approuvées ; `--strict` n'approuve que les capacités « par défaut ».
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env node
2
+ import { readFile } from 'node:fs/promises';
3
+ import { checkEmbedApp, hasErrors } from '../dist/check.js';
4
+
5
+ const args = process.argv.slice(2);
6
+ const opt = (n) => {
7
+ const i = args.indexOf(n);
8
+ return i === -1 ? undefined : args[i + 1];
9
+ };
10
+ if (args.includes('--help') || !opt('--manifest')) {
11
+ console.log(`egen-embed-check — vérifie une app embarquée (manifeste, capacités, intégrabilité en iframe)
12
+
13
+ Usage : egen-embed-check --manifest egen-app.json [--shell https://egen.exemple.org] [--probe] [--allow-localhost]
14
+
15
+ --shell origine du Shell EGEN (contrôle CSP frame-ancestors)
16
+ --probe interroge l'URL de l'app (en-têtes X-Frame-Options / CSP)
17
+ --allow-localhost tolère http://localhost (développement)
18
+
19
+ Code de sortie : 1 si au moins une erreur.`);
20
+ process.exit(opt('--manifest') ? 0 : 1);
21
+ }
22
+ let manifest;
23
+ try {
24
+ manifest = JSON.parse(await readFile(opt('--manifest'), 'utf8'));
25
+ } catch (e) {
26
+ console.error(`✗ manifeste illisible : ${e.message}`);
27
+ process.exit(1);
28
+ }
29
+ const issues = await checkEmbedApp({ manifest, shellOrigin: opt('--shell'), probe: args.includes('--probe'), allowInsecureLocalhost: args.includes('--allow-localhost') });
30
+ const sym = { error: '✗', warn: '!', info: 'i' };
31
+ for (const i of issues) console.log(`${sym[i.level]} ${i.message}`);
32
+ if (!issues.length) console.log('✔ aucune remarque');
33
+ process.exit(hasErrors(issues) ? 1 : 0);
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+ import { readFile } from 'node:fs/promises';
3
+ import { startSimulator } from '../dist/server.js';
4
+
5
+ const args = process.argv.slice(2);
6
+ const opt = (name) => {
7
+ const i = args.indexOf(name);
8
+ return i === -1 ? undefined : args[i + 1];
9
+ };
10
+ if (args.includes('--help') || !opt('--app')) {
11
+ console.log(`egen-embed-sim — simulateur de Shell EGEN pour développer une app embarquée sans le Core
12
+
13
+ Usage : egen-embed-sim --app <url> [--manifest egen-app.json] [--port 4100] [--strict] [--session session.json]
14
+
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)
17
+ --strict n'approuver que les capacités « par défaut » (voir doc 17 §5)
18
+ --session fichier JSON de la session simulée`);
19
+ process.exit(opt('--app') ? 0 : 1);
20
+ }
21
+ const read = async (p) => (p ? JSON.parse(await readFile(p, 'utf8')) : undefined);
22
+ const sim = await startSimulator({
23
+ app: opt('--app'),
24
+ port: opt('--port') ? Number(opt('--port')) : undefined,
25
+ manifest: await read(opt('--manifest')),
26
+ session: await read(opt('--session')),
27
+ strict: args.includes('--strict'),
28
+ });
29
+ console.log(`Simulateur de Shell EGEN : ${sim.url}\nDéclarez dans votre app : hostOrigins: ['${sim.url}']`);
@@ -0,0 +1,18 @@
1
+ export interface CheckIssue {
2
+ level: 'error' | 'warn' | 'info';
3
+ message: string;
4
+ }
5
+ export interface CheckOptions {
6
+ /** Manifeste `egen-app.json` déjà lu. */
7
+ manifest: unknown;
8
+ /** Origine du Shell EGEN (ex. `https://egen.exemple.org`) : active le contrôle d'intégration en iframe. */
9
+ shellOrigin?: string;
10
+ /** Interroge réellement l'URL de l'app (en-têtes `frame-ancestors`, `X-Frame-Options`). */
11
+ probe?: boolean;
12
+ allowInsecureLocalhost?: boolean;
13
+ fetchImpl?: typeof fetch;
14
+ }
15
+ /** Vérificateur d'app embarquée (`egen-embed-check`) : manifeste, hygiène des capacités demandées, intégrabilité en iframe. */
16
+ export declare function checkEmbedApp(o: CheckOptions): Promise<CheckIssue[]>;
17
+ export declare const hasErrors: (issues: CheckIssue[]) => boolean;
18
+ //# sourceMappingURL=check.d.ts.map
@@ -0,0 +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,CA2D1E;AAED,eAAO,MAAM,SAAS,GAAI,QAAQ,UAAU,EAAE,YAA4C,CAAC"}
package/dist/check.js ADDED
@@ -0,0 +1,337 @@
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 { CAPABILITIES, FORBIDDEN_SESSION_FIELDS, patternCovers, validateManifest } from '@egen-civitas/esm-embed-protocol';
130
+ /** 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) {
131
+ return _async_to_generator(function() {
132
+ var _caps_session, _caps_events, _caps_aitools, _caps_api, _caps_api1, issues, add, r, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _$e, m, caps, needApproval, fields, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, f, pub, own, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, p, tools, apiPaths, _iteratorNormalCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, p1, hosts, _iteratorNormalCompletion4, _didIteratorError4, _iteratorError4, _iterator4, _step4, h, _o_fetchImpl, f1, _res_headers_get, _exec_, _exec, res, xfo, csp, fa, tokens, e;
133
+ return _ts_generator(this, function(_state) {
134
+ switch(_state.label){
135
+ case 0:
136
+ issues = [];
137
+ add = function add(level, message) {
138
+ return issues.push({
139
+ level: level,
140
+ message: message
141
+ });
142
+ };
143
+ r = validateManifest(o.manifest, {
144
+ allowInsecureLocalhost: o.allowInsecureLocalhost
145
+ });
146
+ if (!r.ok) {
147
+ _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
148
+ try {
149
+ for(_iterator = r.errors[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
150
+ _$e = _step.value;
151
+ add('error', _$e);
152
+ }
153
+ } catch (err) {
154
+ _didIteratorError = true;
155
+ _iteratorError = err;
156
+ } finally{
157
+ try {
158
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
159
+ _iterator.return();
160
+ }
161
+ } finally{
162
+ if (_didIteratorError) {
163
+ throw _iteratorError;
164
+ }
165
+ }
166
+ }
167
+ return [
168
+ 2,
169
+ issues
170
+ ];
171
+ }
172
+ m = r.manifest;
173
+ caps = m.capabilities;
174
+ needApproval = Object.keys(caps).filter(function(id) {
175
+ return !CAPABILITIES[id].defaultGrant;
176
+ });
177
+ if (needApproval.length) add('info', "Capacit\xe9s \xe0 faire approuver par l'op\xe9rateur (grants) : ".concat(needApproval.join(', ')));
178
+ fields = (_caps_session = caps.session) === null || _caps_session === void 0 ? void 0 : _caps_session.fields;
179
+ if (Array.isArray(fields)) {
180
+ _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
181
+ try {
182
+ for(_iterator1 = fields[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
183
+ f = _step1.value;
184
+ if (FORBIDDEN_SESSION_FIELDS.includes(String(f).split('.')[0])) add('error', "session.fields : \xab ".concat(f, " \xbb ne sera jamais transmis (identifiant de session ou jeton)"));
185
+ }
186
+ } catch (err) {
187
+ _didIteratorError1 = true;
188
+ _iteratorError1 = err;
189
+ } finally{
190
+ try {
191
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
192
+ _iterator1.return();
193
+ }
194
+ } finally{
195
+ if (_didIteratorError1) {
196
+ throw _iteratorError1;
197
+ }
198
+ }
199
+ }
200
+ }
201
+ pub = (_caps_events = caps.events) === null || _caps_events === void 0 ? void 0 : _caps_events.publish;
202
+ if (Array.isArray(pub)) {
203
+ own = "app.".concat(m.route, ".*");
204
+ _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = undefined;
205
+ try {
206
+ for(_iterator2 = pub[Symbol.iterator](); !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true){
207
+ p = _step2.value;
208
+ if (p === '*' || /^\*/.test(String(p))) add('error', "events.publish : le motif \xab ".concat(p, " \xbb n'est pas support\xe9 (nommer le pr\xe9fixe, ex. ").concat(own, ")"));
209
+ else if (!patternCovers(own, String(p).replace(/\.\*$/, '.x'))) add('warn', "events.publish : \xab ".concat(p, " \xbb sort de l'espace conseill\xe9 ").concat(own));
210
+ }
211
+ } catch (err) {
212
+ _didIteratorError2 = true;
213
+ _iteratorError2 = err;
214
+ } finally{
215
+ try {
216
+ if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
217
+ _iterator2.return();
218
+ }
219
+ } finally{
220
+ if (_didIteratorError2) {
221
+ throw _iteratorError2;
222
+ }
223
+ }
224
+ }
225
+ }
226
+ tools = (_caps_aitools = caps['ai-tools']) === null || _caps_aitools === void 0 ? void 0 : _caps_aitools.tools;
227
+ if (Array.isArray(tools) && tools.some(function(t) {
228
+ return !String(t).includes('.');
229
+ })) add('warn', 'ai-tools.tools : préférer des noms d’outils préfixés (ex. studio.apply) pour éviter les collisions');
230
+ if (caps.api && !(Array.isArray(caps.api.paths) && caps.api.paths.length) && !(Array.isArray(caps.api.hosts) && caps.api.hosts.length)) add('warn', 'api : ni paths ni hosts demandés : aucun appel ne sera possible (deny-by-default)');
231
+ apiPaths = (_caps_api = caps.api) === null || _caps_api === void 0 ? void 0 : _caps_api.paths;
232
+ if (Array.isArray(apiPaths)) {
233
+ _iteratorNormalCompletion3 = true, _didIteratorError3 = false, _iteratorError3 = undefined;
234
+ try {
235
+ for(_iterator3 = apiPaths[Symbol.iterator](); !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true){
236
+ p1 = _step3.value;
237
+ if (p1 === '/*' || p1 === '*') add('warn', "api.paths : \xab ".concat(p1, " \xbb ouvre toute l'API du Core avec la session de l'utilisateur ; nommer les chemins n\xe9cessaires"));
238
+ }
239
+ } catch (err) {
240
+ _didIteratorError3 = true;
241
+ _iteratorError3 = err;
242
+ } finally{
243
+ try {
244
+ if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
245
+ _iterator3.return();
246
+ }
247
+ } finally{
248
+ if (_didIteratorError3) {
249
+ throw _iteratorError3;
250
+ }
251
+ }
252
+ }
253
+ }
254
+ hosts = (_caps_api1 = caps.api) === null || _caps_api1 === void 0 ? void 0 : _caps_api1.hosts;
255
+ if (Array.isArray(hosts)) {
256
+ _iteratorNormalCompletion4 = true, _didIteratorError4 = false, _iteratorError4 = undefined;
257
+ try {
258
+ for(_iterator4 = hosts[Symbol.iterator](); !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true){
259
+ h = _step4.value;
260
+ if (!/^https:\/\//i.test(String(h))) add('error', "api.hosts : \xab ".concat(h, " \xbb doit \xeatre une origine https"));
261
+ }
262
+ } catch (err) {
263
+ _didIteratorError4 = true;
264
+ _iteratorError4 = err;
265
+ } finally{
266
+ try {
267
+ if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
268
+ _iterator4.return();
269
+ }
270
+ } finally{
271
+ if (_didIteratorError4) {
272
+ throw _iteratorError4;
273
+ }
274
+ }
275
+ }
276
+ }
277
+ if (m.technology === 'nextjs' && m.navigation.mode === 'none') add('info', 'Next.js avec navigation « none » : l’URL du Core ne reflétera pas la page courante (partage de lien, F5)');
278
+ if (!caps.lifecycle && !caps.navigation) add('info', 'Aucune capacité navigation/lifecycle demandée : l’app ne pourra ni redimensionner l’iframe ni signaler qu’elle est prête (valeurs par défaut accordées si utilisées)');
279
+ if (!o.probe) return [
280
+ 3,
281
+ 4
282
+ ];
283
+ f1 = (_o_fetchImpl = o.fetchImpl) !== null && _o_fetchImpl !== void 0 ? _o_fetchImpl : fetch;
284
+ _state.label = 1;
285
+ case 1:
286
+ _state.trys.push([
287
+ 1,
288
+ 3,
289
+ ,
290
+ 4
291
+ ]);
292
+ return [
293
+ 4,
294
+ f1(m.url, {
295
+ redirect: 'manual',
296
+ signal: AbortSignal.timeout(10000)
297
+ })
298
+ ];
299
+ case 2:
300
+ res = _state.sent();
301
+ if (res.status >= 400) add('warn', "L'URL de l'app r\xe9pond HTTP ".concat(res.status));
302
+ if (res.status >= 300 && res.status < 400) add('info', "L'URL de l'app redirige (HTTP ".concat(res.status, ") : v\xe9rifier que la cible reste dans la m\xeame origine"));
303
+ xfo = res.headers.get('x-frame-options');
304
+ csp = (_res_headers_get = res.headers.get('content-security-policy')) !== null && _res_headers_get !== void 0 ? _res_headers_get : '';
305
+ fa = (_exec = /frame-ancestors\s+([^;]*)/i.exec(csp)) === null || _exec === void 0 ? void 0 : (_exec_ = _exec[1]) === null || _exec_ === void 0 ? void 0 : _exec_.trim();
306
+ if (xfo && /deny|sameorigin/i.test(xfo) && !fa) add('error', "X-Frame-Options: ".concat(xfo, " interdit l'int\xe9gration en iframe par le Shell (utiliser CSP frame-ancestors)"));
307
+ else if (fa !== undefined) {
308
+ tokens = fa.split(/\s+/);
309
+ if (o.shellOrigin && !tokens.includes('*') && !tokens.includes(o.shellOrigin)) add('error', "CSP frame-ancestors (".concat(fa, ") n'autorise pas le Shell ").concat(o.shellOrigin));
310
+ if (tokens.includes('*')) add('warn', 'CSP frame-ancestors « * » : n’importe quel site peut intégrer l’app (clickjacking) ; nommer l’origine du Shell');
311
+ if (tokens.includes("'none'")) add('error', "CSP frame-ancestors 'none' : intégration impossible");
312
+ } else add('warn', 'Aucune restriction frame-ancestors : l’app peut être intégrée par n’importe quel site (clickjacking) ; limiter à l’origine du Shell');
313
+ return [
314
+ 3,
315
+ 4
316
+ ];
317
+ case 3:
318
+ e = _state.sent();
319
+ add('warn', "URL de l'app injoignable (".concat(e.message, ")"));
320
+ return [
321
+ 3,
322
+ 4
323
+ ];
324
+ case 4:
325
+ return [
326
+ 2,
327
+ issues
328
+ ];
329
+ }
330
+ });
331
+ })();
332
+ }
333
+ export var hasErrors = function hasErrors(issues) {
334
+ return issues.some(function(i) {
335
+ return i.level === 'error';
336
+ });
337
+ };
@@ -0,0 +1,13 @@
1
+ import type { ConnectOptions, EgenClient } from '@egen-civitas/esm-embed-client';
2
+ export type ConnectFn = (options: ConnectOptions) => Promise<EgenClient>;
3
+ export interface ConformanceApi {
4
+ describe(name: string, fn: () => void): void;
5
+ it(name: string, fn: () => Promise<void> | void): void;
6
+ expect: (value: any) => any;
7
+ }
8
+ /**
9
+ * Suite de conformité du protocole v2 pour un client (le SDK, ou toute implémentation tierce qui expose la même forme).
10
+ * Utilisation (Vitest/Jest) : `defineConformance(connectToEgen, { describe, it, expect })`.
11
+ */
12
+ export declare function defineConformance(connect: ConnectFn, t: ConformanceApi): void;
13
+ //# sourceMappingURL=conformance.d.ts.map
@@ -0,0 +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"}