@contentauth/c2pa-node 0.5.5 → 0.6.1

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/Cargo.toml CHANGED
@@ -3,6 +3,7 @@ name = "c2pa-node"
3
3
  version = "0.1.0"
4
4
  license = "MIT"
5
5
  edition = "2021"
6
+ rust-version.workspace = true
6
7
  exclude = ["index.node"]
7
8
 
8
9
  [lib]
@@ -11,7 +12,7 @@ crate-type = ["cdylib"]
11
12
  [dependencies]
12
13
  async-trait = "0.1.77"
13
14
  ciborium = "0.2.2"
14
- c2pa = { version = "0.82.1", default-features = false, features = ["file_io", "pdf", "fetch_remote_manifests", "add_thumbnails", "rust_native_crypto", "default_http"] }
15
+ c2pa = { workspace = true, features = ["file_io", "add_thumbnails"] }
15
16
  futures = "0.3"
16
17
  image = "0.25.6"
17
18
  neon = { version = "1.0.0", default-features = false, features = [
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Content Authenticity Initiative
3
+ © Copyright 2025 Adobe. All rights reserved.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,18 +1,14 @@
1
1
  # C2PA Node.js library
2
2
 
3
- The [c2pa-node-v2](https://github.com/contentauth/c2pa-node-v2) repository implements a Node.js API that can:
3
+ `@contentauth/c2pa-node` is a Node.js library in the [c2pa-js](https://github.com/contentauth/c2pa-js) monorepo that can:
4
4
  - Read and validate C2PA data from media files in supported formats.
5
5
  - Add signed manifests to media files in supported formats.
6
6
 
7
- **WARNING**: This is an early version of this library, and there may be bugs and unimplemented features.
8
-
9
7
  ## Prerequisites
10
8
 
11
- To use the C2PA Node library, you must install:
12
- - A [supported version of Node](https://github.com/neon-bindings/neon#platform-support).
13
- - [Rust](https://www.rust-lang.org/tools/install).
9
+ To use the C2PA Node library you need Node.js **>=22**. If you need to manage multiple versions of Node on your machine, use a tool such as [nvm](https://github.com/nvm-sh/nvm).
14
10
 
15
- If you need to manage multiple versions of Node on your machine, use a tool such as [nvm](https://github.com/nvm-sh/nvm).
11
+ To **build from source** you also need [Rust](https://www.rust-lang.org/tools/install). This is not required when installing the package normally — precompiled binaries are downloaded automatically during installation.
16
12
 
17
13
  ## Installation
18
14
 
@@ -47,15 +43,15 @@ This command will download precompiled binaries for the following systems:
47
43
 
48
44
  ## Documentation
49
45
 
50
- Complete API documentation is generated from TypeScript source using [TypeDoc](https://typedoc.org/) and published to GitHub Pages at [https://contentauth.github.io/c2pa-node-v2/](https://contentauth.github.io/c2pa-node-v2/).
46
+ Complete API documentation is generated from TypeScript source using [TypeDoc](https://typedoc.org/) and published to GitHub Pages at [https://contentauth.github.io/c2pa-js/](https://contentauth.github.io/c2pa-js/).
51
47
 
52
- To generate documentation locally:
48
+ To generate documentation locally, run the following from the monorepo root:
53
49
 
54
50
  ```bash
55
- pnpm build:docs
51
+ pnpm ci:docs
56
52
  ```
57
53
 
58
- This generates HTML documentation in the `docs/` directory. The `docs/` directory is not checked into version control. It's automatically generated and published to GitHub Pages whenever a new release is published.
54
+ This generates HTML documentation in the `docs/` directory at the repo root. It is not checked into version control and is automatically published to GitHub Pages whenever a new release is published.
59
55
 
60
56
  ## Components
61
57
 
@@ -640,11 +636,11 @@ const builder = Builder.new(urlSettings);
640
636
 
641
637
 
642
638
  ### Build and use custom binary
643
- **Build rust binary:**
644
- ```
645
- npm run build:rust
639
+ **Build Rust binary:**
640
+ ```bash
641
+ pnpm run build:rust
646
642
  ```
647
- **Use custom rust binary:**
643
+ **Use custom Rust binary:**
648
644
  ```bash
649
645
  export C2PA_LIBRARY_PATH=<path-to-binary-folder>/index.node
650
646
  ```
package/dist/Builder.js CHANGED
@@ -3,18 +3,10 @@
3
3
  // Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
4
4
  // or the MIT license (http://opensource.org/licenses/MIT),
5
5
  // at your option.
6
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
- return new (P || (P = Promise))(function (resolve, reject) {
9
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
- step((generator = generator.apply(thisArg, _arguments || [])).next());
13
- });
14
- };
15
6
  import { getNeonBinary } from "./binary.js";
16
7
  import { IdentityAssertionSigner } from "./IdentityAssertion.js";
17
8
  export class Builder {
9
+ builder;
18
10
  constructor(builder) {
19
11
  this.builder = builder;
20
12
  }
@@ -63,40 +55,32 @@ export class Builder {
63
55
  addAssertion(label, assertion, assertionKind) {
64
56
  return getNeonBinary().builderAddAssertion.call(this.builder, label, assertion, assertionKind);
65
57
  }
66
- addResource(uri, resource) {
67
- return __awaiter(this, void 0, void 0, function* () {
68
- return getNeonBinary().builderAddResource.call(this.builder, uri, resource);
69
- });
58
+ async addResource(uri, resource) {
59
+ return getNeonBinary().builderAddResource.call(this.builder, uri, resource);
70
60
  }
71
- addIngredient(ingredientJson, ingredient) {
72
- return __awaiter(this, void 0, void 0, function* () {
73
- if (ingredient) {
74
- return getNeonBinary().builderAddIngredientFromAsset.call(this.builder, ingredientJson, ingredient);
75
- }
76
- else {
77
- return getNeonBinary().builderAddIngredient.call(this.builder, ingredientJson);
78
- }
79
- });
61
+ async addIngredient(ingredientJson, ingredient) {
62
+ if (ingredient) {
63
+ return getNeonBinary().builderAddIngredientFromAsset.call(this.builder, ingredientJson, ingredient);
64
+ }
65
+ else {
66
+ return getNeonBinary().builderAddIngredient.call(this.builder, ingredientJson);
67
+ }
80
68
  }
81
69
  addIngredientFromReader(reader) {
82
70
  const readerHandle = reader.getHandle();
83
71
  const result = getNeonBinary().builderAddIngredientFromReader.call(this.builder, readerHandle);
84
72
  return JSON.parse(result);
85
73
  }
86
- toArchive(asset) {
87
- return __awaiter(this, void 0, void 0, function* () {
88
- return getNeonBinary().builderToArchive.call(this.builder, asset);
89
- });
74
+ async toArchive(asset) {
75
+ return getNeonBinary().builderToArchive.call(this.builder, asset);
90
76
  }
91
- static fromArchive(asset, settings) {
92
- return __awaiter(this, void 0, void 0, function* () {
93
- const settingsStr = settings
94
- ? typeof settings === "string"
95
- ? settings
96
- : JSON.stringify(settings)
97
- : undefined;
98
- return new Builder(yield getNeonBinary().builderFromArchive(asset, settingsStr));
99
- });
77
+ static async fromArchive(asset, settings) {
78
+ const settingsStr = settings
79
+ ? typeof settings === "string"
80
+ ? settings
81
+ : JSON.stringify(settings)
82
+ : undefined;
83
+ return new Builder(await getNeonBinary().builderFromArchive(asset, settingsStr));
100
84
  }
101
85
  sign(signer, input, output) {
102
86
  return getNeonBinary().builderSign.call(this.builder, signer.getHandle(), input, output);
@@ -105,59 +89,55 @@ export class Builder {
105
89
  const input = { path: filePath };
106
90
  return getNeonBinary().builderSign.call(this.builder, signer.getHandle(), input, output);
107
91
  }
108
- signConfigAsync(callback, signerConfig, input, output) {
109
- return __awaiter(this, void 0, void 0, function* () {
110
- return getNeonBinary()
111
- .builderSignConfigAsync.call(this.builder, callback, signerConfig, input, output)
112
- .then((result) => {
113
- // output is a buffer and result is the manifest and the signed asset.
114
- if ("buffer" in output) {
115
- if ("signedAsset" in result && "manifest" in result) {
116
- output.buffer = result.signedAsset;
117
- return result.manifest;
118
- }
119
- else {
120
- throw new Error("Unexpected result for DestinationBuffer");
121
- }
92
+ async signConfigAsync(callback, signerConfig, input, output) {
93
+ return getNeonBinary()
94
+ .builderSignConfigAsync.call(this.builder, callback, signerConfig, input, output)
95
+ .then((result) => {
96
+ // output is a buffer and result is the manifest and the signed asset.
97
+ if ("buffer" in output) {
98
+ if ("signedAsset" in result && "manifest" in result) {
99
+ output.buffer = result.signedAsset;
100
+ return result.manifest;
122
101
  }
123
102
  else {
124
- // output is a file and result is the bytes of the manifest.
125
- return result;
103
+ throw new Error("Unexpected result for DestinationBuffer");
126
104
  }
127
- })
128
- .catch((error) => {
129
- throw error;
130
- });
105
+ }
106
+ else {
107
+ // output is a file and result is the bytes of the manifest.
108
+ return result;
109
+ }
110
+ })
111
+ .catch((error) => {
112
+ throw error;
131
113
  });
132
114
  }
133
- signAsync(signer, input, output) {
134
- return __awaiter(this, void 0, void 0, function* () {
135
- const neonHandle = signer.getHandle();
136
- const isIdentity = signer instanceof IdentityAssertionSigner;
137
- const neonFn = isIdentity
138
- ? getNeonBinary().builderIdentitySignAsync
139
- : getNeonBinary().builderSignAsync;
140
- return neonFn
141
- .call(this.builder, neonHandle, input, output)
142
- .then((result) => {
143
- // output is a buffer and result is the manifest and the signed asset.
144
- if ("buffer" in output) {
145
- if ("signedAsset" in result && "manifest" in result) {
146
- output.buffer = result.signedAsset;
147
- return result.manifest;
148
- }
149
- else {
150
- throw new Error("Unexpected result for DestinationBuffer");
151
- }
115
+ async signAsync(signer, input, output) {
116
+ const neonHandle = signer.getHandle();
117
+ const isIdentity = signer instanceof IdentityAssertionSigner;
118
+ const neonFn = isIdentity
119
+ ? getNeonBinary().builderIdentitySignAsync
120
+ : getNeonBinary().builderSignAsync;
121
+ return neonFn
122
+ .call(this.builder, neonHandle, input, output)
123
+ .then((result) => {
124
+ // output is a buffer and result is the manifest and the signed asset.
125
+ if ("buffer" in output) {
126
+ if ("signedAsset" in result && "manifest" in result) {
127
+ output.buffer = result.signedAsset;
128
+ return result.manifest;
152
129
  }
153
130
  else {
154
- // output is a file and result is the bytes of the manifest.
155
- return result;
131
+ throw new Error("Unexpected result for DestinationBuffer");
156
132
  }
157
- })
158
- .catch((error) => {
159
- throw error;
160
- });
133
+ }
134
+ else {
135
+ // output is a file and result is the bytes of the manifest.
136
+ return result;
137
+ }
138
+ })
139
+ .catch((error) => {
140
+ throw error;
161
141
  });
162
142
  }
163
143
  getManifestDefinition() {