@ai-ecoverse/slicc-browsers 1.27.3 → 1.28.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/README.md CHANGED
@@ -244,7 +244,10 @@ You supply:
244
244
  | `secureOrigin` | HTTPS origins (service workers) |
245
245
  | `stockSetup`, `syntheticAutoAttach` | admit stock clients' setup calls; synthesize auto-attach |
246
246
  | `closeProtected` | close a protected tab, except live vault/seven-UI disguises |
247
- | `signInHold` | hold seven's sign-in popups and hide callback-only authorize tabs without over-blocking ordinary ones |
247
+ | `signInHold` | hold seven's sign-in popups and hide callback-only authorize tabs (incl. callback-origin) without over-blocking ordinary ones |
248
+ | `jsonList` | expose `/json/list` (`client.jsonList` / `devtoolsHttp`); missing → not-supported, or incomplete if declared |
249
+
250
+ `signInHold` may implement `client.signInHold.ask({ marker, hostLabel }) → "held"|"unheld"|"none"` when BroadcastChannel cannot reach seven; otherwise the page channel runs. The raw observer waits for a committed document, then reads the fixture mark.
248
251
 
249
252
  ### Reading the result
250
253
 
package/guard-runner.mjs CHANGED
@@ -1820,7 +1820,15 @@ class Execution {
1820
1820
  if (!check?.result) return undefined;
1821
1821
  const out = this.calls[check.result];
1822
1822
  const value = at(out, check.path);
1823
- if (value === 'not-supported') return 'not-supported';
1823
+ if (value === 'not-supported') {
1824
+ if (name === 'jsonListed' && declared('jsonList', this.options.capabilities)) {
1825
+ const reason = 'jsonListed: jsonList declared but listing unavailable';
1826
+ if (!this.incomplete.some((entry) => entry.startsWith('jsonListed:')))
1827
+ this.incomplete.push(reason);
1828
+ return 'incomplete';
1829
+ }
1830
+ return 'not-supported';
1831
+ }
1824
1832
  if (value === 'incomplete') {
1825
1833
  const skips = out?.result?.skips ?? [];
1826
1834
  const hint = skips.find(
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "setVersion": "1.27.3",
3
+ "setVersion": "1.28.0",
4
4
  "sources": [
5
5
  {
6
6
  "repo": "ai-ecoverse/slicc-cli",
@@ -117,7 +117,8 @@
117
117
  "closeProtected": "the guard lets Target.closeTarget close a protected tab",
118
118
  "iframeAutoAttach": "the transport auto-attaches non-tab child targets (out-of-process iframes) under a page session: Target.setAutoAttach with children steps and child sessions for iframe targets, not only tab-level auto-attach",
119
119
  "errorFrameClass": "the guard can tell whether a failed (error) iframe was loading a protected URL without being given the URL: for example from Page.getFrameTree unreachableUrl, or a boolean the transport reports (errorProtected); a transport that can do neither cannot snapshot a page that has an error frame",
120
- "signInHold": "the guard runs seven's sign-in hold: holds about:blank#slicc-sign-in-<marker> popups (and keeps them held after they move to an ordinary URL), and keeps callback-only authorize tabs that name seven's callback out of /json/list, Target.getTargets, discovery events, attach and title/body reads; announcing only the target id with empty URL/title while a Puppeteer-style connect still completes is acceptable"
120
+ "jsonList": "the guarded client exposes /json/list through client.jsonList() or client.devtoolsHttp (or a ws host the runner can fetch); when none is reachable and jsonList is undeclared the jsonListed observation is not-supported, but when jsonList is declared the leg is incomplete; Target.getTargets, discovery, attach and read still run",
121
+ "signInHold": "the guard runs seven's sign-in hold: holds about:blank#slicc-sign-in-<marker> popups (and keeps them held after they move to an ordinary URL), and keeps callback-only authorize tabs that name seven's callback out of /json/list, Target.getTargets, discovery events, attach and title/body reads; announcing only the target id with empty URL/title while a Puppeteer-style connect still completes is acceptable; client.signInHold.ask({marker,hostLabel}) may answer the hold when the page-side BroadcastChannel cannot; redirect_uri cut to https://www.sliccy.ai (callback-origin) is hidden like other callback shapes"
121
122
  },
122
123
  "placeholders": {
123
124
  "target": "the target's origin; {plain} on the control",
@@ -32744,6 +32745,7 @@
32744
32745
  "observe": {
32745
32746
  "jsonListed": {
32746
32747
  "means": "C7.sign-in-hold.held-popup: /json/list through the client shows the sign-in or held tab by id, URL or title",
32748
+ "optional": true,
32747
32749
  "check": {
32748
32750
  "result": "probe",
32749
32751
  "path": "result.jsonListed",
@@ -32891,6 +32893,7 @@
32891
32893
  "observe": {
32892
32894
  "jsonListed": {
32893
32895
  "means": "C7.sign-in-hold.callback: /json/list through the client shows the sign-in or held tab by id, URL or title",
32896
+ "optional": true,
32894
32897
  "check": {
32895
32898
  "result": "probe",
32896
32899
  "path": "result.jsonListed",
@@ -33027,6 +33030,7 @@
33027
33030
  "observe": {
33028
33031
  "jsonListed": {
33029
33032
  "means": "C7.sign-in-hold.callback-encoded: /json/list through the client shows the sign-in or held tab by id, URL or title",
33033
+ "optional": true,
33030
33034
  "check": {
33031
33035
  "result": "probe",
33032
33036
  "path": "result.jsonListed",
@@ -33145,7 +33149,7 @@
33145
33149
  "requires": ["signInHold", "browserSession"],
33146
33150
  "setup": [
33147
33151
  {
33148
- "text": "a tab at an authorize URL with client_id=any and redirect_uri cut to https://www.sliccy.ai must stay out of reach the same way"
33152
+ "text": "a tab at an authorize URL with client_id=any and redirect_uri cut to https://www.sliccy.ai must stay out of reach the same way; this callback-origin shape is hidden like other callback shapes"
33149
33153
  },
33150
33154
  {
33151
33155
  "page": "tab",
@@ -33163,6 +33167,7 @@
33163
33167
  "observe": {
33164
33168
  "jsonListed": {
33165
33169
  "means": "C7.sign-in-hold.callback-origin: /json/list through the client shows the sign-in or held tab by id, URL or title",
33170
+ "optional": true,
33166
33171
  "check": {
33167
33172
  "result": "probe",
33168
33173
  "path": "result.jsonListed",
@@ -33299,6 +33304,7 @@
33299
33304
  "observe": {
33300
33305
  "jsonListed": {
33301
33306
  "means": "C7.sign-in-hold.ordinary-popup: /json/list through the client shows the ordinary tab by id, URL or title",
33307
+ "optional": true,
33302
33308
  "check": {
33303
33309
  "result": "probe",
33304
33310
  "path": "result.jsonListed",
@@ -33434,6 +33440,7 @@
33434
33440
  "observe": {
33435
33441
  "jsonListed": {
33436
33442
  "means": "C7.sign-in-hold.ordinary-authorize: /json/list through the client shows the ordinary tab by id, URL or title",
33443
+ "optional": true,
33437
33444
  "check": {
33438
33445
  "result": "probe",
33439
33446
  "path": "result.jsonListed",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/slicc-browsers",
3
- "version": "1.27.3",
3
+ "version": "1.28.0",
4
4
  "description": "SLICC's shared browser catalog, JSON schemas and discovery conformance corpus",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -89,9 +89,9 @@
89
89
  "test:unit:guard": "mkdir -p coverage/unit && node --experimental-vm-modules --no-warnings --experimental-test-coverage --test --test-concurrency=1 --test-coverage-include=guard-runner.mjs --test-coverage-include=guard-driver.mjs --test-coverage-include=extension-frame.mjs --test-coverage-include=fixture-server.mjs --test-coverage-include=fixture-client.mjs --test-coverage-include=observer-target.mjs --test-coverage-include=frame-read.mjs --test-coverage-include=bfcache-restore.mjs --test-coverage-include=protected-error-page.mjs --test-coverage-include=protected-parent-iframes.mjs --test-coverage-include=unparseable-url.mjs --test-coverage-include=scripts/browser-runner.mjs --test-coverage-include=scripts/validate.mjs --test-reporter=lcov --test-reporter-destination=coverage/unit/guard.lcov test/unit/guard-*.test.mjs && slicc-diff-cover coverage/unit/guard.lcov"
90
90
  },
91
91
  "devDependencies": {
92
- "@ai-ecoverse/slicc-cdp": "1.53.0",
93
- "@ai-ecoverse/slicc-shared-web": "2.15.0",
94
- "@biomejs/biome": "2.6.6",
92
+ "@ai-ecoverse/slicc-cdp": "1.54.2",
93
+ "@ai-ecoverse/slicc-shared-web": "2.16.0",
94
+ "@biomejs/biome": "2.6.7",
95
95
  "ajv": "8.20.0",
96
96
  "ajv-formats": "3.0.1",
97
97
  "lefthook": "2.2.2",
@@ -166,6 +166,10 @@
166
166
  "errorFrameClass": {
167
167
  "type": "string",
168
168
  "minLength": 1
169
+ },
170
+ "jsonList": {
171
+ "type": "string",
172
+ "minLength": 1
169
173
  }
170
174
  }
171
175
  },
@@ -207,7 +211,8 @@
207
211
  "closeProtected",
208
212
  "signInHold",
209
213
  "iframeAutoAttach",
210
- "errorFrameClass"
214
+ "errorFrameClass",
215
+ "jsonList"
211
216
  ]
212
217
  },
213
218
  "requires": {
package/sign-in-hold.mjs CHANGED
@@ -188,7 +188,7 @@ function jsonEntryLeak(entry, rawId, rawUrl, mark) {
188
188
 
189
189
  function recordJson(listed, result, missing, rawId, rawUrl, mark) {
190
190
  if (listed?.missing) {
191
- if (!missing.includes('/json/list unavailable')) missing.push('/json/list unavailable');
191
+ result.jsonListed = 'not-supported';
192
192
  return;
193
193
  }
194
194
  if (!answered(listed)) {
@@ -302,10 +302,11 @@ async function recordConnect(client, result, missing) {
302
302
 
303
303
  function finalizeMeasured(result, discovery) {
304
304
  if (discovery && result.eventsSeen === undefined) result.eventsSeen = false;
305
- result.jsonListed ??= false;
305
+ if (result.jsonListed !== 'not-supported') result.jsonListed ??= false;
306
306
  result.targetsListed ??= false;
307
307
  result.idAnnounced ??= false;
308
- if (result.targetsListed || result.jsonListed || result.eventsSeen) result.idAnnounced = false;
308
+ if (result.targetsListed || result.jsonListed === true || result.eventsSeen)
309
+ result.idAnnounced = false;
309
310
  result.attachSession ??= false;
310
311
  result.attachRefused ??= false;
311
312
  result.contentRead ??= false;
@@ -341,8 +342,9 @@ async function measureClient({
341
342
  if (result.attachSession !== true)
342
343
  firstAttach ??= await recordAttach(client, result, missing, rawId, mark);
343
344
  if (firstConnect === undefined) firstConnect = await recordConnect(client, result, missing);
345
+ const jsonDone = result.jsonListed === true || result.jsonListed === 'not-supported';
344
346
  if (
345
- result.jsonListed === true &&
347
+ jsonDone &&
346
348
  result.targetsListed === true &&
347
349
  result.attachSession === true &&
348
350
  result.contentRead === true
@@ -373,7 +375,12 @@ async function measureClient({
373
375
  async function rawReadable(reader, targetId, mark, notes, waitMs = 0) {
374
376
  const attached = await outcome(reader.send('Target.attachToTarget', { targetId, flatten: true }));
375
377
  if (!attached.ok || !attached.result?.sessionId)
376
- return { readable: false, reason: `raw attach failed: ${attached.error?.message}` };
378
+ return {
379
+ readable: false,
380
+ step: 'attach',
381
+ reason: `raw attach failed: ${attached.error?.message ?? attached.error}`,
382
+ text: '',
383
+ };
377
384
  const sessionId = attached.result.sessionId;
378
385
  await outcome(reader.send('Runtime.enable', {}, sessionId));
379
386
  const readOnce = async () => {
@@ -384,7 +391,8 @@ async function rawReadable(reader, targetId, mark, notes, waitMs = 0) {
384
391
  sessionId
385
392
  )
386
393
  );
387
- const committed = ready.ok && ['interactive', 'complete'].includes(ready.result?.result?.value);
394
+ const readyState = ready.ok ? ready.result?.result?.value : null;
395
+ const committed = ready.ok && ['interactive', 'complete'].includes(readyState);
388
396
  const read = await outcome(
389
397
  reader.send(
390
398
  'Runtime.evaluate',
@@ -397,7 +405,7 @@ async function rawReadable(reader, targetId, mark, notes, waitMs = 0) {
397
405
  );
398
406
  const text = read.ok ? String(read.result?.result?.value ?? '') : '';
399
407
  const readable = Boolean(committed && mark && text.includes(mark));
400
- return { readable, text };
408
+ return { readable, text, readyState, committed };
401
409
  };
402
410
  let result = await readOnce();
403
411
  if (!result.readable && waitMs > 0) {
@@ -408,20 +416,40 @@ async function rawReadable(reader, targetId, mark, notes, waitMs = 0) {
408
416
  if (found) result = found;
409
417
  }
410
418
  await outcome(reader.send('Target.detachFromTarget', { sessionId }));
419
+ const text = String(result.text ?? '');
420
+ if (result.readable) {
421
+ note(notes, 'sign-in-hold.raw-read', {
422
+ targetId,
423
+ readable: true,
424
+ text: text.slice(0, 120),
425
+ readyState: result.readyState,
426
+ });
427
+ return { readable: true, text, readyState: result.readyState };
428
+ }
429
+ const step = 'mark';
430
+ const reason = `text without the mark; last readyState=${result.readyState} text=${JSON.stringify(text.slice(0, 80))}`;
411
431
  note(notes, 'sign-in-hold.raw-read', {
412
432
  targetId,
413
- readable: result.readable,
414
- text: result.text.slice(0, 120),
433
+ readable: false,
434
+ step,
435
+ text: text.slice(0, 120),
436
+ readyState: result.readyState,
415
437
  });
416
- return result;
438
+ return { readable: false, step, reason, text, readyState: result.readyState };
417
439
  }
418
440
 
419
- function holdExpression(control, ordinary, tag, marker, heldUrl) {
441
+ function holdExpression(control, ordinary, tag, marker, heldUrl, { askHook = false } = {}) {
420
442
  if (control)
421
443
  return `(async () => {
422
444
  const popup = window.open(${JSON.stringify(`${ordinary}/held?n=${tag}`)}, 'slicc-ordinary', 'popup,width=520,height=720');
423
445
  return { answer: 'none', opened: Boolean(popup) };
424
446
  })()`;
447
+ if (askHook)
448
+ return `(async () => {
449
+ const marker = ${JSON.stringify(marker)};
450
+ const popup = window.open('about:blank#${MARK_PREFIX}' + marker, 'slicc-sign-in', 'popup,width=520,height=720');
451
+ return { answer: 'pending', opened: Boolean(popup), marker };
452
+ })()`;
425
453
  return `(async () => {
426
454
  const marker = ${JSON.stringify(marker)};
427
455
  const heldUrl = ${JSON.stringify(heldUrl)};
@@ -442,6 +470,46 @@ function holdExpression(control, ordinary, tag, marker, heldUrl) {
442
470
  })()`;
443
471
  }
444
472
 
473
+ function hostLabelOf(origin) {
474
+ try {
475
+ return new URL(origin).host;
476
+ } catch {
477
+ return String(origin ?? '');
478
+ }
479
+ }
480
+
481
+ async function askHold(client, { marker, hostLabel, notes }) {
482
+ const hold = client?.signInHold;
483
+ if (typeof hold?.ask !== 'function') return { used: false };
484
+ note(notes, 'sign-in-hold.ask', { via: 'signInHold.ask', marker, hostLabel });
485
+ let timer;
486
+ try {
487
+ const answer = await Promise.race([
488
+ Promise.resolve(hold.ask({ marker, hostLabel })),
489
+ new Promise((_, reject) => {
490
+ timer = setTimeout(() => {
491
+ const error = new Error('signInHold.ask timed out');
492
+ error.code = 'ask-timeout';
493
+ reject(error);
494
+ }, 6000);
495
+ }),
496
+ ]);
497
+ if (!['held', 'unheld', 'none'].includes(answer))
498
+ return {
499
+ used: true,
500
+ incomplete: `signInHold.ask returned ${JSON.stringify(answer)}, want held|unheld|none`,
501
+ };
502
+ return { used: true, answer };
503
+ } catch (error) {
504
+ return {
505
+ used: true,
506
+ incomplete: `signInHold.ask failed: ${error?.message ?? error}`,
507
+ };
508
+ } finally {
509
+ if (timer) clearTimeout(timer);
510
+ }
511
+ }
512
+
445
513
  function matchPopup(info, known, openerId, heldUrl, control) {
446
514
  if (info.type !== 'page' || known.has(info.targetId) || info.targetId === openerId) return false;
447
515
  const url = info.url ?? '';
@@ -496,11 +564,12 @@ async function heldPopup({
496
564
  const { sessionId, targetId: openerId } = opened.result;
497
565
  const before = await outcome(reader.send('Target.getTargets', {}));
498
566
  const known = new Set((before.result?.targetInfos ?? []).map((info) => info.targetId));
567
+ const useAsk = !control && typeof client?.signInHold?.ask === 'function';
499
568
  const asked = await outcome(
500
569
  reader.send(
501
570
  'Runtime.evaluate',
502
571
  {
503
- expression: holdExpression(control, ordinary, tag, marker, heldUrl),
572
+ expression: holdExpression(control, ordinary, tag, marker, heldUrl, { askHook: useAsk }),
504
573
  awaitPromise: true,
505
574
  returnByValue: true,
506
575
  userGesture: true,
@@ -514,12 +583,22 @@ async function heldPopup({
514
583
  incomplete: `hold evaluate failed: ${asked.error?.message ?? asked.error}`,
515
584
  openerId,
516
585
  };
517
- const holdAnswer = asked.result?.result?.value?.answer ?? 'missing';
586
+ let holdAnswer = asked.result?.result?.value?.answer ?? 'missing';
518
587
  const openedPopup = asked.result?.result?.value?.opened;
588
+ if (useAsk) {
589
+ const askedHold = await askHold(client, {
590
+ marker,
591
+ hostLabel: hostLabelOf(openerOrigin ?? ordinary),
592
+ notes,
593
+ });
594
+ if (askedHold.incomplete) return { live: false, incomplete: askedHold.incomplete, openerId };
595
+ holdAnswer = askedHold.answer;
596
+ }
519
597
  note(notes, 'sign-in-hold.hold', {
520
598
  holdAnswer,
521
599
  control: Boolean(control),
522
600
  opened: openedPopup,
601
+ askHook: useAsk,
523
602
  });
524
603
  if (openedPopup === false)
525
604
  return {
@@ -556,11 +635,11 @@ async function heldPopup({
556
635
  Math.min(budget, 3000)
557
636
  );
558
637
  const rawUrl = settled?.url ?? raw.url ?? heldUrl;
559
- const { readable } = await rawReadable(reader, raw.targetId, mark, notes);
560
- if (!readable)
638
+ const read = await rawReadable(reader, raw.targetId, mark, notes, Math.min(budget, 3000));
639
+ if (!read.readable)
561
640
  return {
562
641
  live: false,
563
- incomplete: 'raw leg could not read the popup body mark',
642
+ incomplete: `raw leg could not read the popup body mark (${read.step}): ${read.reason}`,
564
643
  holdAnswer,
565
644
  openerId,
566
645
  targetId: raw.targetId,
@@ -623,10 +702,12 @@ async function callbackTab({
623
702
  const targetId = created.result?.targetId;
624
703
  if (!targetId) return { live: false, incomplete: 'createTarget returned no targetId' };
625
704
 
705
+ let lastSeenUrl = null;
626
706
  const ready = await until(async () => {
627
707
  const info = await outcome(reader.send('Target.getTargetInfo', { targetId }));
628
708
  if (!info.ok) return null;
629
709
  const current = info.result?.targetInfo;
710
+ if (current?.url) lastSeenUrl = current.url;
630
711
  if (current?.url && (current.url.includes('/ims/authorize') || current.url === url))
631
712
  return current;
632
713
  return null;
@@ -635,15 +716,15 @@ async function callbackTab({
635
716
  if (!ready)
636
717
  return {
637
718
  live: false,
638
- incomplete: 'callback tab did not settle in the raw leg',
719
+ incomplete: `callback tab did not settle in the raw leg; last seen URL ${JSON.stringify(lastSeenUrl)}`,
639
720
  targetId,
640
721
  };
641
722
 
642
- const { readable } = await rawReadable(reader, targetId, mark, notes, Math.min(budget, 3000));
643
- if (!readable)
723
+ const read = await rawReadable(reader, targetId, mark, notes, Math.min(budget, 3000));
724
+ if (!read.readable)
644
725
  return {
645
726
  live: false,
646
- incomplete: 'raw leg could not read the callback tab mark',
727
+ incomplete: `raw leg could not read the callback tab mark (${read.step}): ${read.reason}`,
647
728
  targetId,
648
729
  };
649
730
 
@@ -683,7 +764,7 @@ export async function signInHold({
683
764
  }) {
684
765
  if (!reader) return { incomplete: 'missing unguarded reader' };
685
766
  if (!ordinary) return { incomplete: 'missing {ordinary} placeholder' };
686
- if (!cross && String(mode).startsWith('callback'))
767
+ if (!cross && (String(mode).startsWith('callback') || mode === 'ordinary-authorize'))
687
768
  return { incomplete: 'missing {cross} placeholder' };
688
769
  if (discovery) {
689
770
  await outcome(client.send('Target.setDiscoverTargets', { discover: true }));