Skip to content

0.2.0: adapters for axios, got, Puppeteer and Playwright; Node, Bun and Deno - #1

Merged
ralyodio merged 1 commit into
mainfrom
crawlers
Sep 5, 2026
Merged

0.2.0: adapters for axios, got, Puppeteer and Playwright; Node, Bun and Deno#1
ralyodio merged 1 commit into
mainfrom
crawlers

Conversation

@ralyodio

@ralyodio ralyodio commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

What

Adapters so the tools people already crawl with pay as they go:

tool add
fetch (Node/Bun/Deno/browser, undici, node-fetch, ky…) wrapFetch(fetch, { key })
axios attachX402(axios, client)
got / got-scraping / Crawlee got.extend(x402Hooks(client))
Puppeteer / Lightpanda over CDP attachX402(page, client)
Playwright await attachX402(context, client)

None import the library they adapt; the package stays at two dependencies.

Runtimes

Buffer and bare process.env removed; CI runs the suite and the CLI on Node 22/24, Bun and Deno 2. README has the badges and a per-tool section.

Verified

  • 54 tests on Node, Bun and Deno
  • axios and got tested against the real libraries; browser adapters against fakes
  • by hand: real Puppeteer on Chrome and on Lightpanda, real Playwright on Chrome — each loads a gated page with exactly one payment and the next page with none

Two things the real browsers caught and the tests now cover: a browser's 402 is the HTML sales page, not the offer, so adapters go back for it as JSON; and that retry must replace the caller's Accept, not add a second one.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NSGS7Sy3QmEgTNZDg4eq7g

…nd Deno

Most JavaScript crawling is a fetch under another name, and the rest is
axios, got (Crawlee underneath), Puppeteer or Playwright. This gives each of
them a one-line way to pay: present the filed pass on the way out, pay a 402
once, replay with the pass.

  wrapFetch(fetch, { key })            any fetch-shaped function
  attachX402(axios, client)            request + response interceptors
  got.extend(x402Hooks(client))        beforeRequest + afterResponse hooks
  attachX402(page, client)             Puppeteer: page.goto pays at navigation
  await attachX402(context, client)    Playwright: routed, the page sees the paid answer

None of the adapters import the library they adapt; the package stays two
dependencies. axios and got are tested against the real libraries; the
browser adapters against library-shaped fakes, and by hand with real
Puppeteer on Chrome and on Lightpanda and real Playwright on Chrome.

Two things the real browsers taught. A browser asks for text/html, and a
gateway answers that 402 with its sales page rather than the offer, so every
adapter goes back for the offer as JSON when the 402 carries none. And that
retry must REPLACE the caller's Accept, not add to it: axios sends
`Accept`, the override was `accept`, the Fetch API joined them, and the
gateway served the page again. `acceptingJson` is the fix.

Runtimes: base64 through atob/btoa instead of Buffer, env through
globalThis.process, so the same files run on Node 20.19+, Bun and Deno 2.
CI now runs the suite and the CLI on all three. README rewritten around
the tools people crawl with, with badges. 54 tests.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NSGS7Sy3QmEgTNZDg4eq7g
@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedgot@​16.0.09910010088100
Addedaxios@​1.20.09810010092100

View full report

@socket-security

Copy link
Copy Markdown

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn Medium
Low adoption: npm chunk-data

Location: Package overview

From: pnpm-lock.yamlnpm/got@16.0.0npm/chunk-data@0.1.0

ℹ Read more on: This package | This alert | What are unpopular packages?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Unpopular packages may have less maintenance and contain other problems.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/chunk-data@0.1.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@ralyodio
ralyodio merged commit 9442a36 into main Sep 5, 2026
6 checks passed
@ralyodio
ralyodio deleted the crawlers branch September 5, 2026 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant