@ai-ecoverse/slicc-browsers 1.50.0 → 1.52.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
@@ -75,11 +75,11 @@ npm install @ai-ecoverse/slicc-browsers
75
75
  | `./guard-runner`, `./guard-driver.mjs` | the guard vector runner and its helpers |
76
76
  | `./fixture`, `./fixture-client` | the test server (Node only) and a client for a remote one |
77
77
 
78
- Everything except `./fixture` runs in browsers and Node. `protected.mjs` bundles the engine and `seven.mjs` is standalone; neither imports anything. MV3 extensions using the engine need `'wasm-unsafe-eval'` in their extension pages CSP.
78
+ Only `./fixture` requires Node. MV3 extension pages using wasm need `'wasm-unsafe-eval'`. Use `./protected-js.mjs` or `./engine-js` for page contexts whose CSP forbids WebAssembly. Inject the JS bundle before page scripts run so it can capture the original built-ins.
79
79
 
80
80
  ## Engine
81
81
 
82
- One rules engine classifies protected origins, targets, cookie domains, storage keys and HAR request URLs. Use Rust's `slicc_browsers::engine::Engine::embedded()?` (feature `engine`), import `engine` or async `loadEngine` from `@ai-ecoverse/slicc-browsers/engine` in JS, or call `engine.Default()` in Go's `github.com/ai-ecoverse/slicc-browsers/engine`. JS and Go run the same import-free wasm (under 512 KiB); on macOS, Go defaults to wazero’s interpreter for hardened-runtime compatibility (wazero issue 2393). Bindings check ABI 1; only incompatible request or answer changes bump it. Treat errors as refusals. `refusal(key)` returns the shared text from `catalog.json`’s `refusals` or errors on an unknown key.
82
+ One rules engine classifies protected origins, targets, cookie domains, storage keys and HAR request URLs. Use Rust's `slicc_browsers::engine::Engine::embedded()?` (feature `engine`), import `engine` or async `loadEngine` from `@ai-ecoverse/slicc-browsers/engine` in JS, or call `engine.Default()` in Go's `github.com/ai-ecoverse/slicc-browsers/engine`. The default JS and Go bindings run the same import-free wasm (under 512 KiB); on macOS, Go defaults to wazero’s interpreter for hardened-runtime compatibility (wazero issue 2393). Bindings check ABI 1; only incompatible request or answer changes bump it. Treat errors as refusals. `refusal(key)` returns the shared text from `catalog.json`’s `refusals` or errors on an unknown key.
83
83
 
84
84
  ## The catalog
85
85
 
@@ -91,11 +91,11 @@ One rules engine classifies protected origins, targets, cookie domains, storage
91
91
  - **Profiles and platforms**: where SLICC keeps its browser profiles, and the config dirs and registry keys per OS.
