@contentauth/c2pa-node 0.5.1 → 0.5.3

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.lock CHANGED
@@ -150,9 +150,6 @@ name = "arbitrary"
150
150
  version = "1.4.1"
151
151
  source = "registry+https://github.com/rust-lang/crates.io-index"
152
152
  checksum = "dde20b3d026af13f561bdd0f15edf01fc734f0dafcedbaf42bba506a9517f223"
153
- dependencies = [
154
- "derive_arbitrary",
155
- ]
156
153
 
157
154
  [[package]]
158
155
  name = "arg_enum_proc_macro"
@@ -302,7 +299,7 @@ dependencies = [
302
299
  "addr2line",
303
300
  "cfg-if",
304
301
  "libc",
305
- "miniz_oxide",
302
+ "miniz_oxide 0.8.9",
306
303
  "object",
307
304
  "rustc-demangle",
308
305
  "windows-targets 0.52.6",
@@ -492,15 +489,15 @@ dependencies = [
492
489
 
493
490
  [[package]]
494
491
  name = "bytes"
495
- version = "1.10.1"
492
+ version = "1.11.1"
496
493
  source = "registry+https://github.com/rust-lang/crates.io-index"
497
- checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a"
494
+ checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33"
498
495
 
499
496
  [[package]]
500
497
  name = "c2pa"
501
- version = "0.75.6"
498
+ version = "0.77.0"
502
499
  source = "registry+https://github.com/rust-lang/crates.io-index"
503
- checksum = "ec84a99bf4acb2db1f9459f9668cac78fe26cf04c21ed7a04b3ce1044a02c7d6"
500
+ checksum = "fe6c3fcc525dcac6cde7d020cc4d3065b2d2042e48efc096baba97876b276f41"
504
501
  dependencies = [
505
502
  "asn1-rs",
506
503
  "async-generic",
@@ -511,8 +508,8 @@ dependencies = [
511
508
  "byteorder",
512
509
  "byteordered",
513
510
  "bytes",
511
+ "c2pa_cbor",
514
512
  "chrono",
515
- "ciborium",
516
513
  "config",
517
514
  "console_log",
518
515
  "const-hex",
@@ -566,7 +563,6 @@ dependencies = [
566
563
  "serde-transcode",
567
564
  "serde-wasm-bindgen",
568
565
  "serde_bytes",
569
- "serde_cbor",
570
566
  "serde_derive",
571
567
  "serde_json",
572
568
  "serde_with",
@@ -576,7 +572,7 @@ dependencies = [
576
572
  "static-iref",
577
573
  "tempfile",
578
574
  "thiserror 2.0.17",
579
- "toml 0.9.11+spec-1.1.0",
575
+ "toml 1.0.4+spec-1.1.0",
580
576
  "ureq 3.1.2",
581
577
  "url",
582
578
  "uuid",
@@ -588,8 +584,7 @@ dependencies = [
588
584
  "wstd",
589
585
  "x509-parser",
590
586
  "zeroize",
591
- "zip 6.0.0",
592
- "zip 7.2.0",
587
+ "zip",
593
588
  ]
594
589
 
595
590
  [[package]]
@@ -616,6 +611,17 @@ dependencies = [
616
611
  "trustmark",
617
612
  ]
618
613
 
614
+ [[package]]
615
+ name = "c2pa_cbor"
616
+ version = "0.77.2"
617
+ source = "registry+https://github.com/rust-lang/crates.io-index"
618
+ checksum = "a32d9f47773390b9e3400021ddd9ef7a8d61b8a6501cf72aecd6409d6d447c89"
619
+ dependencies = [
620
+ "half",
621
+ "serde",
622
+ "serde_bytes",
623
+ ]
624
+
619
625
  [[package]]
620
626
  name = "cbc"
621
627
  version = "0.1.2"
@@ -705,7 +711,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
705
711
  checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9"
706
712
  dependencies = [
707
713
  "ciborium-io",
708
- "half 2.6.0",
714
+ "half",
709
715
  ]
710
716
 
711
717
  [[package]]
@@ -984,17 +990,6 @@ dependencies = [
984
990
  "serde",
985
991
  ]
986
992
 
987
- [[package]]
988
- name = "derive_arbitrary"
989
- version = "1.4.1"
990
- source = "registry+https://github.com/rust-lang/crates.io-index"
991
- checksum = "30542c1ad912e0e3d22a1935c290e12e8a29d704a420177a31faad4a601a0800"
992
- dependencies = [
993
- "proc-macro2",
994
- "quote",
995
- "syn 2.0.104",
996
- ]
997
-
998
993
  [[package]]
999
994
  name = "digest"
1000
995
  version = "0.10.7"
@@ -1185,9 +1180,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1185
1180
  checksum = "f83197f59927b46c04a183a619b7c29df34e63e63c7869320862268c0ef687e0"
1186
1181
  dependencies = [
1187
1182
  "bit_field",
1188
- "half 2.6.0",
1183
+ "half",
1189
1184
  "lebe",
1190
- "miniz_oxide",
1185
+ "miniz_oxide 0.8.9",
1191
1186
  "rayon-core",
1192
1187
  "smallvec",
1193
1188
  "zune-inflate",
@@ -1264,7 +1259,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1264
1259
  checksum = "4a3d7db9596fecd151c5f638c0ee5d5bd487b6e0ea232e5dc96d5250f6f94b1d"
1265
1260
  dependencies = [
1266
1261
  "crc32fast",
1267
- "miniz_oxide",
1262
+ "miniz_oxide 0.8.9",
1268
1263
  ]
1269
1264
 
1270
1265
  [[package]]
@@ -1461,12 +1456,6 @@ dependencies = [
1461
1456
  "tracing",
1462
1457
  ]
1463
1458
 
1464
- [[package]]
1465
- name = "half"
1466
- version = "1.8.3"
1467
- source = "registry+https://github.com/rust-lang/crates.io-index"
1468
- checksum = "1b43ede17f21864e81be2fa654110bf1e793774238d86ef8555c37e6519c0403"
1469
-
1470
1459
  [[package]]
1471
1460
  name = "half"
1472
1461
  version = "2.6.0"
@@ -1823,7 +1812,7 @@ checksum = "19734e3c43b2a850f5889c077056e47c874095f2d87e853c7c41214ae67375f0"
1823
1812
  dependencies = [
1824
1813
  "bytes",
1825
1814
  "crc32fast",
1826
- "miniz_oxide",
1815
+ "miniz_oxide 0.8.9",
1827
1816
  ]
1828
1817
 
1829
1818
  [[package]]
@@ -2026,9 +2015,9 @@ checksum = "00810f1d8b74be64b13dbf3db89ac67740615d6c891f0e7b6179326533011a07"
2026
2015
 
2027
2016
  [[package]]
2028
2017
  name = "js-sys"
2029
- version = "0.3.83"
2018
+ version = "0.3.91"
2030
2019
  source = "registry+https://github.com/rust-lang/crates.io-index"
2031
- checksum = "464a3709c7f55f1f721e5389aa6ea4e3bc6aba669353300af094b29ffbdde1d8"
2020
+ checksum = "b49715b7073f385ba4bc528e5747d02e66cb39c6146efb66b781f131f0fb399c"
2032
2021
  dependencies = [
2033
2022
  "once_cell",
2034
2023
  "wasm-bindgen",
@@ -2235,6 +2224,16 @@ dependencies = [
2235
2224
  "simd-adler32",
2236
2225
  ]
2237
2226
 
2227
+ [[package]]
2228
+ name = "miniz_oxide"
2229
+ version = "0.9.0"
2230
+ source = "registry+https://github.com/rust-lang/crates.io-index"
2231
+ checksum = "5faa9f23e86bd5768d76def086192ff5f869fb088da12a976ea21e9796b975f6"
2232
+ dependencies = [
2233
+ "adler2",
2234
+ "simd-adler32",
2235
+ ]
2236
+
2238
2237
  [[package]]
2239
2238
  name = "mio"
2240
2239
  version = "1.0.4"
@@ -2520,7 +2519,7 @@ version = "2.0.0-rc.8"
2520
2519
  source = "registry+https://github.com/rust-lang/crates.io-index"
2521
2520
  checksum = "11826e6118cc42fea0cb2b102f7d006c1bb339cb167f8badb5fb568616438234"
2522
2521
  dependencies = [
2523
- "half 2.6.0",
2522
+ "half",
2524
2523
  "ndarray",
2525
2524
  "ort-sys",
2526
2525
  "tracing",
@@ -2647,9 +2646,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
2647
2646
 
2648
2647
  [[package]]
2649
2648
  name = "pix"
2650
- version = "0.13.4"
2649
+ version = "0.14.0"
2651
2650
  source = "registry+https://github.com/rust-lang/crates.io-index"
2652
- checksum = "b6574ffbea793ab0c9a9b09ae99831f1513fdd7732b12aca4c7182c46dc3bc9f"
2651
+ checksum = "1a054a84d1ff0dc456386e5fc081e099e6855ddcc8913dc9349c294d47d76bd4"
2653
2652
 
2654
2653
  [[package]]
2655
2654
  name = "pkcs1"
@@ -2688,16 +2687,16 @@ dependencies = [
2688
2687
  "crc32fast",
2689
2688
  "fdeflate",
2690
2689
  "flate2",
2691
- "miniz_oxide",
2690
+ "miniz_oxide 0.8.9",
2692
2691
  ]
2693
2692
 
2694
2693
  [[package]]
2695
2694
  name = "png_pong"
2696
- version = "0.9.3"
2695
+ version = "0.10.0"
2697
2696
  source = "registry+https://github.com/rust-lang/crates.io-index"
2698
- checksum = "a767b8b17e388cb7f1e74cf3c2ebce14e6b7ae123fa27150889a353fd9eb981f"
2697
+ checksum = "cb58df2a992d49a178fd69f8c9ead5d4c70014652cd4cca9608a1cb46097aff6"
2699
2698
  dependencies = [
2700
- "miniz_oxide",
2699
+ "miniz_oxide 0.9.0",
2701
2700
  "parsenic",
2702
2701
  "pix",
2703
2702
  "simd-adler32",
@@ -3510,16 +3509,6 @@ dependencies = [
3510
3509
  "serde",
3511
3510
  ]
3512
3511
 
3513
- [[package]]
3514
- name = "serde_cbor"
3515
- version = "0.11.2"
3516
- source = "registry+https://github.com/rust-lang/crates.io-index"
3517
- checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5"
3518
- dependencies = [
3519
- "half 1.8.3",
3520
- "serde",
3521
- ]
3522
-
3523
3512
  [[package]]
3524
3513
  name = "serde_core"
3525
3514
  version = "1.0.228"
@@ -4091,14 +4080,14 @@ dependencies = [
4091
4080
 
4092
4081
  [[package]]
4093
4082
  name = "toml"
4094
- version = "0.9.11+spec-1.1.0"
4083
+ version = "1.0.4+spec-1.1.0"
4095
4084
  source = "registry+https://github.com/rust-lang/crates.io-index"
4096
- checksum = "f3afc9a848309fe1aaffaed6e1546a7a14de1f935dc9d89d32afd9a44bab7c46"
4085
+ checksum = "c94c3321114413476740df133f0d8862c61d87c8d26f04c6841e033c8c80db47"
4097
4086
  dependencies = [
4098
4087
  "indexmap 2.13.0",
4099
4088
  "serde_core",
4100
4089
  "serde_spanned 1.0.4",
4101
- "toml_datetime 0.7.5+spec-1.1.0",
4090
+ "toml_datetime 1.0.0+spec-1.1.0",
4102
4091
  "toml_parser",
4103
4092
  "toml_writer",
4104
4093
  "winnow",
@@ -4115,9 +4104,9 @@ dependencies = [
4115
4104
 
4116
4105
  [[package]]
4117
4106
  name = "toml_datetime"
4118
- version = "0.7.5+spec-1.1.0"
4107
+ version = "1.0.0+spec-1.1.0"
4119
4108
  source = "registry+https://github.com/rust-lang/crates.io-index"
4120
- checksum = "92e1cfed4a3038bc5a127e35a2d360f145e1f4b971b551a2ba5fd7aedf7e1347"
4109
+ checksum = "32c2555c699578a4f59f0cc68e5116c8d7cabbd45e1409b989d4be085b53f13e"
4121
4110
  dependencies = [
4122
4111
  "serde_core",
4123
4112
  ]
@@ -4138,9 +4127,9 @@ dependencies = [
4138
4127
 
4139
4128
  [[package]]
4140
4129
  name = "toml_parser"
4141
- version = "1.0.6+spec-1.1.0"
4130
+ version = "1.0.9+spec-1.1.0"
4142
4131
  source = "registry+https://github.com/rust-lang/crates.io-index"
4143
- checksum = "a3198b4b0a8e11f09dd03e133c0280504d0801269e9afa46362ffde1cbeebf44"
4132
+ checksum = "702d4415e08923e7e1ef96cd5727c0dfed80b4d2fa25db9647fe5eb6f7c5a4c4"
4144
4133
  dependencies = [
4145
4134
  "winnow",
4146
4135
  ]
@@ -4459,9 +4448,9 @@ dependencies = [
4459
4448
 
4460
4449
  [[package]]
4461
4450
  name = "wasm-bindgen"
4462
- version = "0.2.106"
4451
+ version = "0.2.114"
4463
4452
  source = "registry+https://github.com/rust-lang/crates.io-index"
4464
- checksum = "0d759f433fa64a2d763d1340820e46e111a7a5ab75f993d1852d70b03dbb80fd"
4453
+ checksum = "6532f9a5c1ece3798cb1c2cfdba640b9b3ba884f5db45973a6f442510a87d38e"
4465
4454
  dependencies = [
4466
4455
  "cfg-if",
4467
4456
  "once_cell",
@@ -4472,11 +4461,12 @@ dependencies = [
4472
4461
 
4473
4462
  [[package]]
4474
4463
  name = "wasm-bindgen-futures"
4475
- version = "0.4.56"
4464
+ version = "0.4.64"
4476
4465
  source = "registry+https://github.com/rust-lang/crates.io-index"
4477
- checksum = "836d9622d604feee9e5de25ac10e3ea5f2d65b41eac0d9ce72eb5deae707ce7c"
4466
+ checksum = "e9c5522b3a28661442748e09d40924dfb9ca614b21c00d3fd135720e48b67db8"
4478
4467
  dependencies = [
4479
4468
  "cfg-if",
4469
+ "futures-util",
4480
4470
  "js-sys",
4481
4471
  "once_cell",
4482
4472
  "wasm-bindgen",
@@ -4485,9 +4475,9 @@ dependencies = [
4485
4475
 
4486
4476
  [[package]]
4487
4477
  name = "wasm-bindgen-macro"
4488
- version = "0.2.106"
4478
+ version = "0.2.114"
4489
4479
  source = "registry+https://github.com/rust-lang/crates.io-index"
4490
- checksum = "48cb0d2638f8baedbc542ed444afc0644a29166f1595371af4fecf8ce1e7eeb3"
4480
+ checksum = "18a2d50fcf105fb33bb15f00e7a77b772945a2ee45dcf454961fd843e74c18e6"
4491
4481
  dependencies = [
4492
4482
  "quote",
4493
4483
  "wasm-bindgen-macro-support",
@@ -4495,9 +4485,9 @@ dependencies = [
4495
4485
 
4496
4486
  [[package]]
4497
4487
  name = "wasm-bindgen-macro-support"
4498
- version = "0.2.106"
4488
+ version = "0.2.114"
4499
4489
  source = "registry+https://github.com/rust-lang/crates.io-index"
4500
- checksum = "cefb59d5cd5f92d9dcf80e4683949f15ca4b511f4ac0a6e14d4e1ac60c6ecd40"
4490
+ checksum = "03ce4caeaac547cdf713d280eda22a730824dd11e6b8c3ca9e42247b25c631e3"
4501
4491
  dependencies = [
4502
4492
  "bumpalo",
4503
4493
  "proc-macro2",
@@ -4508,18 +4498,18 @@ dependencies = [
4508
4498
 
4509
4499
  [[package]]
4510
4500
  name = "wasm-bindgen-shared"
4511
- version = "0.2.106"
4501
+ version = "0.2.114"
4512
4502
  source = "registry+https://github.com/rust-lang/crates.io-index"
4513
- checksum = "cbc538057e648b67f72a982e708d485b2efa771e1ac05fec311f9f63e5800db4"
4503
+ checksum = "75a326b8c223ee17883a4251907455a2431acc2791c98c26279376490c378c16"
4514
4504
  dependencies = [
4515
4505
  "unicode-ident",
4516
4506
  ]
4517
4507
 
4518
4508
  [[package]]
4519
4509
  name = "web-sys"
4520
- version = "0.3.83"
4510
+ version = "0.3.91"
4521
4511
  source = "registry+https://github.com/rust-lang/crates.io-index"
4522
- checksum = "9b32828d774c412041098d182a8b38b16ea816958e07cf40eec2bc080ae137ac"
4512
+ checksum = "854ba17bb104abfb26ba36da9729addc7ce7f06f5c0f90f3c391f8461cca21f9"
4523
4513
  dependencies = [
4524
4514
  "js-sys",
4525
4515
  "wasm-bindgen",
@@ -5025,21 +5015,9 @@ dependencies = [
5025
5015
 
5026
5016
  [[package]]
5027
5017
  name = "zip"
5028
- version = "6.0.0"
5029
- source = "registry+https://github.com/rust-lang/crates.io-index"
5030
- checksum = "eb2a05c7c36fde6c09b08576c9f7fb4cda705990f73b58fe011abf7dfb24168b"
5031
- dependencies = [
5032
- "arbitrary",
5033
- "crc32fast",
5034
- "indexmap 2.13.0",
5035
- "memchr",
5036
- ]
5037
-
5038
- [[package]]
5039
- name = "zip"
5040
- version = "7.2.0"
5018
+ version = "8.2.0"
5041
5019
  source = "registry+https://github.com/rust-lang/crates.io-index"
5042
- checksum = "c42e33efc22a0650c311c2ef19115ce232583abbe80850bc8b66509ebef02de0"
5020
+ checksum = "b680f2a0cd479b4cff6e1233c483fdead418106eae419dc60200ae9850f6d004"
5043
5021
  dependencies = [
5044
5022
  "crc32fast",
5045
5023
  "indexmap 2.13.0",
package/Cargo.toml CHANGED
@@ -11,7 +11,7 @@ crate-type = ["cdylib"]
11
11
  [dependencies]
12
12
  async-trait = "0.1.77"
13
13
  ciborium = "0.2.2"
14
- c2pa = { version = "0.75.6", default-features = false, features = ["file_io", "pdf", "fetch_remote_manifests", "add_thumbnails", "rust_native_crypto", "default_http"] }
14
+ c2pa = { version = "0.77.0", default-features = false, features = ["file_io", "pdf", "fetch_remote_manifests", "add_thumbnails", "rust_native_crypto", "default_http"] }
15
15
  futures = "0.3"
16
16
  image = "0.25.6"
17
17
  neon = { version = "1.0.0", default-features = false, features = [
package/README.md CHANGED
@@ -116,6 +116,165 @@ await builder.addResource('resource://example', resourceAsset);
116
116
  const manifest = builder.sign(signer, inputAsset, outputAsset);
117
117
  ```
118
118
 
119
+ #### Setting Builder Intent
120
+
121
+ The builder intent describes the type of operation being performed on the asset. This influences how the manifest is structured and what assertions are automatically added.
122
+
123
+ `create`: This is a new digital creation, a DigitalSourceType is required. The Manifest must not have a parent ingredient. A `c2pa.created` action will be added if not provided.
124
+
125
+ `edit`: This is an edit of a pre-existing parent asset. The Manifest must have a parent ingredient. A parent ingredient will be generated from the source stream if not otherwise provided. A `c2pa.opened` action will be tied to the parent ingredient.
126
+
127
+ `update`: A restricted version of Edit for non-editorial changes. There must be only one ingredient, as a parent. No changes can be made to the hashed content of the parent. There are additional restrictions on the types of changes that can be made.
128
+
129
+ ```javascript
130
+ const builder = Builder.new();
131
+
132
+ builder.setIntent({
133
+ create: 'http://cv.iptc.org/newscodes/digitalsourcetype/trainedAlgorithmicMedia',
134
+ });
135
+
136
+ builder.setIntent('edit');
137
+
138
+ builder.setIntent('update');
139
+ ```
140
+
141
+ The `create` intent accepts a `DigitalSourceType` that describes the origin of the asset. Common values include:
142
+
143
+ - `'http://cv.iptc.org/newscodes/digitalsourcetype/trainedAlgorithmicMedia'` - AI-generated content
144
+ - `'http://cv.iptc.org/newscodes/digitalsourcetype/digitalCapture'` - Digital camera capture
145
+ - `'http://cv.iptc.org/newscodes/digitalsourcetype/composite'` - Composite of multiple sources
146
+
147
+ For a complete list of digital source types, see the [C2PA specification](https://c2pa.org/specifications/specifications/2.2/specs/C2PA_Specification.html#_digital_source_type) and [IPTC digital source type vocabulary](https://cv.iptc.org/newscodes/digitalsourcetype).
148
+
149
+ For more details on builder intents, see the [c2pa-rs Builder documentation](https://docs.rs/c2pa/latest/c2pa/struct.Builder.html).
150
+
151
+ #### Adding Ingredients from Assets
152
+
153
+ When you have access to the ingredient asset, use `addIngredient` with an asset to include both the metadata and the asset data:
154
+
155
+ ```javascript
156
+ import * as fs from "node:fs/promises";
157
+
158
+ // Load the ingredient asset
159
+ const ingredientBuffer = await fs.readFile('path/to/source-image.jpg');
160
+
161
+ // Create a builder
162
+ const builder = Builder.new();
163
+
164
+ // Add the ingredient with its asset
165
+ await builder.addIngredient(
166
+ JSON.stringify({
167
+ title: 'source-image.jpg',
168
+ format: 'image/jpeg',
169
+ instance_id: 'ingredient-123',
170
+ relationship: 'parentOf',
171
+ }),
172
+ {
173
+ buffer: ingredientBuffer,
174
+ mimeType: 'image/jpeg',
175
+ }
176
+ );
177
+
178
+ const definition = builder.getManifestDefinition();
179
+ console.log(definition.ingredients); // Contains the ingredient with embedded data
180
+ ```
181
+
182
+ #### Adding Multiple Ingredients
183
+
184
+ You can add multiple ingredients to document complex provenance chains:
185
+
186
+ ```javascript
187
+ const builder = Builder.new();
188
+
189
+ // Load ingredient assets
190
+ const background = await fs.promises.readFile('background.jpg');
191
+ const overlay = await fs.promises.readFile('overlay.png');
192
+
193
+ // Add first ingredient
194
+ await builder.addIngredient(
195
+ JSON.stringify({
196
+ title: 'background.jpg',
197
+ format: 'image/jpeg',
198
+ instance_id: 'background-001',
199
+ relationship: 'componentOf',
200
+ }),
201
+ {
202
+ buffer: background,
203
+ mimeType: 'image/jpeg',
204
+ }
205
+ );
206
+
207
+ // Add second ingredient
208
+ await builder.addIngredient(
209
+ JSON.stringify({
210
+ title: 'overlay.png',
211
+ format: 'image/png',
212
+ instance_id: 'overlay-002',
213
+ relationship: 'componentOf',
214
+ }),
215
+ {
216
+ buffer: overlay,
217
+ mimeType: 'image/png',
218
+ }
219
+ );
220
+
221
+ const definition = builder.getManifestDefinition();
222
+ console.log(definition.ingredients.length); // 2
223
+ ```
224
+
225
+ #### Adding Ingredients from Readers
226
+
227
+ You can also add ingredients directly from a `Reader` object, which automatically includes the C2PA data:
228
+
229
+ ```javascript
230
+ // Read an existing C2PA asset
231
+ const sourceReader = await Reader.fromAsset({
232
+ path: 'source-image.jpg',
233
+ });
234
+
235
+ // Create a builder
236
+ const builder = Builder.new();
237
+
238
+ // Add ingredient from reader
239
+ const ingredient = builder.addIngredientFromReader(sourceReader);
240
+
241
+ console.log(ingredient.title); // Contains ingredient metadata
242
+ ```
243
+
244
+ #### Creating and Reusing Builder Archives
245
+
246
+ Builder archives allow you to save a builder's state (including ingredients) and reuse it later:
247
+
248
+ ```javascript
249
+ // Create a builder with ingredients
250
+ const builder = Builder.new();
251
+
252
+ const ingredientBuffer = await fs.promises.readFile('source.jpg');
253
+ await builder.addIngredient(
254
+ JSON.stringify({
255
+ title: 'source.jpg',
256
+ format: 'image/jpeg',
257
+ instance_id: 'source-123',
258
+ }),
259
+ {
260
+ buffer: ingredientBuffer,
261
+ mimeType: 'image/jpeg',
262
+ }
263
+ );
264
+
265
+ // Save as an archive
266
+ await builder.toArchive({ path: 'builder-archive.zip' });
267
+
268
+ // Later, recreate the builder from the archive
269
+ const restoredBuilder = await Builder.fromArchive({ path: 'builder-archive.zip' });
270
+
271
+ // The ingredients are preserved
272
+ const definition = restoredBuilder.getManifestDefinition();
273
+ console.log(definition.ingredients); // Contains the ingredient
274
+ ```
275
+
276
+ For complete type definitions, see the [@contentauth/c2pa-types](https://www.npmjs.com/package/@contentauth/c2pa-types) package.
277
+
119
278
  ### Signers
120
279
 
121
280
  The library provides several types of signers for different use cases:
@@ -454,6 +454,29 @@ describe("Builder", () => {
454
454
  expect(JSON.stringify(manifestStore)).toContain("Test Ingredient");
455
455
  expect(JSON.stringify(manifestStore)).toContain("thumbnail.ingredient");
456
456
  }));
457
+ it("should add ingredient with custom metadata", () => __awaiter(void 0, void 0, void 0, function* () {
458
+ const builder = Builder.new();
459
+ const ingredient = {
460
+ title: "Test Ingredient",
461
+ format: "image/jpeg",
462
+ instance_id: "ingredient-12345",
463
+ relationship: "componentOf",
464
+ metadata: {
465
+ customString: "my custom value",
466
+ customNumber: 42,
467
+ customBool: true,
468
+ customObject: {
469
+ nested: "value",
470
+ count: 123
471
+ },
472
+ customArray: ["item1", "item2", "item3"]
473
+ }
474
+ };
475
+ yield builder.addIngredient(JSON.stringify(ingredient));
476
+ const definition = builder.getManifestDefinition();
477
+ expect(definition.ingredients).toHaveLength(1);
478
+ expect(definition.ingredients[0]).toMatchObject(ingredient);
479
+ }));
457
480
  it("should perform redaction workflow like test_redaction_async", () => __awaiter(void 0, void 0, void 0, function* () {
458
481
  // This test mirrors the Rust test_redaction_async test
459
482
  // Create a reader to get the parent manifest label from the existing source
package/dist/index.node CHANGED
Binary file
@@ -19,6 +19,9 @@ import type {
19
19
  Manifest,
20
20
  ManifestStore,
21
21
  } from "@contentauth/c2pa-types";
22
+
23
+ export type { Ingredient } from "@contentauth/c2pa-types";
24
+
22
25
  /**
23
26
  * Describes the digital signature algorithms allowed by the C2PA spec
24
27
  *
@@ -59,7 +62,7 @@ export type TrustmarkVariant =
59
62
  // Quality Trustmark model
60
63
  | "Q";
61
64
 
62
- type ManifestAssertionKind = "Cbor" | "Json" | "Binary" | "Uri";
65
+ export type ManifestAssertionKind = "Cbor" | "Json" | "Binary" | "Uri";
63
66
 
64
67
  /**
65
68
  * A buffer for the source asset
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/contentauth/c2pa-node-v2.git"
6
6
  },
7
- "version": "0.5.1",
7
+ "version": "0.5.3",
8
8
  "description": "Node.js bindings for C2PA",
9
9
  "main": "dist/index.js",
10
10
  "type": "module",