@chegger/node-obscura-aws-lambda

中文文档
0.2.6发布于 2026/11/05MITTypeScriptCommonJS零依赖构建来源已验证近 30 天下载 1948

AWS Lambda-specific Node.js runtime wrapper for the Obscura browser binary.

原始使用文档
文档目录10 节
  1. Install
  2. Usage
  3. API
  4. getBinaryPath()
  5. startObscura(options?)
  6. Build the Lambda Artifact
  7. Smoke-test the built artifact
  8. Environment variables
  9. Releasing
  10. License

@chegger/node-obscura-aws-lambda

AWS Lambda-specific Node.js wrapper around the Obscura browser binary.

  • Obscura: same version as this package (see package.json; built tag and checksum are in dist/build-metadata.json)
  • Target runtime: AWS Lambda nodejs24.x on Linux x64

Install

npm install @chegger/node-obscura-aws-lambda

Usage

const { chromium } = require('playwright-core');
const { startObscura } = require('@chegger/node-obscura-aws-lambda');

async function main() {
  const obscura = await startObscura({ stealth: true });
  const browser = await chromium.connectOverCDP(obscura.endpoint);

  try {
    const context = browser.contexts()[0] || (await browser.newContext());
    const page = await context.newPage();
    await page.goto('https://example.com');
    console.log(await page.title());
  } finally {
    await browser.close();
    await obscura.close();
  }
}

main().catch((error) => {
  console.error(error);
  process.exit(1);
});

If you use CDK NodejsFunction, force Docker bundling so the postinstall step runs in a Linux x64 Lambda-like environment and includes the downloaded binary in the deployment artifact:

const myLambdaFunction = new lambda.NodejsFunction(this, 'MyLambdaFunction', {
  // ...
  runtime: l.Runtime.NODEJS_24_X,
  architecture: l.Architecture.X86_64,
  bundling: {
    forceDockerBundling: true,
    nodeModules: ['@chegger/node-obscura-aws-lambda'],
  },
});

API

getBinaryPath()

Returns the installed Lambda-specific Obscura binary path.

startObscura(options?)

Starts obscura serve and resolves when the CDP endpoint is ready.

Options:

  • port?: number
  • host?: string
  • stealth?: boolean
  • startupTimeoutMs?: number
  • extraArgs?: string[]

Returns:

{
  endpoint: string;
  wsEndpoint: string;
  close: () => Promise<void>;
}

Build the Lambda Artifact

This repo is Docker-first. You do not need Rust installed locally for the main build flow.

npm run build:artifact

That script will:

  1. clone the upstream obscura source
  2. build it inside an Amazon Linux 2023 Docker image
  3. package obscura and obscura-worker into: dist/obscura-x86_64-linux-lambda.tar.gz
  4. write a checksum and build metadata

Smoke-test the built artifact

npm run smoke:test

This runs the built binary inside the AWS Lambda Node 24 base image and waits for /json/version to come up.

Environment variables

Runtime install:

  • OBSCURA_AWS_LAMBDA_RELEASE_TAG overrides the package release tag to download. Default: v${package.version}
  • OBSCURA_AWS_LAMBDA_DOWNLOAD_BASE_URL overrides the binary download base URL
  • NODE_OBSCURA_AWS_LAMBDA_SKIP_DOWNLOAD=1 skips binary download during install

Build scripts:

  • OBSCURA_UPSTREAM_REPO overrides the upstream Obscura git repo
  • OBSCURA_UPSTREAM_TAG overrides the upstream Obscura git tag. Default: v${package.version}
  • OBSCURA_CARGO_FEATURES overrides Cargo features. Default: stealth
  • OBSCURA_LAMBDA_DOCKER_TAG overrides the local Docker builder image tag
  • OBSCURA_LAMBDA_ARCHIVE overrides the archive path used by the smoke test
  • OBSCURA_LAMBDA_SMOKE_IMAGE overrides the Lambda base image used by the smoke test

Releasing

Package version and upstream Obscura tag are kept in sync via package.json.

npm run version:set -- 0.1.9
git add package.json package-lock.json
git commit -m "Release 0.1.9 with upstream Obscura v0.1.9."
git push origin main
git tag v0.1.9
git push origin v0.1.9

CI then builds the Lambda binary, creates the GitHub release, and publishes to npm.

License

MIT for this wrapper package. Obscura itself remains Apache-2.0 under its upstream project.

版本与发布记录

@chegger/node-obscura-aws-lambda 共发布 16 个版本,首次发布于 2026/05/05;过去 12 个月发布了 16 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.2.6latest2026/11/054 天前
0.2.52026/10/2020 天前
0.2.42026/10/081 个月前
0.2.32026/09/231 个月前
0.2.22026/09/072 个月前
0.2.12026/08/242 个月前

关于 @chegger/node-obscura-aws-lambda 的常见问题

@chegger/node-obscura-aws-lambda 是什么?

AWS Lambda-specific Node.js runtime wrapper for the Obscura browser binary.

如何安装 @chegger/node-obscura-aws-lambda?

在项目目录运行 npm install @chegger/node-obscura-aws-lambda,或使用 pnpm add / yarn add / bun add。

@chegger/node-obscura-aws-lambda 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@chegger/node-obscura-aws-lambda 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@chegger/node-obscura-aws-lambda 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@chegger/node-obscura-aws-lambda 可以商用吗?

@chegger/node-obscura-aws-lambda 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@chegger/node-obscura-aws-lambda 的下载量有多少?

根据 npm 官方下载统计,@chegger/node-obscura-aws-lambda 在 2026/10/10 – 2026/11/08 这 30 天内被下载 1,948 次,日均约 65 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@chegger/node-obscura-aws-lambda 还在维护吗?

最新版本 0.2.6 发布于 2026/11/05(4 天前);至今共发布 16 个版本,其中过去 12 个月发布了 16 个;首次发布于 2026/05/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。