92
92
  - **Protected origins**: see [below](#protected-origins).
93
93
 
94
- The catalog is `"schema": 1`. Minor releases only add fields; changing or removing one takes schema 2 and a major release. slicc-cli keeps no browser tables of its own: to add or change a browser, change `catalog.json`, release, and bump the dependency.
94
+ The catalog uses schema 1. Minor releases only add fields; removing or changing fields requires schema 2 and a major release. slicc-cli has no browser tables: change `catalog.json`, release and bump the dependency.
95
95
 
96
96
  ## Discovery
97
97
 
98
- A program lists the browsers it can attach to, from four sources: `DevToolsActivePort` files in known user-data dirs and SLICC profiles, `--cdp` URLs, a port probe, and the process list. It ranks the endpoints, adds the installed browsers it could launch, and prints the list in the shape of [`schema/browsers.schema.json`](schema/browsers.schema.json). Seven's tabs are reported by origin only, never with a path, query or title.
98
+ Discovery ranks browsers from known user-data dirs’ `DevToolsActivePort` files, `--cdp` URLs, a port probe and the process list, and lists installed browsers it can launch. Output follows [`schema/browsers.schema.json`](schema/browsers.schema.json). Seven tabs expose only their origin, never a path, query or title.
99
99
 
100
100
  The process scan finds other programs’ `--remote-debugging-port` browsers; see `discovery.process` and the `process-*` corpus cases.
101
101
 
@@ -147,15 +147,15 @@ slicc-cli's `test/integration/corpus_test.go` is a complete harness.
147
147
  ## Protected origins
148
148
 
149
149
  Browser control must never navigate to, open, attach to, or read cookies or storage of:
150
- - **seven and the vault**: `sliccy.ai` hosts one label deep, bar a few listed ones, over HTTP(S), any port; apex-domain cookies too, not apex or deeper pages. Unprotected pages there read and write them via `document.cookie` and `cookieStore` as in any browser; CDP filtering is defence in depth; SLICC's cookies are host-only;
150
+ - **seven and the vault**: `sliccy.ai` hosts one label deep, bar a few listed ones, over HTTP(S) or WS(S), any port; apex-domain cookies too, not apex or deeper pages. Unprotected pages there read and write them via `document.cookie` and `cookieStore` as in any browser; CDP filtering is defence in depth; SLICC's cookies are host-only;
151
151
  - **the browser's own privileged pages**: `chrome://` and other Chromium browsers' equivalents, `devtools://`, `chrome-extension://` (home to password managers and wallets), `file://` and Chrome's UI targets, bar the new tab page;
152
152
  - **a program's extra seven origins**.
153
153
 
154
- All bindings share a URL parser and unwrap URL aliases. Unparseable URLs are protected wherever they might load. A tab seven opened keeps seven's origin on `about:blank`. A refused call fails with `slicc: refused: target is on seven's origin`.
154
+ Targets and frames use only their own URL and reported security origin (including inherited origins), never their parent, opener or history; unknown origins alone do not protect a target, but an unparseable URL does. Error documents are ordinary unless the failed URL is unparseable, and a protected failed URL is redacted to its origin. A refused call fails with `slicc: refused: target is on seven's origin`.
155
155
 
156
156
  The engine withholds protected frames, not their ordinary page. Adapters report any mixed state from capture dispatch to release: screenshots and screencasts show Seven but blank other protected boxes; PDFs needing blanking are refused.
157
157
 
158
- Foreign extension frames follow separate rules: no attachment, reads, or URLs in discovery, snapshots, accessibility trees or evaluate results. The tab's page can still be read and snapshotted. Screenshots and input are allowed only while every extension frame is hidden (no layout box or `visibility: hidden`) and none holds focus through nested documents or shadow roots; a screenshot taken as one became shown is dropped. Opacity and position don't count as hidden. A race between that check and the CDP reply is accepted. While an extension frame is present, whole-page captures and new screencasts are refused; active screencasts stop or drop frames. These refusals name the extension frame, not seven. `protectedOrigins.extensionFrames` lists the schemes, methods and refusals; `protected.mjs` offers `extensionFrame(url)`.
158
+ Foreign extension frames cannot be attached or read. Their URLs are hidden in discovery, snapshots, accessibility trees and evaluate results; the tab remains readable and can be snapshotted. Screenshots and input require every extension frame to be hidden (no layout box or `visibility: hidden`) and unfocused, including through nested documents or shadow roots. Opacity and position don’t count. Drop screenshots if a frame becomes visible; a race between the check and CDP reply is accepted. While a frame is present, refuse whole-page captures and new screencasts; stop active screencasts or drop their frames. Refusals name the extension frame, not seven. `protectedOrigins.extensionFrames` lists the schemes, methods and refusals; `protected.mjs` offers `extensionFrame(url)`.
159
159
 
160
160
  `catalog.json`’s `protectedOrigins` holds the rules. `protected.json` tests them across bindings. `protected.mjs` exposes the engine synchronously:
161
161
 
@@ -166,7 +166,7 @@ import { protectedOrigins } from '@ai-ecoverse/slicc-browsers/protected.mjs';
166
166
  const guard = protectedOrigins(catalog.protectedOrigins, ['http://127.0.0.1:5710']);
167
167
  guard.url('https://seven.sliccy.ai/');
168
168
  guard.cookieDomain('.sliccy.ai');
169
- guard.target({ url: 'about:blank', opener: 'protected' });
169
+ guard.frame({ url: 'about:blank', securityOrigin: 'https://seven.sliccy.ai' });
170
170
  ```
171
171
 
172
172
  It also offers `storageKey(key)` and `unparseable(text)`.
package/catalog.json CHANGED
@@ -751,7 +751,7 @@
751
751
  "unprotectedLabels": ["get", "mcpcat", "echo", "lease-pilot"]
752
752
  }
753
753
  ],
754
- "schemes": ["https", "http"],
754
+ "schemes": ["https", "http", "ws", "wss"],
755
755
  "innerSchemes": ["blob", "filesystem", "view-source"],
756
756
  "anySchemes": ["devtools"],
757
757
  "protectedSchemes": [
@@ -786,11 +786,19 @@
786
786
  "inheriting": ["about:blank", "about:srcdoc"],
787
787
  "errorPage": {
788
788
  "url": "chrome-error://chromewebdata/",
789
- "target": "previous",
789
+ "target": "ownOrigin",
790
790
  "redact": "origin"
791
791
  },
792
792
  "unparseable": "protected",
793
793
  "unparseableRefusal": "slicc: refused: slicc can't parse this URL, so it could be a protected page",
794
+ "extensionWorlds": {
795
+ "schemes": [
796
+ "chrome-extension",
797
+ "moz-extension",
798
+ "safari-web-extension",
799
+ "ms-browser-extension"
800
+ ]
801
+ },
794
802
  "extensionFrames": {
795
803
  "schemes": ["chrome-extension"],
796
804
  "whenShown": [
@@ -0,0 +1,34 @@
1
+ const { Array, Map, Object, Reflect, RegExp, String, Uint8Array, WeakMap } = globalThis;
2
+ const { apply } = Reflect;
3
+ export const method =
4
+ (fn) =>
5
+ (self, ...args) =>
6
+ apply(fn, self, args);
7
+ const getter = (prototype, key) => method(Object.getOwnPropertyDescriptor(prototype, key).get);
8
+ export const typedLength = getter(Object.getPrototypeOf(Uint8Array.prototype), 'length');
9
+ export const byteLength = getter(globalThis.ArrayBuffer.prototype, 'byteLength');
10
+ export const typedSet = method(Uint8Array.prototype.set);
11
+ export const copyWithin = method(Uint8Array.prototype.copyWithin);
12
+ export const fill = method(Uint8Array.prototype.fill);
13
+ export const charCodeAt = method(String.prototype.charCodeAt);
14
+ export const wellFormed = method(String.prototype.toWellFormed);
15
+ export const startsWith = method(String.prototype.startsWith);
16
+ export const exec = method(RegExp.prototype.exec);
17
+ export const includes = method(Array.prototype.includes);
18
+ export const every = method(Array.prototype.every);
19
+ export const weakGet = method(WeakMap.prototype.get);
20
+ export const weakSet = method(WeakMap.prototype.set);
21
+ export const mapGet = method(Map.prototype.get);
22
+ export const mapSet = method(Map.prototype.set);
23
+ export const mapDelete = method(Map.prototype.delete);
24
+ export const forEachEntry = method(Map.prototype.forEach);
25
+ export const deref = method(globalThis.WeakRef.prototype.deref);
26
+ const { setPrototypeOf } = Object;
27
+ export function list(values, convert, accept = () => true) {
28
+ const out = setPrototypeOf([], null);
29
+ for (let i = 0; i < values.length; i++) {
30
+ const v = values[i];
31
+ if (accept(v)) out[out.length] = convert(v);
32
+ }
33
+ return out;
34
+ }