@ai-ecoverse/slicc-browsers 1.43.0 → 1.44.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.
Binary file
package/engine.mjs ADDED
@@ -0,0 +1,108 @@
1
+ import bytes from './engine/engine-wasm.mjs';
2
+
3
+ const encoder = new TextEncoder();
4
+ const decoder = new TextDecoder('utf-8', { fatal: true });
5
+ const roles = [
6
+ 'seven',
7
+ 'slicc',
8
+ 'extra',
9
+ 'browser',
10
+ 'extension',
11
+ 'file',
12
+ 'unparseable',
13
+ 'ordinary',
14
+ ];
15
+ let compiled;
16
+
17
+ function valid(op, result) {
18
+ switch (op) {
19
+ case 'urlClass':
20
+ return (
21
+ typeof result?.protected === 'boolean' &&
22
+ roles.includes(result.role) &&
23
+ (result.origin === null || typeof result.origin === 'string')
24
+ );
25
+ case 'info':
26
+ return (
27
+ result?.abi === 1 &&
28
+ Number.isInteger(result.catalogSchema) &&
29
+ typeof result.digest === 'string' &&
30
+ /^[0-9a-f]{16}$/.test(result.digest)
31
+ );
32
+ case 'har':
33
+ return result === 'include' || result === 'exclude';
34
+ case 'storageKey':
35
+ return typeof result?.protected === 'boolean';
36
+ default:
37
+ return typeof result === 'boolean';
38
+ }
39
+ }
40
+
41
+ function exchange(wasm, method, input) {
42
+ const ptr = wasm.engine_alloc(input.length) >>> 0;
43
+ new Uint8Array(wasm.memory.buffer, ptr, input.length).set(input);
44
+ const packed = wasm[method](ptr, input.length);
45
+ const start = Number(BigInt.asUintN(64, packed) >> 32n);
46
+ const length = Number(packed & 0xffffffffn);
47
+ const answer = JSON.parse(decoder.decode(new Uint8Array(wasm.memory.buffer, start, length)));
48
+ wasm.engine_free(start, length);
49
+ wasm.engine_free(ptr, input.length);
50
+ if (typeof answer?.error === 'string') throw new Error(answer.error);
51
+ if (!answer || Object.keys(answer).length !== 1 || !Object.hasOwn(answer, 'ok'))
52
+ throw new Error('invalid engine response');
53
+ return answer.ok;
54
+ }
55
+
56
+ function binding(module, config) {
57
+ const input = encoder.encode(JSON.stringify(config));
58
+ function create() {
59
+ const wasm = new WebAssembly.Instance(module).exports;
60
+ if (wasm.engine_abi() !== 1) throw new Error('unsupported engine ABI');
61
+ if (exchange(wasm, 'engine_init', input) !== true)
62
+ throw new Error('engine initialization failed');
63
+ return wasm;
64
+ }
65
+ let instance = create();
66
+ function call(request) {
67
+ try {
68
+ instance ??= create();
69
+ const result = exchange(instance, 'engine_call', encoder.encode(JSON.stringify(request)));
70
+ const ok =
71
+ request.op === 'batch'
72
+ ? Array.isArray(result) &&
73
+ result.length === request.calls.length &&
74
+ result.every((v, i) => valid(request.calls[i].op, v))
75
+ : valid(request.op, result);
76
+ if (!ok) throw new Error(`invalid engine result for ${request.op}`);
77
+ return result;
78
+ } catch (error) {
79
+ instance = undefined;
80
+ throw error;
81
+ }
82
+ }
83
+ return {
84
+ url: (url, { readOnly = false } = {}) => call({ op: 'url', url, readOnly }),
85
+ urlReadOnly: (url) => call({ op: 'url', url, readOnly: true }),
86
+ urlClass: (url) => call({ op: 'urlClass', url }),
87
+ target: (facts) => call({ ...facts, op: 'target' }),
88
+ kept: (url) => call({ op: 'kept', url }),
89
+ keptTarget: (facts) => call({ ...facts, op: 'keptTarget' }),
90
+ unparseable: (url) => call({ op: 'unparseable', url }),
91
+ cookieDomain: (domain) => call({ op: 'cookieDomain', domain }),
92
+ storageKey: (key) => call({ op: 'storageKey', key }),
93
+ extensionFrame: (url) => call({ op: 'extensionFrame', url }),
94
+ har: (url) => call({ op: 'har', url }),
95
+ info: () => call({ op: 'info' }),
96
+ batch: (calls) => call({ op: 'batch', calls }),
97
+ };
98
+ }
99
+
100
+ export function engine(config = {}) {
101
+ compiled ??= new WebAssembly.Module(bytes);
102
+ return binding(compiled, config);
103
+ }
104
+
105
+ export async function loadEngine(config = {}) {
106
+ compiled ??= await WebAssembly.compile(bytes);
107
+ return binding(compiled, config);
108
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "setVersion": "1.43.0",
3
+ "setVersion": "1.44.0",
4
4
  "sources": [
5
5
  {
6
6
  "repo": "ai-ecoverse/slicc-cli",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/slicc-browsers",
3
- "version": "1.43.0",
3
+ "version": "1.44.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",
@@ -28,6 +28,10 @@
28
28
  "./protected.json": "./protected.json",
29
29
  "./debugger-stage1.json": "./debugger-stage1.json",
30
30
  "./protected.mjs": "./protected.mjs",
31
+ "./engine": "./engine.mjs",
32
+ "./engine.mjs": "./engine.mjs",
33
+ "./engine/engine-wasm.mjs": "./engine/engine-wasm.mjs",
34
+ "./engine/engine.wasm": "./engine/engine.wasm",
31
35
  "./guard-vectors.json": "./guard-vectors.json",
32
36
  "./guard-driver.mjs": "./guard-driver.mjs",
33
37
  "./seven.mjs": "./seven.mjs",
@@ -49,6 +53,9 @@
49
53
  "protected.json",
50
54
  "debugger-stage1.json",
51
55
  "protected.mjs",
56
+ "engine.mjs",
57
+ "engine/engine-wasm.mjs",
58
+ "engine/engine.wasm",
52
59
  "guard-vectors.json",
53
60
  "guard-driver.mjs",
54
61
  "seven.mjs",
@@ -76,12 +83,13 @@
76
83
  "scripts": {
77
84
  "prepare": "slicc-install-hooks",
78
85
  "corpus": "node scripts/corpus.mjs",
86
+ "engine": "PATH=\"$HOME/.cargo/bin:$PATH\" node scripts/engine.mjs",
79
87
  "validate": "node scripts/validate.mjs",
80
- "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",
81
- "format": "biome check --write . && gofmt -w . && cargo fmt",
82
- "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-redirect-through.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-cookie-plant-chrome.test.mjs test/integration/guard-cookie-plant.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/validate-guard-explicit.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 test/integration/guard-explicit-attach-chrome.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-child-latency-stress.test.mjs test/integration/guard-adoption.test.mjs test/integration/guard-scoping.test.mjs test/integration/guard-late-pause.test.mjs test/integration/guard-cookie-plant-raw-leg.test.mjs test/integration/guard-cookie-plant-deletion.test.mjs test/integration/guard-cookie-plant-attach.test.mjs test/integration/guard-cookie-plant-attach-retry.test.mjs test/integration/guard-cookie-plant-open-commit.test.mjs test/integration/guard-cookie-plant-legacy-setup.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-error-page-enable.test.mjs test/integration/guard-discovery.test.mjs test/integration/guard-bfcache-chrome.test.mjs test/integration/guard-bfcache-ownership-probe.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-frame-click.test.mjs test/integration/guard-extension-frame-key.test.mjs test/integration/guard-extension-frame-attach.test.mjs test/integration/guard-extension-frames.test.mjs test/integration/guard-stock-setup.test.mjs test/integration/guard-explicit-attach.test.mjs test/integration/guard-explicit-order.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-record.test.mjs test/integration/guard-runner.test.mjs test/integration/guard-error-legs.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 test/integration/guard-browser-storage.test.mjs test/integration/guard-control-premises.test.mjs test/integration/guard-control-probe-failure.test.mjs test/integration/guard-kept-origins.test.mjs",
88
+ "lint": "export PATH=\"$HOME/.cargo/bin:$PATH\" && if [ \"$(uname -s)\" = Darwin ]; then echo 'Skipping byte comparison on macOS; Linux CI owns the wasm bytes.'; else git ls-files --error-unmatch engine/engine.wasm engine/engine-wasm.mjs > /dev/null && npm run engine && git diff --exit-code -- engine/engine.wasm engine/engine-wasm.mjs; fi && 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 --all --check && cargo clippy --workspace --locked --all-features --all-targets -- -D warnings && cargo check --target wasm32-wasip1 --no-default-features --locked && cargo check --target wasm32-wasip1 --features serde --locked && cargo check --target wasm32-wasip1 --all-features --locked",
89
+ "format": "biome check --write . && gofmt -w . && cargo fmt --all",
90
+ "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-redirect-through.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-cookie-plant-chrome.test.mjs test/integration/guard-cookie-plant.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/validate-guard-explicit.test.mjs test/integration/go.test.mjs test/integration/cargo.test.mjs test/integration/engine.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 test/integration/guard-explicit-attach-chrome.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-child-latency-stress.test.mjs test/integration/guard-adoption.test.mjs test/integration/guard-scoping.test.mjs test/integration/guard-late-pause.test.mjs test/integration/guard-cookie-plant-raw-leg.test.mjs test/integration/guard-cookie-plant-deletion.test.mjs test/integration/guard-cookie-plant-attach.test.mjs test/integration/guard-cookie-plant-attach-retry.test.mjs test/integration/guard-cookie-plant-open-commit.test.mjs test/integration/guard-cookie-plant-legacy-setup.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-error-page-enable.test.mjs test/integration/guard-discovery.test.mjs test/integration/guard-bfcache-chrome.test.mjs test/integration/guard-bfcache-ownership-probe.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-frame-click.test.mjs test/integration/guard-extension-frame-key.test.mjs test/integration/guard-extension-frame-attach.test.mjs test/integration/guard-extension-frames.test.mjs test/integration/guard-stock-setup.test.mjs test/integration/guard-explicit-attach.test.mjs test/integration/guard-explicit-order.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-record.test.mjs test/integration/guard-runner.test.mjs test/integration/guard-error-legs.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 test/integration/guard-browser-storage.test.mjs test/integration/guard-control-premises.test.mjs test/integration/guard-control-probe-failure.test.mjs test/integration/guard-kept-origins.test.mjs",
83
91
  "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 ./...",
84
- "build": "go build ./... && cargo build --all-features && cargo build --target wasm32-wasip1 --all-features && npm pack --dry-run",
92
+ "build": "export PATH=\"$HOME/.cargo/bin:$PATH\" && go build ./... && cargo build --locked --all-features && cargo build --locked --target wasm32-wasip1 --all-features && npm pack --dry-run",
85
93
  "prepublishOnly": "node scripts/set-crate-version.mjs \"$npm_package_version\"",
86
94
  "trust": "npx fledgling sync -y --skip-publish",
87
95
  "trust:dry": "npx fledgling sync --dry-run -y --skip-publish",
@@ -90,12 +98,13 @@
90
98
  "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"
91
99
  },
92
100
  "devDependencies": {
93
- "@ai-ecoverse/slicc-cdp": "2.2.1",
94
- "@ai-ecoverse/slicc-shared-web": "2.18.0",
101
+ "@ai-ecoverse/slicc-cdp": "2.4.0",
102
+ "@ai-ecoverse/slicc-shared-web": "2.19.1",
95
103
  "@biomejs/biome": "2.6.8",
96
104
  "ajv": "8.20.0",
97
105
  "ajv-formats": "3.0.1",
106
+ "binaryen": "132.0.0",
98
107
  "lefthook": "2.2.2",
99
- "semantic-release": "25.0.9"
108
+ "semantic-release": "26.0.1"
100
109
  }
101
110
  }