@ai-ecoverse/slicc-browsers 1.27.2 → 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
@@ -232,6 +232,7 @@ You supply:
232
232
  | --- | --- |
233
233
  | `autoAttach` | auto-attach to child targets such as popups and iframes |
234
234
  | `iframeAutoAttach` | auto-attach non-tab child targets (out-of-process iframes) under a page session |
235
+ | `errorFrameClass` | tell whether a failed (error) iframe was loading a protected URL, without being given the URL (for example from `unreachableUrl` in `Page.getFrameTree`, or a transport boolean) |
235
236
  | `browserSession` | send commands on the browser session, not only a page |
236
237
  | `browserContexts` | create isolated browser contexts |
237
238
  | `discovery` | report target create/change without a session |
@@ -243,7 +244,10 @@ You supply:
243
244
  | `secureOrigin` | HTTPS origins (service workers) |
244
245
  | `stockSetup`, `syntheticAutoAttach` | admit stock clients' setup calls; synthesize auto-attach |
245
246
  | `closeProtected` | close a protected tab, except live vault/seven-UI disguises |
246
- | `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.
247
251
 
248
252
  ### Reading the result
249
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.2",
3
+ "setVersion": "1.28.0",
4
4
  "sources": [
5
5
  {
6
6
  "repo": "ai-ecoverse/slicc-cli",
@@ -116,7 +116,9 @@
116
116
  "secureOrigin": "the fixture and page origins are secure contexts (HTTPS), so service worker registration is available",
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
- "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"
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
+ "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"
120
122
  },
121
123
  "placeholders": {
122
124
  "target": "the target's origin; {plain} on the control",
@@ -24378,7 +24380,8 @@
24378
24380
  {
24379
24381
  "page": "framed",
24380
24382
  "from": "{ordinary}",
24381
- "url": "{network-error}"
24383
+ "url": "{network-error}",
24384
+ "requires": ["errorFrameClass"]
24382
24385
  },
24383
24386
  {
24384
24387
  "settle": {
@@ -24421,7 +24424,7 @@
24421
24424
  }
24422
24425
  ],
24423
24426
  "targets": ["network-error"],
24424
- "requires": ["browserSession"],
24427
+ "requires": ["browserSession", "errorFrameClass"],
24425
24428
  "observe": {
24426
24429
  "errorSeen": {
24427
24430
  "means": "Chrome reported a failed ordinary document request before the tab navigated away",
@@ -32742,6 +32745,7 @@
32742
32745
  "observe": {
32743
32746
  "jsonListed": {
32744
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,
32745
32749
  "check": {
32746
32750
  "result": "probe",
32747
32751
  "path": "result.jsonListed",
@@ -32889,6 +32893,7 @@
32889
32893
  "observe": {
32890
32894
  "jsonListed": {
32891
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,
32892
32897
  "check": {
32893
32898
  "result": "probe",
32894
32899
  "path": "result.jsonListed",
@@ -33025,6 +33030,7 @@
33025
33030
  "observe": {
33026
33031
  "jsonListed": {
33027
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,
33028
33034
  "check": {
33029
33035
  "result": "probe",
33030
33036
  "path": "result.jsonListed",
@@ -33143,7 +33149,7 @@
33143
33149
  "requires": ["signInHold", "browserSession"],
33144
33150
  "setup": [
33145
33151
  {
33146
- "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"
33147
33153
  },
33148
33154
  {
33149
33155
  "page": "tab",
@@ -33161,6 +33167,7 @@
33161
33167
  "observe": {
33162
33168
  "jsonListed": {
33163
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,
33164
33171
  "check": {
33165
33172
  "result": "probe",
33166
33173
  "path": "result.jsonListed",
@@ -33297,6 +33304,7 @@
33297
33304
  "observe": {
33298
33305
  "jsonListed": {
33299
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,
33300
33308
  "check": {
33301
33309
  "result": "probe",
33302
33310
  "path": "result.jsonListed",
@@ -33432,6 +33440,7 @@
33432
33440
  "observe": {
33433
33441
  "jsonListed": {
33434
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,
33435
33444
  "check": {
33436
33445
  "result": "probe",
33437
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.2",
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",
@@ -78,7 +78,7 @@
78
78
  "validate": "node scripts/validate.mjs",
79
79
  "lint": "slicc-lint && test -z \"$(gofmt -l .)\" && go mod tidy -diff && go vet ./... && GOOS=darwin go vet ./... && GOOS=windows go vet ./... && golangci-lint run && cargo fmt --check && cargo clippy --all-features --all-targets -- -D warnings && cargo check --target wasm32-wasip1 --no-default-features && cargo check --target wasm32-wasip1 --features serde && cargo check --target wasm32-wasip1 --all-features",
80
80
  "format": "biome check --write . && gofmt -w . && cargo fmt",
81
- "test": "export PATH=\"$HOME/.cargo/bin:$PATH\" && node --test --test-concurrency=1 test/integration/debugger-stage1-packaging.test.mjs test/integration/debugger-raw-control.test.mjs test/integration/debugger-cleanup.test.mjs test/integration/debugger-stage1-install-vectors.test.mjs test/integration/protected-premise.test.mjs test/integration/debugger-stage1-vectors.test.mjs test/integration/self-contained.test.mjs test/integration/seven-corpus.test.mjs test/integration/browser-runner.test.mjs test/integration/fixture-client.test.mjs test/integration/guard-redirect-carrier.test.mjs test/integration/guard-redirect-session-end.test.mjs test/integration/guard-redirect-history.test.mjs test/integration/guard-redirect-iframe.test.mjs test/integration/guard-incomplete.test.mjs test/integration/guard-unparseable-wipe.test.mjs test/integration/guard-browser-ui.test.mjs test/integration/guard-snapshot-settle.test.mjs test/integration/guard-stall.test.mjs test/integration/guard-forged.test.mjs test/integration/guard-trusted-emulation.test.mjs test/integration/guard-exit-steps.test.mjs test/integration/guard-exit-refusal.test.mjs test/integration/guard-frame-read.test.mjs test/integration/guard-bfcache.test.mjs test/integration/guard-bfcache-marker.test.mjs test/integration/guard-bfcache-history.test.mjs test/integration/guard-bfcache-review.test.mjs test/integration/guard-bfcache-quarantine.test.mjs test/integration/guard-error-page-navigation.test.mjs test/integration/guard-error-page-events.test.mjs test/integration/guard-error-page-reload.test.mjs test/integration/guard-close-protected.test.mjs test/integration/guard-close-protected-shapes.test.mjs test/integration/guard-close-protected-shapes-chrome.test.mjs test/integration/guard-credential-export.test.mjs test/integration/guard-protected-parent-iframes.test.mjs test/integration/guard-protected-parent-iframes-chrome.test.mjs test/integration/guard-sign-in-hold.test.mjs test/integration/guard-protected-parent-page.test.mjs test/integration/guard-protected-parent-page-chrome.test.mjs test/integration/guard-world-paint.test.mjs test/integration/gates.test.mjs test/integration/validate.test.mjs test/integration/validate-guard-stock-setup.test.mjs test/integration/go.test.mjs test/integration/cargo.test.mjs test/integration/workflows.test.mjs test/integration/guard-refusable-nav.test.mjs test/integration/guard-protected-worker.test.mjs test/integration/guard-protected-worker-chrome-narrow.test.mjs test/integration/guard-protected-worker-chrome-hide.test.mjs test/integration/guard-protected-worker-chrome-hide-cut.test.mjs test/integration/guard-protected-worker-chrome-admit.test.mjs test/integration/guard-protected-worker-chrome-late.test.mjs test/integration/guard-protected-worker-chrome-rewrite.test.mjs test/integration/guard-protected-worker-chrome-rewrite-late.test.mjs test/integration/guard-sweep-union.test.mjs && node --test --test-concurrency=2 test/integration/guard-lifecycle.test.mjs test/integration/chromium-launch.test.mjs test/integration/guard-fit.test.mjs test/integration/guard-chain.test.mjs test/integration/guard-validation.test.mjs test/integration/guard-liveness.test.mjs test/integration/guard-observations.test.mjs test/integration/guard-child-latency.test.mjs test/integration/guard-adoption.test.mjs test/integration/guard-scoping.test.mjs test/integration/guard-late-pause.test.mjs test/integration/guard-legs.test.mjs test/integration/guard-fetch-enable.test.mjs test/integration/guard-diagnostics.test.mjs test/integration/guard-chrome.test.mjs test/integration/guard-worlds.test.mjs test/integration/guard-world-discovery.test.mjs test/integration/guard-world-guesses.test.mjs test/integration/guard-unparseable.test.mjs test/integration/guard-redirect-secret.test.mjs test/integration/guard-error-page.test.mjs test/integration/guard-discovery.test.mjs test/integration/guard-bfcache-chrome.test.mjs test/integration/guard-browser-page.test.mjs test/integration/guard-scales.test.mjs test/integration/guard-shared-log.test.mjs test/integration/guard-pre-beacon.test.mjs test/integration/guard-world-pause.test.mjs test/integration/guard-reveal-overlap.test.mjs test/integration/guard-extension-frame-cast.test.mjs test/integration/guard-extension-frame-mouse.test.mjs test/integration/guard-extension-frames.test.mjs test/integration/guard-stock-setup.test.mjs test/integration/guard-stock-attack.test.mjs test/integration/guard-parallel.test.mjs test/integration/guard-client-exit.test.mjs test/integration/guard-runner.test.mjs test/integration/guard-sweep-ordinary.test.mjs test/integration/guard-sweep-seven.test.mjs test/integration/guard-sweep-vault.test.mjs test/integration/guard-sweep-vault-x.test.mjs test/integration/guard-sweep-apex.test.mjs test/integration/guard-sweep-idp.test.mjs test/integration/guard-sweep-others.test.mjs",
81
+ "test": "export PATH=\"$HOME/.cargo/bin:$PATH\" && node --test --test-concurrency=1 test/integration/debugger-stage1-packaging.test.mjs test/integration/debugger-raw-control.test.mjs test/integration/debugger-cleanup.test.mjs test/integration/debugger-stage1-install-vectors.test.mjs test/integration/protected-premise.test.mjs test/integration/debugger-stage1-vectors.test.mjs test/integration/self-contained.test.mjs test/integration/seven-corpus.test.mjs test/integration/browser-runner.test.mjs test/integration/fixture-client.test.mjs test/integration/guard-redirect-carrier.test.mjs test/integration/guard-redirect-session-end.test.mjs test/integration/guard-redirect-history.test.mjs test/integration/guard-redirect-iframe.test.mjs test/integration/guard-incomplete.test.mjs test/integration/guard-unparseable-wipe.test.mjs test/integration/guard-browser-ui.test.mjs test/integration/guard-snapshot-settle.test.mjs test/integration/guard-stall.test.mjs test/integration/guard-forged.test.mjs test/integration/guard-trusted-emulation.test.mjs test/integration/guard-exit-steps.test.mjs test/integration/guard-exit-refusal.test.mjs test/integration/guard-frame-read.test.mjs test/integration/guard-bfcache.test.mjs test/integration/guard-bfcache-marker.test.mjs test/integration/guard-bfcache-history.test.mjs test/integration/guard-bfcache-review.test.mjs test/integration/guard-bfcache-quarantine.test.mjs test/integration/guard-error-page-navigation.test.mjs test/integration/guard-error-page-events.test.mjs test/integration/guard-error-page-reload.test.mjs test/integration/guard-close-protected.test.mjs test/integration/guard-close-protected-shapes.test.mjs test/integration/guard-close-protected-shapes-chrome.test.mjs test/integration/guard-credential-export.test.mjs test/integration/guard-protected-parent-iframes.test.mjs test/integration/guard-protected-parent-iframes-chrome.test.mjs test/integration/guard-error-frame-class.test.mjs test/integration/guard-sign-in-hold.test.mjs test/integration/guard-protected-parent-page.test.mjs test/integration/guard-protected-parent-page-chrome.test.mjs test/integration/guard-world-paint.test.mjs test/integration/gates.test.mjs test/integration/validate.test.mjs test/integration/validate-guard-stock-setup.test.mjs test/integration/go.test.mjs test/integration/cargo.test.mjs test/integration/workflows.test.mjs test/integration/guard-refusable-nav.test.mjs test/integration/guard-protected-worker.test.mjs test/integration/guard-protected-worker-chrome-narrow.test.mjs test/integration/guard-protected-worker-chrome-hide.test.mjs test/integration/guard-protected-worker-chrome-hide-cut.test.mjs test/integration/guard-protected-worker-chrome-admit.test.mjs test/integration/guard-protected-worker-chrome-late.test.mjs test/integration/guard-protected-worker-chrome-rewrite.test.mjs test/integration/guard-protected-worker-chrome-rewrite-late.test.mjs test/integration/guard-sweep-union.test.mjs && node --test --test-concurrency=2 test/integration/guard-lifecycle.test.mjs test/integration/chromium-launch.test.mjs test/integration/guard-fit.test.mjs test/integration/guard-chain.test.mjs test/integration/guard-validation.test.mjs test/integration/guard-liveness.test.mjs test/integration/guard-observations.test.mjs test/integration/guard-child-latency.test.mjs test/integration/guard-adoption.test.mjs test/integration/guard-scoping.test.mjs test/integration/guard-late-pause.test.mjs test/integration/guard-legs.test.mjs test/integration/guard-fetch-enable.test.mjs test/integration/guard-diagnostics.test.mjs test/integration/guard-chrome.test.mjs test/integration/guard-worlds.test.mjs test/integration/guard-world-discovery.test.mjs test/integration/guard-world-guesses.test.mjs test/integration/guard-unparseable.test.mjs test/integration/guard-redirect-secret.test.mjs test/integration/guard-error-page.test.mjs test/integration/guard-discovery.test.mjs test/integration/guard-bfcache-chrome.test.mjs test/integration/guard-browser-page.test.mjs test/integration/guard-scales.test.mjs test/integration/guard-shared-log.test.mjs test/integration/guard-pre-beacon.test.mjs test/integration/guard-world-pause.test.mjs test/integration/guard-reveal-overlap.test.mjs test/integration/guard-extension-frame-cast.test.mjs test/integration/guard-extension-frame-mouse.test.mjs test/integration/guard-extension-frames.test.mjs test/integration/guard-stock-setup.test.mjs test/integration/guard-stock-attack.test.mjs test/integration/guard-parallel.test.mjs test/integration/guard-client-exit.test.mjs test/integration/guard-runner.test.mjs test/integration/guard-sweep-ordinary.test.mjs test/integration/guard-sweep-seven.test.mjs test/integration/guard-sweep-vault.test.mjs test/integration/guard-sweep-vault-x.test.mjs test/integration/guard-sweep-apex.test.mjs test/integration/guard-sweep-idp.test.mjs test/integration/guard-sweep-others.test.mjs",
82
82
  "test:unit": "mkdir -p coverage/unit && node --experimental-test-coverage --test --test-concurrency=1 --test-reporter=lcov --test-reporter-destination=coverage/unit/lcov.info test/unit/*.test.mjs && go test -race -cover ./...",
83
83
  "build": "go build ./... && cargo build --all-features && cargo build --target wasm32-wasip1 --all-features && npm pack --dry-run",
84
84
  "prepublishOnly": "node scripts/set-crate-version.mjs \"$npm_package_version\"",
@@ -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",
@@ -162,6 +162,14 @@
162
162
  "iframeAutoAttach": {
163
163
  "type": "string",
164
164
  "minLength": 1
165
+ },
166
+ "errorFrameClass": {
167
+ "type": "string",
168
+ "minLength": 1
169
+ },
170
+ "jsonList": {
171
+ "type": "string",
172
+ "minLength": 1
165
173
  }
166
174
  }
167
175
  },
@@ -202,7 +210,9 @@
202
210
  "syntheticAutoAttach",
203
211
  "closeProtected",
204
212
  "signInHold",
205
- "iframeAutoAttach"
213
+ "iframeAutoAttach",
214
+ "errorFrameClass",
215
+ "jsonList"
206
216
  ]
207
217
  },
208
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 }));