@contentauth/c2pa-node 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Content Authenticity Initiative
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,87 @@
1
+ # C2PA Node.js library
2
+
3
+ The [c2pa-node](https://github.com/contentauth/c2pa-node-v2) repository implements a Node.js API that can:
4
+ - Read and validate C2PA data from media files in supported formats.
5
+ - Add signed manifests to media files in supported formats.
6
+
7
+ For more information on using the library in an application, see [Using the CAI Node library](docs/usage.md).
8
+
9
+ **WARNING**: This is an early prerelease version of this library. There may be bugs and unimplemented features, and the API is subject to change.
10
+
11
+ <div style={{display: 'none'}}>
12
+
13
+ For the best experience, read the docs on the [CAI Open Source SDK documentation website](https://opensource.contentauthenticity.org/docs/c2pa-node/). Some additional documentation for this repository is also available on GitHub:
14
+
15
+ - [Using the Node library](docs/usage.md)
16
+ - [Supported media file formats](https://opensource.contentauthenticity.org/docs/c2pa-node/supported-formats)
17
+ - [Release notes](docs/release-notes.md)
18
+ - [Contributing to the project](docs/project-contributions.md)
19
+
20
+ </div>
21
+
22
+ ## Prerequisites
23
+
24
+ To use the C2PA Node library, you must install:
25
+ - A [supported version of Node](https://github.com/neon-bindings/neon#platform-support).
26
+ - [Rust](https://www.rust-lang.org/tools/install).
27
+
28
+ If you need to manage multiple versions of Node on your machine, use a tool such as [nvm](https://github.com/nvm-sh/nvm).
29
+
30
+ ## Installation
31
+
32
+ ### Installing for use in a client app
33
+
34
+ Using npm:
35
+
36
+ ```sh
37
+ $ npm install c2pa-node
38
+ ```
39
+
40
+ Using Yarn:
41
+
42
+ ```sh
43
+ $ yarn add c2pa-node
44
+ ```
45
+
46
+ Using pnpm:
47
+
48
+ ```sh
49
+ $ pnpm add c2pa-node
50
+ ```
51
+
52
+ This command will download precompiled binaries for the following systems:
53
+
54
+ - Linux x86_64
55
+ - Linux aarch64 (ARM)
56
+ - macOS aarch64 (Apple Silicon)
57
+ - macOS x86_64 (Intel Mac)
58
+ - Windows x86
59
+ - Windows ARM
60
+
61
+ All other platforms require building a custom binary as described below, since the `postinstall` step builds the Rust library into a native Node.js module on your machine.
62
+
63
+ ### Building custom binaries
64
+
65
+ For a platform or architecture that does not have a precompiled binary, you must pre-build a custom binary by following these steps:
66
+
67
+ 1. [Install the Rust toolchain](https://www.rust-lang.org/tools/install).
68
+ 1. Run the following commands on the target system or VM:
69
+ ```sh
70
+ cd c2pa-node
71
+ pnpm install
72
+ pnpm build:rust
73
+ ```
74
+ 1. Copy the binary to a place that is accessible by your application (in this example, it is `/path/to/my/application/resources`):
75
+ ```sh
76
+ cd /path/to/my/application
77
+ mkdir resources
78
+ cp /path/to/c2pa-node/generated/c2pa.node resources/c2pa.node
79
+ ```
80
+ 1. Set the the `C2PA_LIBRARY_PATH` environment variable to the path to the `c2pa.node` module by entering these commands:
81
+ ```sh
82
+ export C2PA_LIBRARY_PATH=resources/c2pa.node
83
+ npm install c2pa-node
84
+ npm start
85
+ ```
86
+
87
+ **Important:** `C2PA_LIBRARY_PATH` _must_ be set while both **installing** or **adding** `c2pa-node` to your app to avoid building the Rust code. It must _also_ be set while **running** your app so that it loads the bindings from the correct location.
package/dist/index.js ADDED
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ // Copyright 2025 Adobe. All rights reserved.
3
+ // This file is licensed to you under the Apache License,
4
+ // Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
5
+ // or the MIT license (http://opensource.org/licenses/MIT),
6
+ // at your option.
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.Trustmark = exports.IdentityAssertionSigner = exports.IdentityAssertionBuilder = exports.CallbackSigner = exports.LocalSigner = exports.Reader = exports.Builder = void 0;
23
+ // Unless required by applicable law or agreed to in writing,
24
+ // this software is distributed on an "AS IS" BASIS, WITHOUT
25
+ // WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or
26
+ // implied. See the LICENSE-MIT and LICENSE-APACHE files for the
27
+ // specific language governing permissions and limitations under
28
+ // each license.
29
+ __exportStar(require("index.node"), exports);
30
+ var Builder_1 = require("./Builder");
31
+ Object.defineProperty(exports, "Builder", { enumerable: true, get: function () { return Builder_1.Builder; } });
32
+ var Reader_1 = require("./Reader");
33
+ Object.defineProperty(exports, "Reader", { enumerable: true, get: function () { return Reader_1.Reader; } });
34
+ var Signer_1 = require("./Signer");
35
+ Object.defineProperty(exports, "LocalSigner", { enumerable: true, get: function () { return Signer_1.LocalSigner; } });
36
+ Object.defineProperty(exports, "CallbackSigner", { enumerable: true, get: function () { return Signer_1.CallbackSigner; } });
37
+ var IdentityAssertion_1 = require("./IdentityAssertion");
38
+ Object.defineProperty(exports, "IdentityAssertionBuilder", { enumerable: true, get: function () { return IdentityAssertion_1.IdentityAssertionBuilder; } });
39
+ Object.defineProperty(exports, "IdentityAssertionSigner", { enumerable: true, get: function () { return IdentityAssertion_1.IdentityAssertionSigner; } });
40
+ var Trustmark_1 = require("./Trustmark");
41
+ Object.defineProperty(exports, "Trustmark", { enumerable: true, get: function () { return Trustmark_1.Trustmark; } });
package/package.json ADDED
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "@contentauth/c2pa-node",
3
+ "repository": {
4
+ "type": "git",
5
+ "url": "git+https://github.com/contentauth/c2pa-node-v2.git"
6
+ },
7
+ "version": "0.1.0",
8
+ "description": "Node.js bindings for C2PA",
9
+ "main": "dist/index.js",
10
+ "types": "dist/js-src/index.d.ts",
11
+ "files": [
12
+ "dist/js-src",
13
+ "dist/src",
14
+ "dist/Cargo.toml",
15
+ "dist/Cargo.lock"
16
+ ],
17
+ "engines": {
18
+ "node": ">=18.20.2"
19
+ },
20
+ "author": "Colin Murphy <colmurph@adobe.com>",
21
+ "license": "MIT",
22
+ "devDependencies": {
23
+ "@changesets/cli": "^2.29.5",
24
+ "@eslint/js": "^9.0.0",
25
+ "@neon-rs/cli": "0.1.82",
26
+ "@types/debug": "^4.1.12",
27
+ "@types/fs-extra": "^11.0.4",
28
+ "@types/jest": "^29.5.14",
29
+ "@types/node": "^22.10.1",
30
+ "@typescript-eslint/eslint-plugin": "^8.0.0",
31
+ "@typescript-eslint/parser": "^8.0.0",
32
+ "cpy-cli": "^5.0.0",
33
+ "eslint": "^9.32.0",
34
+ "fs-extra": "^11.3.0",
35
+ "jest": "^29.7.0",
36
+ "npm-run-all": "^4.1.5",
37
+ "rimraf": "^6.0.1",
38
+ "sharp": "^0.34.3",
39
+ "ts-jest": "^29.2.5",
40
+ "typedoc": "^0.28.9",
41
+ "typedoc-plugin-markdown": "^4.8.0",
42
+ "typescript": "^5.7.2"
43
+ },
44
+ "keywords": [
45
+ "c2pa"
46
+ ],
47
+ "bugs": {
48
+ "url": "https://github.com/contentauth/c2pa-node-v2/issues"
49
+ },
50
+ "homepage": "https://github.com/contentauth/c2pa-node-v2#readme",
51
+ "dependencies": {
52
+ "debug": "^4.4.0"
53
+ },
54
+ "scripts": {
55
+ "build": "run-s build:rust build:ts build:docs",
56
+ "build:debug": "run-s build:rust-debug build:ts",
57
+ "build:docs": "typedoc --plugin typedoc-plugin-markdown --readme none --out docs js-src/index.ts",
58
+ "build:rust": "pnpm run build:rust-debug --release",
59
+ "build:rust-debug": "cargo build --message-format=json-render-diagnostics > cargo.log",
60
+ "build:ts": "tsc -b && cpy index.node dist",
61
+ "changeset:publish": "changeset publish",
62
+ "ci": "run-s build:rust-debug build:ts test",
63
+ "clean": "rimraf dist generated target",
64
+ "cross": "pnpm run cross-build --release",
65
+ "cross-build": "cross build --message-format=json-render-diagnostics > cross.log",
66
+ "debug": "pnpm run cargo-build --",
67
+ "lint": "cargo clippy && pnpm eslint",
68
+ "postbuild:rust-debug": "neon dist < cargo.log",
69
+ "postcross-build": "neon dist -m /target < cross.log",
70
+ "release": "run-s build changeset:publish",
71
+ "test": "jest",
72
+ "test:watch": "jest --watch --runInBand --detectOpenHandles --forceExit"
73
+ }
74
+ }