Skip to content

feat: Add Node.js bindings via napi-rs#253

Open
davidfestal wants to merge 9 commits intooras-project:mainfrom
davidfestal:nodejs-bindings
Open

feat: Add Node.js bindings via napi-rs#253
davidfestal wants to merge 9 commits intooras-project:mainfrom
davidfestal:nodejs-bindings

Conversation

@davidfestal
Copy link
Copy Markdown

@davidfestal davidfestal commented Mar 31, 2026

Introduces Node.js bindings for the rust-oci-client using napi-rs, enabling Node.js applications to interact with OCI registries.

Features:

  • 17 OciClient methods: pull, push, manifests, blobs, tags, referrers
  • Authentication helpers: anonymous, basic, bearer
  • Platform resolver configuration via os/arch/variant filter
  • Full TypeScript definitions auto-generated

Supported platforms (7 targets):

  • macOS x86_64 and ARM64
  • Linux x86_64 and ARM64 (glibc)
  • Linux x86_64 and ARM64 (musl/Alpine)
  • Windows x86_64

CI/CD:

  • Build and test workflows for all platforms
  • Publish workflow for NPM releases
  • Node.js 22 and 24 support
  • Integration tests with Zot registry
Note:

In order to allow the publishing of the Javascript bindings to NPMJS, a NPM_TOKEN secret will be required in this repository.

Assisted-by: Cursor

Introduces Node.js bindings for the rust-oci-client using napi-rs,
enabling Node.js applications to interact with OCI registries.

Features:
- 17 OciClient methods: pull, push, manifests, blobs, tags, referrers
- Authentication helpers: anonymous, basic, bearer
- Platform resolver configuration via os/arch/variant filter
- Full TypeScript definitions auto-generated

Supported platforms (7 targets):
- macOS x86_64 and ARM64
- Linux x86_64 and ARM64 (glibc)
- Linux x86_64 and ARM64 (musl/Alpine)
- Windows x86_64

CI/CD:
- Build and test workflows for all platforms
- Publish workflow for npm releases
- Node.js 22 and 24 support
- Integration tests with Zot registry

Assisted-by: Cursor
Signed-off-by: David Festal <dfestal@redhat.com>
@davidfestal
Copy link
Copy Markdown
Author

davidfestal commented Mar 31, 2026

cc @TerryHowe This is the work I briefly told you about last week at KubeCon EU when discussing at the ORAS booth.

@davidfestal
Copy link
Copy Markdown
Author

davidfestal commented Mar 31, 2026

Before opening this PR, the result of the bindings publish workflow has already been pushed from my fork to my personal scope on NPMJS: @dfatwork/oci-client.
It can be easily tested from there in any Node.js project.

@davidfestal
Copy link
Copy Markdown
Author

cc @sabre1041

@TerryHowe
Copy link
Copy Markdown
Member

cc @TerryHowe This is the work I briefly told you about last week at KubeCon EU when discussing at the ORAS booth.

Ah, okay. Thanks. I'm not a maintainer on this project though, so they will need to chime in.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new napi-rs-based Node.js/TypeScript binding package for oci-client, plus CI workflows to build/test/publish prebuilt binaries across major platforms.

Changes:

  • Introduces a new bindings/nodejs workspace crate exposing an OciClient N-API surface (auth/config/manifest/blob APIs + TS types).
  • Adds Node-side tooling (Yarn v4, version sync script, TS config, tests including mock registry + Zot integration).
  • Adds GitHub Actions workflows for multi-target Node build/test, npm publish, and wires release flow to run Node checks.

Reviewed changes

