c2pa-js
The old c2pa-js repository is now in c2pa-js-legacy and is deprecated. If you need to work with C2PA metadata in the browser, use the libraries in this repository instead.
JavaScript libraries and tools for working with C2PA metadata. This repository is part of the Content Authenticity Initiative.
Using this monorepo
This monorepo uses Nx and pnpm.
Prerequisites
Install the following before you work in this repository.
Node.js
Node.js v22 or later is required. Older versions may fail to build because of unrecognized file extensions.
If you use nvm, install a supported v22 release (for example, nvm install 22 or nvm install 22.22.0).
pnpm and Nx
Install pnpm and the Nx CLI globally:
npm install -g pnpm
npm install -g nx
Rust toolchain for building c2pa-wasm
To build from source instead of using published packages only, you need the Rust toolchain and other prerequisites. See Prerequisites in packages/c2pa-wasm/README.md.
Recommended setup order
- Install Node.js,
pnpm, and the Nx CLI (see the previous sections). - Install the Rust toolchain and
c2pa-wasmprerequisites (packages/c2pa-wasm/README.md). - From the repository root, run
pnpm installto install dependencies.
Running commands with Nx
Run tasks as nx <target> <project>. For example:
nx build c2pa-web # Builds c2pa-web and its dependencies
nx test c2pa-web # Builds and runs tests for c2pa-web
nx lint c2pa-web # Runs ESLint on c2pa-web
nx lint c2pa-web --fix # Runs ESLint and applies fixes
Committing changes for a release
Include a changeset when your change should ship in a release.
From the repository root:
pnpm changeset
Follow the prompts to bump affected packages. The command adds a Markdown file under .changeset/; commit that file with your pull request.
After the pull request merges to main, the changeset bot opens a release pull request. When that pull request merges, a new release is published.
Directory layout
See each package directory for full details.
packages
The /packages directory contains libraries published for production use.
c2pa-web
SDK for C2PA metadata in the browser. Source: packages/c2pa-web.
c2pa-wasm
WebAssembly bindings for c2pa-rs, built with wasm-bindgen. They power c2pa-web; most applications should use c2pa-web instead of calling the bindings directly. Source: packages/c2pa-wasm.
c2pa-types
TypeScript types generated from c2pa-rs structs for use by c2pa-web. Source: packages/c2pa-types.
tools
The /tools directory contains utilities for local development.
testbed
Minimal site for inspecting c2pa-web output and experimenting locally. Source: tools/testbed.
nx-wasm-bindgen
Custom Nx executor that builds c2pa-wasm with wasm-bindgen. Source: tools/nx-wasm-bindgen.
License
This project is licensed under the MIT license.