This repository contains impers, a Node.js + TypeScript library that wraps libcurl for browser impersonation and HTTP/2/3 support.
src/: TypeScript source. Key areas includecore/(Curl handles),ffi/(Koffi bindings),http/(request/response/session helpers),websocket/,types/, andutils/.tests/: Jest test suite (e.g.,tests/http.test.ts) plus shared helpers intests/setup.tsandtests/mock-server.ts.examples/: Runnable usage samples likeexamples/simple-get.tsandexamples/websocket.ts.dist/: Generated build output fromnpm run build(do not edit by hand).
npm run build: Compile TypeScript fromsrc/intodist/.npm run lint: Run ESLint over the codebase.npm test: Run Jest tests (ESM,ts-jestpreset).npm run test:watch: Re-run tests in watch mode during development.
Spritually, the API should be both nodejs native and similar to the sibling python project curl-cffi, which you can find in ../curl_cffi.
However, the API should not be a one-to-one mapping to anything.
- TypeScript with ESM (
"type": "module"); follow the existing import style andNodeNextmodule resolution. - Use 2-space indentation, double quotes for strings, and semicolons, matching the current files.
- File names are lowercase and descriptive (
request.ts,websocket.ts). Tests end with.test.ts. - Linting is enforced via ESLint +
typescript-eslint(eslint.config.js); keep code consistent with lint rules.
- Tests live under
tests/and are matched by**/tests/**/*.test.ts. - Use
tests/mock-server.tsfor local HTTP behavior when needed. - Keep new tests focused on observable behavior (status, headers, cookies, body parsing).
- Commit history is short; existing messages are simple, imperative, sentence-case (e.g., “Add LICENSE”). Follow that style.
- PRs should include: a clear description, tests run (
npm test/npm run lint), and any user-facing API changes (updateREADME.mdorexamples/when relevant).
- Node.js 18+ is required.
- For full fingerprint support, install
curl-impersonateand setLIBCURL_PATHif it is not on the default library path (seeREADME.md).