Copilot reviewed 22 out of 23 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
Cargo.toml Converts repo to a Cargo workspace and centralizes shared package/dependency metadata.
bindings/nodejs/yarn.lock Adds Yarn lockfile for Node binding toolchain dependencies.
bindings/nodejs/tsconfig.json TypeScript compiler settings for the Node bindings package.
bindings/nodejs/src/lib.rs Implements the N-API Rust bindings (client/config/auth/types/manifests/constants).
bindings/nodejs/scripts/sync-version.js Syncs Node package version to Rust workspace version.
bindings/nodejs/scripts/fix-const-enums.js Post-processes generated .d.ts to avoid const enum declarations.
bindings/nodejs/README.md Documents installation/usage and exposed APIs for Node consumers.
bindings/nodejs/package.json Defines the npm package, scripts, napi targets, and dev dependencies.
bindings/nodejs/Cargo.toml New Rust crate manifest for the Node bindings (cdylib) and feature wiring.
bindings/nodejs/build.rs Sets up napi-build for generating bindings at build time.
bindings/nodejs/.yarnrc.yml Configures Yarn to use node-modules linker.
bindings/nodejs/.gitignore Ignores generated bindings artifacts, build outputs, and node_modules.
bindings/nodejs/.gitattributes Sets text/binary attributes and marks generated binding outputs as non-detectable.
bindings/nodejs/.editorconfig Establishes formatting defaults for the Node bindings subtree.
bindings/nodejs/test/zot-registry.ts Test utility to run Zot registry container for integration/push tests.
bindings/nodejs/test/tsconfig.json TS config for running AVA tests as ES modules.
bindings/nodejs/test/package.json Marks tests directory as ESM (type: module).
bindings/nodejs/test/mock-registry.ts Mock HTTP registry server using existing Rust fixtures for deterministic tests.
bindings/nodejs/test/bindings.spec.ts AVA test suite covering bindings behavior (auth/config/pull/push/etc.).
.github/workflows/release.yml Gates crates.io publish on Node build/test and adds npm publish job call.
.github/workflows/nodejs-publish-call.yml Reusable workflow to assemble artifacts and publish to npm.
.github/workflows/nodejs-build.yml Entry workflow to run Node build/test on PRs and main branch changes.
.github/workflows/nodejs-build-call.yml Reusable multi-platform build/test matrix for Node binaries + TS bindings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread bindings/nodejs/src/lib.rs
Comment thread .github/workflows/nodejs-build-call.yml Outdated
Comment thread .github/workflows/nodejs-build-call.yml Outdated
Comment thread bindings/nodejs/package.json
Comment thread bindings/nodejs/README.md
Comment thread .github/workflows/release.yml Outdated
Comment thread .github/workflows/nodejs-publish-call.yml Outdated
Comment thread bindings/nodejs/Cargo.toml Outdated
Copy link
Copy Markdown
Member

@TerryHowe TerryHowe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work overall — the binding coverage, test setup, and multi-platform CI are well done. Inline comments cover the critical and important issues. The two blockers are the release.yml coupling (Rust publish shouldn't depend on Node.js build success) and the platform filter bug (Os::Other/Arch::Other won't match typed oci-spec variants for standard platforms like linux/amd64).

Comment thread .github/workflows/release.yml Outdated
Comment thread bindings/nodejs/src/lib.rs Outdated
Comment thread Cargo.toml
Comment thread .github/workflows/nodejs-build-call.yml Outdated
Comment thread .github/workflows/nodejs-publish-call.yml
... according to review comments

Signed-off-by: David Festal <dfestal@redhat.com>
Assisted-by: Cursor
Signed-off-by: David Festal <dfestal@redhat.com>
Assisted-by: Cursor
Signed-off-by: David Festal <dfestal@redhat.com>
to avoid building napi bindings on bare cargo commands.

Signed-off-by: David Festal <dfestal@redhat.com>
Signed-off-by: David Festal <dfestal@redhat.com>
…te on dependency changes

Signed-off-by: David Festal <dfestal@redhat.com>
Signed-off-by: David Festal <dfestal@redhat.com>
Signed-off-by: David Festal <dfestal@redhat.com>
@davidfestal davidfestal requested a review from TerryHowe April 13, 2026 22:17
@davidfestal
Copy link
Copy Markdown
Author

@TerryHowe I fixed all your comments.

@davidfestal
Copy link
Copy Markdown
Author

@thomastaylor312 @bacongobbler @flavio any feedback on this PR ?

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.

3 participants