PageSourceSearch

https://opensource.contentauthenticity.org/assets/js/836572e5.4d2a16d1.js

js contentauthenticity.org collected 2026-09-24 08:25:05 UTC 7,940 bytes, 1 lines download raw bytes

1"use strict";(globalThis.webpackChunkopensource_contentauth_org=globalThis.webpackChunkopensource_contentauth_org||[]).push([[2458],{8453:(e,s,n)=>{n.d(s,{R:()=>r,x:()=>c});var i=n(6540);const t={},a=i.createContext(t);function r(e){const s=i.useContext(a);return i.useMemo(function(){return"function"==typeof e?e(s):{...s,...e}},[s,e])}function c(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:r(e.components),i.createElement(a.Provider,{value:s},e.children)}},9818:(e,s,n)=>{n.r(s),n.d(s,{assets:()=>l,contentTitle:()=>c,default:()=>h,frontMatter:()=>r,metadata:()=>i,toc:()=>d});const i=JSON.parse('{"id":"sdk-repos/c2pa-js/packages/c2pa-wasm/README","title":"c2pa-wasm","description":"The WebAssembly wrapper for c2pa-rs that powers c2pa-web, built with wasm-bindgen. While these bindings can be used directly, most users will prefer the convenience of c2pa-web.","source":"@site/docs/sdk-repos/c2pa-js/packages/c2pa-wasm/README.md","sourceDirName":"sdk-repos/c2pa-js/packages/c2pa-wasm","slug":"/sdk-repos/c2pa-js/packages/c2pa-wasm/","permalink":"/docs/sdk-repos/c2pa-js/packages/c2pa-wasm/","draft":false,"unlisted":false,"editUrl":"https://github.com/contentauth/c2pa-js/edit/main/packages/c2pa-wasm/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"docs","previous":{"title":"c2pa-types","permalink":"/docs/sdk-repos/c2pa-js/packages/c2pa-types/"},"next":{"title":"c2pa-utilities","permalink":"/docs/sdk-repos/c2pa-js/packages/c2pa-utilities/"}}');var t=n(4848),a=n(8453);const r={},c="c2pa-wasm",l={},d=[{value:"Installation",id:"installation",level:2},{value:"Development",id:"development",level:2},{value:"Prerequisites",id:"prerequisites",level:3},{value:"Rust",id:"rust",level:4},{value:"wasm-bindgen-cli",id:"wasm-bindgen-cli",level:4},{value:"wasm-pack",id:"wasm-pack",level:4},{value:"Building",id:"building",level:3},{value:"Testing",id:"testing",level:3}];function o(e){const s={a:"a",admonition:"admonition",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,a.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(s.header,{children:(0,t.jsx)(s.h1,{id:"c2pa-wasm",children:"c2pa-wasm"})}),"\n",(0,t.jsxs)(s.p,{children:["The WebAssembly wrapper for ",(0,t.jsx)(s.a,{href:"https://github.com/contentauth/c2pa-rs",children:(0,t.jsx)(s.code,{children:"c2pa-rs"})})," that powers ",(0,t.jsx)(s.code,{children:"c2pa-web"}),", built with ",(0,t.jsx)(s.a,{href:"https://github.com/wasm-bindgen/wasm-bindgen",children:"wasm-bindgen"}),". While these bindings can be used directly, most users will prefer the convenience of ",(0,t.jsx)(s.code,{children:"c2pa-web"}),"."]}),"\n",(0,t.jsx)(s.h2,{id:"installation",children:"Installation"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sh",children:"npm install @contentauth/c2pa-wasm\n"})}),"\n",(0,t.jsx)(s.h2,{id:"development",children:"Development"}),"\n",(0,t.jsx)(s.h3,{id:"prerequisites",children:"Prerequisites"}),"\n",(0,t.jsx)(s.p,{children:"Ensure the repo-wide prerequisites are installed:"}),"\n",(0,t.jsxs)(s.ul,{children:["\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.a,{href:"https://nodejs.org/",children:"Node.js"})," v22.22+"]}),"\n",(0,t.jsx)(s.li,{children:(0,t.jsx)(s.a,{href:"https://nx.dev/getting-started/intro",children:"Nx"})}),"\n",(0,t.jsx)(s.li,{children:(0,t.jsx)(s.a,{href:"https://pnpm.io/",children:"pnpm"})}),"\n"]}),"\n",(0,t.jsxs)(s.p,{children:["See the ",(0,t.jsx)(s.a,{href:"/docs/sdk-repos/c2pa-js/#prerequisites",children:"c2pa-js README"})," for details."]}),"\n",(0,t.jsx)(s.p,{children:"Then, install all of the following prerequisites:"}),"\n",(0,t.jsxs)(s.ul,{children:["\n",(0,t.jsx)(s.li,{children:(0,t.jsx)(s.a,{href:"#rust",children:"Rust"})}),"\n",(0,t.jsx)(s.li,{children:(0,t.jsx)(s.a,{href:"#wasm-bindgen-cli",children:"wasm-bindgen-cli"})}),"\n",(0,t.jsx)(s.li,{children:(0,t.jsx)(s.a,{href:"#wasm-pack",children:"wasm-pack"})}),"\n"]}),"\n",(0,t.jsx)(s.h4,{id:"rust",children:"Rust"}),"\n",(0,t.jsxs)(s.p,{children:["The minimum supported Rust version is ",(0,t.jsx)(s.strong,{children:"1.88.0"}),"."]}),"\n",(0,t.jsxs)(s.p,{children:["To install Rust via ",(0,t.jsx)(s.a,{href:"https://rustup.rs/",children:"rustup"}),":"]}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sh",children:"curl https://sh.rustup.rs -sSf | sh\n"})}),"\n",(0,t.jsxs)(s.p,{children:["For more information, see ",(0,t.jsx)(s.a,{href:"https://www.rust-lang.org/tools/install",children:"Install Rust"}),"."]}),"\n",(0,t.jsxs)(s.p,{children:["Additionally, you must install the ",(0,t.jsx)(s.code,{children:"wasm32-unknown-unknown"})," target:"]}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sh",children:"rustup target add wasm32-unknown-unknown\n"})}),"\n",(0,t.jsx)(s.h4,{id:"wasm-bindgen-cli",children:"wasm-bindgen-cli"}),"\n",(0,t.jsxs)(s.p,{children:["The ",(0,t.jsx)(s.code,{children:"wasm-bindgen-cli"})," provides options to tweak JavaScript generated by ",(0,t.jsx)(s.code,{children:"wasm-bindgen"}),"."]}),"\n",(0,t.jsxs)(s.p,{children:["For more information, see the ",(0,t.jsx)(s.a,{href:"https://wasm-bindgen.github.io/wasm-bindgen/reference/cli",children:"wasm-bindgen-cli documentation"}),"."]}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sh",children:"cargo install [email protected]\n"})}),"\n",(0,t.jsx)(s.admonition,{type:"info",children:(0,t.jsxs)(s.p,{children:["The version of ",(0,t.jsx)(s.code,{children:"wasm-bindgen-cli"})," ",(0,t.jsx)(s.strong,{children:"must"})," match the version of the ",(0,t.jsx)(s.code,{children:"wasm-bindgen"})," dependency in ",(0,t.jsx)(s.a,{href:"https://github.com/contentauth/c2pa-js/blob/main/packages/c2pa-wasm/Cargo.toml",children:(0,t.jsx)(s.code,{children:"Cargo.toml"})}),". A version mismatch will cause build failures with errors like ",(0,t.jsx)(s.em,{children:'"rust Wasm file schema version: X.X.X, this binary schema version: Y.Y.Y"'}),". If you encounter this, check ",(0,t.jsx)(s.code,{children:"Cargo.toml"})," for the correct version and reinstall the CLI accordingly."]})}),"\n",(0,t.jsx)(s.h4,{id:"wasm-pack",children:"wasm-pack"}),"\n",(0,t.jsx)(s.p,{children:"Wasm-pack is a tool for building and working with Rust-generated WebAssembly that interoperates with JavaScript."}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sh",children:"cargo install [email protected]\n"})}),"\n",(0,t.jsxs)(s.p,{children:["For more information, see the ",(0,t.jsx)(s.a,{href:"https://rustwasm.github.io/docs/wasm-pack/",children:"wasm-pack documentation"}),"."]}),"\n",(0,t.jsx)(s.h3,{id:"building",children:"Building"}),"\n",(0,t.jsx)(s.p,{children:"To build the library:"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sh",children:"nx build c2pa-wasm\n"})}),"\n",(0,t.jsxs)(s.p,{children:["This will execute the commands defined in the ",(0,t.jsx)(s.a,{href:"https://github.com/contentauth/c2pa-js-v2/blob/main/tools/nx-wasm-bindgen/src/executors/build/executor.ts",children:"nx-wasm-bindgen executor"})," to produce the final output in the ",(0,t.jsx)(s.code,{children:"pkg/"})," directory."]}),"\n",(0,t.jsx)(s.h3,{id:"testing",children:"Testing"}),"\n",(0,t.jsxs)(s.p,{children:["The library relies on ",(0,t.jsx)(s.a,{href:"https://rustwasm.github.io/docs/wasm-pack/",children:(0,t.jsx)(s.code,{children:"wasm-pack"})})," to run its tests. As a general principle, the majority of test coverage will come from ",(0,t.jsx)(s.code,{children:"c2pa-web"}),"'s test suite."]}),"\n",(0,t.jsx)(s.p,{children:"To run the tests:"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sh",children:"nx test c2pa-wasm\n"})})]})}function h(e={}){const{wrapper:s}={...(0,a.R)(),...e.components};return s?(0,t.jsx)(s,{...e,children:(0,t.jsx)(o,{...e})}):o(e)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.