@lincoln504/pi-research 1.7.12 → 1.7.15
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/agent-skill/pi-research/SKILL.md +1 -1
- package/dist/cli.mjs +4 -0
- package/docs/ARCHITECTURE.md +2 -2
- package/docs/CHANGELOG.md +43 -0
- package/package.json +9 -8
- package/scripts/setup.cjs +8 -2
- package/src/core/pi-version.ts +11 -1
- package/src/tui/research-panel-wave.ts +4 -1
- package/src/youtube/potoken.ts +9 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: pi-research
|
|
3
3
|
description: "Multi-agent web research for any coding agent. Use for anything requiring current information from the internet — news, trends, product/service/company facts, statistics, people, places, events, APIs, library behavior, or 'what is X / how does X work' questions. Also use to search a local knowledge store of previously researched findings before doing live research. Powered by the pi-research engine (search, stealth scraping, security databases, Stack Exchange). Not for reading local files, running project commands, or analyzing this repository's own source."
|
|
4
4
|
license: MIT
|
|
5
|
-
metadata: { "author": "Lincoln Deen", "version": "1.7.
|
|
5
|
+
metadata: { "author": "Lincoln Deen", "version": "1.7.15", "package": "@lincoln504/pi-research", "engine": "pi-research-sdk", "openclaw": { "requires": { "bins": ["node"] } } }
|
|
6
6
|
allowed-tools: Bash(node:*)
|
|
7
7
|
---
|
|
8
8
|
|
package/dist/cli.mjs
CHANGED
|
@@ -23220,6 +23220,7 @@ function describeError(error) {
|
|
|
23220
23220
|
var mintChain = Promise.resolve();
|
|
23221
23221
|
var wedged = false;
|
|
23222
23222
|
var MINT_HARD_RELEASE_MS = 5 * 60 * 1e3;
|
|
23223
|
+
var MAX_INTERPRETER_CHARS = 8 * 1024 * 1024;
|
|
23223
23224
|
async function mintPoTokens(identifiers, opts = {}) {
|
|
23224
23225
|
if (wedged) {
|
|
23225
23226
|
throw new Error("PoToken minter is wedged by a prior mint that never settled; refusing to start a new mint until it resolves.");
|
|
@@ -23302,6 +23303,9 @@ async function doMint(identifiers, opts) {
|
|
|
23302
23303
|
if (!challenge) throw new Error("BotGuard challenge unavailable");
|
|
23303
23304
|
const interpreter = challenge.interpreterJavascript?.privateDoNotAccessOrElseSafeScriptWrappedValue;
|
|
23304
23305
|
if (!interpreter) throw new Error("BotGuard interpreter script missing");
|
|
23306
|
+
if (typeof interpreter !== "string" || interpreter.length > MAX_INTERPRETER_CHARS) {
|
|
23307
|
+
throw new Error("BotGuard interpreter script has an unexpected shape or size");
|
|
23308
|
+
}
|
|
23305
23309
|
new Function(interpreter)();
|
|
23306
23310
|
if (!challenge.program || !challenge.globalName) {
|
|
23307
23311
|
throw new Error("BotGuard challenge missing program/globalName");
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -387,8 +387,8 @@ warns on every startup when a host-provided package (`typebox`, `@sinclair/typeb
|
|
|
387
387
|
loader and create a second live module instance (`resource-loader.js`,
|
|
388
388
|
`collectExtensionPackageWarnings`; pi `docs/packages.md`). Under pi the host's own copy is used,
|
|
389
389
|
so the two agree on `Value.Check`/`Convert` by construction. `@earendil-works/pi-ai` and
|
|
390
|
-
`@earendil-works/pi-coding-agent` 1.0.0 through 1.
|
|
391
|
-
the
|
|
390
|
+
`@earendil-works/pi-coding-agent` 1.0.0 through 1.4.0 all pin `1.3.27` (re-checked 2026-10-21 in
|
|
391
|
+
the published 1.4.0 packages' `package.json`, previously 2026-10-17 in 1.3.0), which is why the devDependency, and so every test run and
|
|
392
392
|
the type-check, stays on exactly that version: bump it in lockstep with the pi host, not
|
|
393
393
|
independently. A standalone CLI/SDK install resolves the peer automatically on npm >= 7; the
|
|
394
394
|
`pi-research` bin preflights it with the pi packages and exits 78 with the remedy when a
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,49 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.7.15] - 2026-10-21
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **`scripts/setup.cjs` still ran its Linux `install-deps` step through a shell string.** `execSync(`"${cli}" install-deps`)` interpolated a path under the package directory into `/bin/sh -c`, so with `PLAYWRIGHT_INSTALL_DEPS=true` (or `--system-deps`) a package directory whose name contained `$(...)` or backticks would execute it at install time. `prepare.cjs`, `cleanup.cjs` and the browser fetch in the same file already used `spawnSync` with an argv array for exactly this reason; this was the lone holdout. It is now `spawnSync(cli, ['install-deps'])` with the exit status and spawn error converted back into the existing "could not install system dependencies" warning. New `test/unit/scripts/install-script-shell-safety.test.ts` fails on any `execSync`/`exec`/`shell: true` in the shipped install-time scripts (`setup`, `cleanup`, `prepare`, `build`, `camoufox-layout`); verified to fail against the previous `setup.cjs`. `scripts/ensure-native-deps.cjs` keeps its `execSync` deliberately: it is CI-only, not in `files[]`, and its command string is built from repo-pinned versions, not from a user-controlled path.
|
|
13
|
+
- **The research panel's wave animation indexed outside its trail array at width 1.** `computeHeadState` clamped the last cell index to at least 1, so with a single available cell the head landed on index 1, grew `waveColors` to two entries, and the width check in `generateWaveFill` then discarded the trail on every frame. Output stayed correct (the fill loop is bounded by `available`), so nothing visibly broke, but the animation silently lost its trail state at that width. The clamp is now 0. `src/tui/research-panel-wave.ts` previously had no test at all; `test/unit/tui/research-panel-wave.test.ts` now pins cell count, colour-channel range, resize handling, the edge-impact glyphs, an unparseable accent colour and a huge frame counter. It found the width-1 bug on its first run.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- **The BotGuard interpreter is size- and type-checked before `new Function` compiles it** (`src/youtube/potoken.ts`). The script is fetched over HTTPS and running it is inherent to PoToken minting, so this does not change the trust model; it only refuses a non-string or implausibly large (over 8 MiB; real ones are a few hundred KB) value instead of compiling it.
|
|
18
|
+
- **`npm run lock:restore-stubs`** (`scripts/restore-lock-stubs.cjs`) re-adds the two kreuzberg phantom-musl lockfile stubs that every plain `npm install` / `npm update` / `--package-lock-only` drops and that break `npm ci` on CI. It reads the version from the parent's own `optionalDependencies`, is idempotent, and was verified byte-identical against the committed lockfile after deleting both stubs. `test/unit/package.test.ts`'s failure message now points at it. Run it, then `npm ci --dry-run`, after any lockfile regeneration.
|
|
19
|
+
|
|
20
|
+
### Verified
|
|
21
|
+
|
|
22
|
+
Audit findings checked and left unchanged: `.github/workflows/release.yml` (SHA-pinned actions, `id-token` only in the publish job, which installs nothing and publishes the vetted tarball, CI-green gate on the tagged commit); the 5 npm 12 "install scripts not yet covered by allowScripts" packages (`@google/genai`, `onnxruntime-node` x2, `protobufjs`, `webgpu`) do not affect this package: the allow-scripts setting lives in the user's `~/.npmrc`, not the repository, and the measured finding in the 1.6.x entries stands that none of these needs its script to function; the SSRF stack (`validateUrlForSSRF`, connect-time IP pin, per-hop redirect validation).
|
|
23
|
+
|
|
24
|
+
## [1.7.14] - 2026-10-21
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- **The pi host dev dependencies move 1.3.0 → 1.4.0** (`@earendil-works/pi-ai`, `pi-coding-agent`, `pi-tui`, and the `pi-agent-core`/`pi-codemode`/`pi-mcp`/`pi-telemetry` they pull in; the peer range stays `>=0.99.0 <2`). The 1.3.0 → 1.4.0 diff of the published tarballs (2026-10-21): `pi-coding-agent`'s extension surface file (`dist/core/extensions/types.d.ts`) is byte-identical, and its `package.json` still pins `typebox` at `1.3.27`, so the lockstep rule and the 0.99.0 floor are unchanged. `pi-tui`'s changes are render-internal and touch nothing this package consumes: the unclosed `$$`/`\[` display-math no longer swallows later Markdown tables (the "text not filling in" class of symptom in model replies), bold/italic now render next to CJK punctuation, and terminal modes are restored on unclean exit. `pi-ai`'s `before_provider_headers` attribution-header change and the `generateSummary()` `reserveTokens` change touch no handler this package registers and no call it makes.
|
|
29
|
+
- **`PI_TESTED_MAX_VERSION` moves to 1.4.0** (`src/core/pi-version.ts`), so a pi 1.4.x host runs without the "newer than the tested ceiling" notice. No handler in this package needed re-signing: the `before_agent_start` handler still reads only `systemPrompt`/`systemPromptOptions` (present on both union members), and both `pi.sendUserMessage` calls already pass `deliverAs`.
|
|
30
|
+
- **In-range lockfile refresh from the 1.4.0 install** (pi trio, `undici`, `vitest`, `@vitest/coverage-v8`, `vite`, `jsdom`, `poolifier`, `youtubei.js`, `npm-check-updates`); dev pins move `@huggingface/transformers` 4.3.0 → 4.3.1, `eslint` 10.11.0 → 10.13.0, and `@typescript-eslint/*` 8.71.0 → 8.72.0.
|
|
31
|
+
- **`playwright-core` stays 1.62.1; 1.64.1 is rejected by coupling.** `@camoufox/camoufox` 0.5.7 pins `playwright-core` at 1.62.0 with an override ceiling of `<1.63`, because every Playwright minor is free to change Juggler (the wire protocol Camoufox speaks); a bump to 1.64.1 would cross that ceiling and is not measurable without a full browser re-validation. `apache-arrow` stays 21.1.0 (the 21.2.0 IPC read failure measured in 1.7.13) and `typebox` stays 1.3.27 (pi host lockstep).
|
|
32
|
+
|
|
33
|
+
### Verified
|
|
34
|
+
|
|
35
|
+
Full gate suite against the new tree: lint, the four type-checks (TypeScript 6 and 7, src and tests), unit, integration (serial + parallel), `npm audit` (0), production audit gate, and a fresh-install consumer boot. Knowledge store suite green on the pinned lancedb 0.40.0 / apache-arrow 21.1.0 pair.
|
|
36
|
+
|
|
37
|
+
## [1.7.13] - 2026-10-19
|
|
38
|
+
|
|
39
|
+
### Changed
|
|
40
|
+
|
|
41
|
+
- **`poolifier` 5.3.2 → 6.0.1** (caret). The API surface this package uses is byte-identical between the two versions' declarations (installed `.d.ts` diff, 2026-10-19): `FixedClusterPool`'s constructor `(numberOfWorkers, filePath, opts?)`, `ClusterWorker`'s constructor, the `WorkerChoiceStrategies` enumeration, and every `PoolOptions`/`WorkerOptions` field. The 6.0.0 breaking changes do not apply here: the deferred custom-operation-handler identity rule (this package registers plain task functions, no operation handlers) and the new Node engine requirement `^22.18.0 || >=24.3.0`, which our `engines` floor (`>=22.22.2`) and the CI Node (22.22.2) both satisfy. 6.0.1 also carries the 5.4.x fixes into the new major (worker launch option descriptors, 5.4.1; task lifecycle and type export fixes, 6.0.0).
|
|
42
|
+
- **`@lancedb/lancedb` 0.39.0 → 0.40.0.** The surface this package uses (`connect`, `Connection`, `Table.createIndex`/`search`/`add`/`optimize`/`count`, `Index.fts()`/`Index.btree()`, `rerankers.RRFReranker`) is unchanged in the 0.39.0 → 0.40.0 `.d.ts` diff; the 0.40.0 changes are additive (views, materialized views, job pause/resume, blob read options, OAuth/catalog). The release line's node-side "update arrow to 21" fix aligns with this package's apache-arrow pin.
|
|
43
|
+
- **`impit` 0.14.5 → 0.14.6** (patch). The JS bundle is unchanged between versions; the only declaration change is additive — `timeout` on `ImpitOptions` and request options accepts `null` (disabled timeout).
|
|
44
|
+
- **`apache-arrow` stays 21.1.0; 21.2.0 is rejected by measurement.** With `apache-arrow` 21.2.0, the knowledge store unit suite fails 35/35 on both lancedb 0.39.0 and 0.40.0 (`Failed to read IPC file: Arrow error: Parser error: Unable to get root as footer: RangeOutOfBounds`) — an arrow IPC read failure between lancedb's native bindings and the JS layer. With 21.1.0, the same suite passes 36/36 on both lancedb versions. The exact pin and the `overrides` pin therefore stay at 21.1.0.
|
|
45
|
+
- In-range lockfile refresh from the new install (undici, vitest, youtubei.js, jsdom, vite where the range moved); nothing else.
|
|
46
|
+
|
|
47
|
+
### Verified
|
|
48
|
+
|
|
49
|
+
Full gate suite against the new tree: lint, the four type-checks (TypeScript 6 and 7, src and tests), unit 3320, integration 103 serial + 57 parallel, depcruise (244 modules, Node 22.22.2), `npm audit` (0), production audit gate (0), verify-package manifest (247 files) and a fresh-install consumer boot (`pi-research --version` with the pi trio installed). Knowledge store matrix: lancedb 0.39.0/0.40.0 × apache-arrow 21.1.0/21.2.0 measured on the 36-case store suite — only the 21.1.0 column passes.
|
|
50
|
+
|
|
8
51
|
## [1.7.12] - 2026-10-17
|
|
9
52
|
|
|
10
53
|
### Changed
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lincoln504/pi-research",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.15",
|
|
4
4
|
"description": "Web research for your agents with smart and safe tooling + knowledge store",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -108,6 +108,7 @@
|
|
|
108
108
|
"deps:check": "depcruise --config config/tooling/dependency-cruiser.cjs --output-type err-long src",
|
|
109
109
|
"deps:generate": "npx --yes madge@8.0.0 --image docs/deps.svg src/index.ts",
|
|
110
110
|
"verify:changelog": "node scripts/verify-changelog.cjs",
|
|
111
|
+
"lock:restore-stubs": "node scripts/restore-lock-stubs.cjs",
|
|
111
112
|
"analyze:dependencies": "ncu",
|
|
112
113
|
"//analyze:compatibility": "depngn needs a node-version argument and a TTY (it calls stdout.clearLine): in CI or a pipe run it as: script -qec \"npx depngn 22.22.2\" /dev/null. Many entries report n/a (it cannot read engines for packages without the field).",
|
|
113
114
|
"analyze:compatibility": "depngn 22.22.2"
|
|
@@ -121,16 +122,16 @@
|
|
|
121
122
|
"dependencies": {
|
|
122
123
|
"@camoufox/camoufox": "^0.5.7",
|
|
123
124
|
"@kreuzberg/html-to-markdown-node": "^3.7.2",
|
|
124
|
-
"@lancedb/lancedb": "0.
|
|
125
|
+
"@lancedb/lancedb": "0.40.0",
|
|
125
126
|
"apache-arrow": "21.1.0",
|
|
126
127
|
"bgutils-js": "^4.0.3",
|
|
127
128
|
"esbuild": "^0.28.2",
|
|
128
|
-
"impit": "0.14.
|
|
129
|
+
"impit": "0.14.6",
|
|
129
130
|
"jsdom": "^30.1.0",
|
|
130
131
|
"node-html-markdown": "^2.0.0",
|
|
131
132
|
"pdf-oxide-wasm": "^0.3.77",
|
|
132
133
|
"playwright-core": "1.62.1",
|
|
133
|
-
"poolifier": "^
|
|
134
|
+
"poolifier": "^6.0.1",
|
|
134
135
|
"undici": "^8.11.2",
|
|
135
136
|
"youtubei.js": "^18.0.0"
|
|
136
137
|
},
|
|
@@ -141,7 +142,7 @@
|
|
|
141
142
|
"typebox": ">=1.3.27 <2"
|
|
142
143
|
},
|
|
143
144
|
"optionalDependencies": {
|
|
144
|
-
"@huggingface/transformers": "4.3.
|
|
145
|
+
"@huggingface/transformers": "4.3.1",
|
|
145
146
|
"webgpu": "^0.6.0"
|
|
146
147
|
},
|
|
147
148
|
"overrides": {
|
|
@@ -165,12 +166,12 @@
|
|
|
165
166
|
"@earendil-works/pi-tui": ">=0.99.0 <2",
|
|
166
167
|
"@eslint/js": "^10.0.1",
|
|
167
168
|
"@types/jsdom": "^30.0.0",
|
|
168
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
169
|
-
"@typescript-eslint/parser": "8.
|
|
169
|
+
"@typescript-eslint/eslint-plugin": "8.72.0",
|
|
170
|
+
"@typescript-eslint/parser": "8.72.0",
|
|
170
171
|
"@vitest/coverage-v8": "^5.0.3",
|
|
171
172
|
"dependency-cruiser": "^18.5.0",
|
|
172
173
|
"depngn": "^0.6.0",
|
|
173
|
-
"eslint": "10.
|
|
174
|
+
"eslint": "10.13.0",
|
|
174
175
|
"npm-check-updates": "^23.1.0",
|
|
175
176
|
"typebox": "1.3.27",
|
|
176
177
|
"typescript": ">=6.0.3 <6.1.0",
|
package/scripts/setup.cjs
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* PLAYWRIGHT_INSTALL_DEPS=true - also install Linux system deps (or pass --system-deps)
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
const {
|
|
21
|
+
const { spawnSync } = require('child_process');
|
|
22
22
|
const { existsSync, readdirSync, statSync } = require('fs');
|
|
23
23
|
const { homedir } = require('os');
|
|
24
24
|
const path = require('path');
|
|
@@ -98,7 +98,13 @@ if (process.env.PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD === '1') {
|
|
|
98
98
|
// ships the same `install-deps` subcommand (verified: its CLI lists it).
|
|
99
99
|
const playwrightCoreBin = path.join(projectRoot, 'node_modules', '.bin', isWindows ? 'playwright-core.cmd' : 'playwright-core');
|
|
100
100
|
const cli = existsSync(playwrightCoreBin) ? playwrightCoreBin : 'playwright-core';
|
|
101
|
-
|
|
101
|
+
// spawnSync with an ARGV ARRAY (no shell), for the same reason the browser fetch
|
|
102
|
+
// below and prepare.cjs do: `cli` sits under the project root, so a shell string
|
|
103
|
+
// would execute `$(...)` or backticks in a directory name at install time.
|
|
104
|
+
// This branch is Linux-only, so no `.cmd` shim (which needs a shell) is involved.
|
|
105
|
+
const res = spawnSync(cli, ['install-deps'], { stdio: 'inherit', env: { ...env, PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '0' } });
|
|
106
|
+
if (res.error) throw res.error;
|
|
107
|
+
if (res.status !== 0) throw new Error(`playwright-core install-deps exited with ${res.signal ? `signal ${res.signal}` : `code ${res.status}`}`);
|
|
102
108
|
} catch (e) {
|
|
103
109
|
console.warn(`WARNING: could not install system dependencies. Run: sudo apt-get install -y libgbm1 libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libxkbcommon0 libxcomposite1\nReason: ${e instanceof Error ? e.message : String(e)}\n(These are the libraries headless camoufox needs. Xvfb is NOT required for the default headless mode — only add it if you opt into virtual-display mode with PI_RESEARCH_USE_XVFB=true.)`);
|
|
104
110
|
}
|
package/src/core/pi-version.ts
CHANGED
|
@@ -147,8 +147,18 @@ export const PI_MIN_VERSION: SemverParts = { major: 0, minor: 99, patch: 0 };
|
|
|
147
147
|
* Nothing this package consumes is removed or re-signed; the four type-checks pass against
|
|
148
148
|
* 1.3.0 (TypeScript 6 and 7, src and tests), and `typebox` still pins 1.3.27 in `pi-ai`
|
|
149
149
|
* and `pi-coding-agent`, so the lockstep rule and the 0.99.0 floor are unchanged.
|
|
150
|
+
*
|
|
151
|
+
* 1.4.0 (2026-10-21) was verified on 2026-10-21 by diffing the published tarballs:
|
|
152
|
+
* `@earendil-works/pi-coding-agent`'s extension surface file
|
|
153
|
+
* (`dist/core/extensions/types.d.ts`) is byte-identical, and its `package.json` still pins
|
|
154
|
+
* `typebox` at `1.3.27`, so the lockstep rule and the 0.99.0 floor are unchanged. The host's
|
|
155
|
+
* own changes are internal: `pi-tui` fixes the unclosed `$$`/`\[` display-math swallowing of
|
|
156
|
+
* later Markdown tables and renders bold/italic next to CJK punctuation (rendering fixes this
|
|
157
|
+
* package's custom TUI panels do not share), and restores terminal modes on unclean exit. The
|
|
158
|
+
* `before_provider_headers` attribution-header change and the `generateSummary()`
|
|
159
|
+
* `reserveTokens` change touch no API this package registers or calls.
|
|
150
160
|
*/
|
|
151
|
-
export const PI_TESTED_MAX_VERSION: SemverParts = { major: 1, minor:
|
|
161
|
+
export const PI_TESTED_MAX_VERSION: SemverParts = { major: 1, minor: 4, patch: 0 };
|
|
152
162
|
|
|
153
163
|
export type PiCompatibilityLevel = 'ok' | 'unparseable' | 'too-old' | 'untested';
|
|
154
164
|
|
|
@@ -137,7 +137,10 @@ function ageToColor(
|
|
|
137
137
|
* headPos is returned as a float for smooth interpolation.
|
|
138
138
|
*/
|
|
139
139
|
function computeHeadState(frame: number, available: number): { headPos: number; goingRight: boolean; isDwelling: boolean } {
|
|
140
|
-
|
|
140
|
+
// Last valid cell index. Clamped at 0, not 1: with a single cell the head must stay
|
|
141
|
+
// on cell 0, because index 1 is outside the trail array (it silently grew the array
|
|
142
|
+
// to 2 entries, so the width check in generateWaveFill reset the trail every frame).
|
|
143
|
+
const M = Math.max(0, available - 1);
|
|
141
144
|
const D = DWELL_FRAMES;
|
|
142
145
|
const halfPeriod = PERIOD_FRAMES / 2;
|
|
143
146
|
const pos = frame % PERIOD_FRAMES;
|
package/src/youtube/potoken.ts
CHANGED
|
@@ -94,6 +94,9 @@ let wedged = false;
|
|
|
94
94
|
// timer on the browser page-creation mutex in thread-worker-messaging.ts.
|
|
95
95
|
const MINT_HARD_RELEASE_MS = 5 * 60 * 1000;
|
|
96
96
|
|
|
97
|
+
/** Upper bound on the BotGuard interpreter source compiled via `new Function` (real ones are a few hundred KB). */
|
|
98
|
+
const MAX_INTERPRETER_CHARS = 8 * 1024 * 1024;
|
|
99
|
+
|
|
97
100
|
/**
|
|
98
101
|
* Mint a session-bound token (for `identifiers[0]`, the visitorData) plus one
|
|
99
102
|
* content-bound token per remaining identifier (the video IDs), all from a
|
|
@@ -235,6 +238,12 @@ async function doMint(
|
|
|
235
238
|
|
|
236
239
|
const interpreter = challenge.interpreterJavascript?.privateDoNotAccessOrElseSafeScriptWrappedValue;
|
|
237
240
|
if (!interpreter) throw new Error('BotGuard interpreter script missing');
|
|
241
|
+
// Bound what reaches `new Function`: the value crossed the network inside a parsed
|
|
242
|
+
// JSON envelope, so refuse anything that is not a string or is implausibly large
|
|
243
|
+
// (real BotGuard interpreters are a few hundred KB) rather than compile it.
|
|
244
|
+
if (typeof interpreter !== 'string' || interpreter.length > MAX_INTERPRETER_CHARS) {
|
|
245
|
+
throw new Error('BotGuard interpreter script has an unexpected shape or size');
|
|
246
|
+
}
|
|
238
247
|
// Eval in the Node realm so the VM and bgutils share one Uint8Array realm.
|
|
239
248
|
// The interpreter is YouTube's BotGuard VM, fetched over HTTPS from Google's
|
|
240
249
|
// attestation endpoint by bgutils — running it is required and inherent to
|