@contentauth/c2pa-node 0.1.2 → 0.2.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.
@@ -11,14 +11,9 @@
11
11
  // specific language governing permissions and limitations under
12
12
  // each license.
13
13
 
14
+ // This file contains types not included in @contentauth/c2pa-types and not directly applicable to the neon generated code (index.node.d.ts)
14
15
  import { Buffer } from "buffer";
15
- /**
16
- * Assertions in C2PA can be stored in several formats
17
- */
18
- export type ManifestAssertionKind = "Cbor" | "Json";
19
- export type UriOrResource = ResourceRef | HashedUri;
20
- export type DateT = string;
21
- export type Relationship = "parentOf" | "componentOf" | "inputTo";
16
+ import type { Manifest, ManifestStore } from "@contentauth/c2pa-types";
22
17
  /**
23
18
  * Describes the digital signature algorithms allowed by the C2PA spec
24
19
  *
@@ -35,19 +30,18 @@ export type SigningAlg =
35
30
  | "ps512"
36
31
  | "ed25519";
37
32
 
38
- // A claim_version field is now allowed in a manifest definition for Builder and, if set to 2 will generate v2 claims
39
33
  export type ClaimVersion = 1 | 2;
40
34
 
41
35
  // Trustmark Versions
42
36
  export type TrustmarkVersion =
43
37
  // Tolerates 8 bit flips
44
- | "BchSuper"
38
+ | "BCH_SUPER"
45
39
  // Tolerates 5 bit flips
46
- | "Bch5"
40
+ | "BCH_5"
47
41
  // Tolerates 4 bit flips
48
- | "Bch4"
42
+ | "BCH_4"
49
43
  // Tolerates 3 bit flips
50
- | "Bch3";
44
+ | "BCH_3";
51
45
 
52
46
  // Trustmark Variants. See https://github.com/adobe/trustmark/blob/main/FAQ.md for more
53
47
  export type TrustmarkVariant =
@@ -60,422 +54,7 @@ export type TrustmarkVariant =
60
54
  // Quality Trustmark model
61
55
  | "Q";
62
56
 
63
- /**
64
- * A Container for a set of Manifests and a ValidationStatus list
65
- */
66
- export interface ManifestStore {
67
- /**
68
- * A label for the active (most recent) manifest in the store
69
- */
70
- active_manifest?: string | undefined;
71
- /**
72
- * A HashMap of Manifests
73
- */
74
- manifests: {
75
- [k: string]: Manifest;
76
- };
77
- /**
78
- * ValidationStatus generated when loading the ManifestStore from an asset
79
- */
80
- validation_status?: ValidationStatus[] | undefined;
81
- [k: string]: unknown;
82
- }
83
-
84
- /**
85
- * A Manifest represents all the information in a c2pa manifest
86
- */
87
- export interface Manifest {
88
- /**
89
- * A list of assertions
90
- */
91
- assertions?: ManifestAssertion[];
92
- /**
93
- * A User Agent formatted string identifying the software/hardware/system produced this claim Spaces are not allowed in names, versions can be specified with product/1.0 syntax
94
- */
95
- claim_generator?: string;
96
- claim_generator_hints?:
97
- | {
98
- [k: string]: unknown;
99
- }
100
- | undefined;
101
- /**
102
- * A list of claim generator info data identifying the software/hardware/system produced this claim
103
- */
104
- claim_generator_info?: ClaimGeneratorInfo[] | undefined;
105
- /**
106
- * A List of verified credentials
107
- */
108
- credentials?: unknown[] | undefined;
109
- /**
110
- * The format of the source file as a MIME type
111
- */
112
- format?: string;
113
- /**
114
- * A List of ingredients
115
- */
116
- ingredients?: Ingredient[];
117
- /**
118
- * Instance ID from `xmpMM:InstanceID` in XMP metadata
119
- */
120
- instance_id?: string;
121
- label?: string | undefined;
122
- /**
123
- * A list of redactions - URIs to a redacted assertions
124
- */
125
- redactions?: string[] | undefined;
126
- /**
127
- * container for binary assets (like thumbnails)
128
- */
129
- resources?: ResourceStore;
130
- /**
131
- * Signature data (only used for reporting)
132
- */
133
- signature_info?: SignatureInfo | undefined;
134
- thumbnail?: ResourceRef | undefined;
135
- /**
136
- * A human-readable title, generally source filename
137
- */
138
- title?: string | undefined;
139
- /**
140
- * Optional prefix added to the generated Manifest Label This is typically Internet domain name for the vendor (i.e. `adobe`)
141
- */
142
- vendor?: string | undefined;
143
- [k: string]: unknown;
144
- }
145
-
146
- /**
147
- * A labeled container for an Assertion value in a Manifest
148
- */
149
- export interface ManifestAssertion {
150
- data: unknown;
151
- /**
152
- * There can be more than one assertion for any label
153
- */
154
- instance?: number | undefined;
155
- /**
156
- * The [ManifestAssertionKind] for this assertion (as stored in c2pa content)
157
- */
158
- kind?: ManifestAssertionKind | undefined;
159
- /**
160
- * An assertion label in reverse domain format
161
- */
162
- label: string;
163
- [k: string]: unknown;
164
- }
165
-
166
- /**
167
- * Description of the claim generator, or the software used in generating the claim
168
- *
169
- * This structure is also used for actions softwareAgent
170
- */
171
- export interface ClaimGeneratorInfo {
172
- /**
173
- * hashed URI to the icon (either embedded or remote)
174
- */
175
- icon?: UriOrResource | undefined;
176
- /**
177
- * A human readable string naming the claim_generator
178
- */
179
- name: string;
180
- /**
181
- * A human readable string of the product's version
182
- */
183
- version?: string | undefined;
184
- [k: string]: unknown;
185
- }
186
-
187
- /**
188
- * A reference to a resource to be used in JSON serialization
189
- */
190
- export interface ResourceRef {
191
- /**
192
- * The algorithm used to hash the resource (if applicable)
193
- */
194
- alg?: string | undefined;
195
- /**
196
- * More detailed data types as defined in the C2PA spec
197
- */
198
- data_types?: AssetType[] | undefined;
199
- /**
200
- * The mime type of the referenced resource
201
- */
202
- format: string;
203
- /**
204
- * The hash of the resource (if applicable)
205
- */
206
- hash?: string | undefined;
207
- /**
208
- * A URI that identifies the resource as referenced from the manifest
209
- *
210
- * This may be a JUMBF URI, a file path, a URL or any other string. Relative JUMBF URIs will be resolved with the manifest label. Relative file paths will be resolved with the base path if provided
211
- */
212
- identifier: string;
213
- [k: string]: unknown;
214
- }
215
-
216
- export interface AssetType {
217
- type: string;
218
- version?: string | undefined;
219
- [k: string]: unknown;
220
- }
221
-
222
- /**
223
- * Hashed Uri structure as defined by C2PA spec It is annotated to produce the correctly tagged cbor serialization
224
- */
225
- export interface HashedUri {
226
- alg?: string | undefined;
227
- hash: number[];
228
- url: string;
229
- [k: string]: unknown;
230
- }
231
-
232
- /**
233
- * An `Ingredient` is any external asset that has been used in the creation of an image
234
- */
235
- export interface Ingredient {
236
- /**
237
- * The active manifest label (if one exists)
238
- *
239
- * If this ingredient has a [`ManifestStore`], this will hold the label of the active [`Manifest`]
240
- *
241
- * [`Manifest`]: crate::Manifest [`ManifestStore`]: crate::ManifestStore
242
- */
243
- active_manifest?: string | undefined;
244
- /**
245
- * A reference to the actual data of the ingredient
246
- */
247
- data?: ResourceRef | undefined;
248
- /**
249
- * Additional description of the ingredient
250
- */
251
- description?: string | undefined;
252
- /**
253
- * Document ID from `xmpMM:DocumentID` in XMP metadata
254
- */
255
- document_id?: string | undefined;
256
- /**
257
- * The format of the source file as a MIME type
258
- */
259
- format?: string;
260
- /**
261
- * An optional hash of the asset to prevent duplicates
262
- */
263
- hash?: string | undefined;
264
- /**
265
- * URI to an informational page about the ingredient or its data
266
- */
267
- informational_URI?: string | undefined;
268
- /**
269
- * Instance ID from `xmpMM:InstanceID` in XMP metadata
270
- */
271
- instance_id?: string | undefined;
272
- /**
273
- * A [`ManifestStore`] from the source asset extracted as a binary C2PA blob
274
- *
275
- * [`ManifestStore`]: crate::ManifestStore
276
- */
277
- manifest_data?: ResourceRef | undefined;
278
- /**
279
- * Any additional [`Metadata`] as defined in the C2PA spec
280
- *
281
- * [`Manifest`]: crate::Manifest
282
- */
283
- metadata?: Metadata | undefined;
284
- /**
285
- * URI from `dcterms:provenance` in XMP metadata
286
- */
287
- provenance?: string | undefined;
288
- /**
289
- * Set to `ParentOf` if this is the parent ingredient
290
- *
291
- * There can only be one parent ingredient in the ingredients
292
- */
293
- relationship?: Relationship & string;
294
- resources?: ResourceStore;
295
- /**
296
- * A thumbnail image capturing the visual state at the time of import
297
- *
298
- * A tuple of thumbnail MIME format (i.e. `image/jpeg`) and binary bits of the image
299
- */
300
- thumbnail?: ResourceRef | undefined;
301
- /**
302
- * A human-readable title, generally source filename
303
- */
304
- title: string;
305
- /**
306
- * Validation results
307
- */
308
- validation_status?: ValidationStatus[] | undefined;
309
- [k: string]: unknown;
310
- }
311
-
312
- /**
313
- * The Metadata structure can be used as part of other assertions or on its own to reference others
314
- */
315
- export interface Metadata {
316
- data_source?: DataSource | undefined;
317
- dateTime?: DateT | undefined;
318
- reference?: HashedUri | undefined;
319
- reviewRatings?: ReviewRating[] | undefined;
320
- [k: string]: unknown;
321
- }
322
-
323
- /**
324
- * A description of the source for assertion data
325
- */
326
- export interface DataSource {
327
- /**
328
- * A list of [`Actor`]s associated with this source
329
- */
330
- actors?: Actor[] | undefined;
331
- /**
332
- * A human-readable string giving details about the source of the assertion data
333
- */
334
- details?: string | undefined;
335
- /**
336
- * A value from among the enumerated list indicating the source of the assertion
337
- */
338
- type: string;
339
- [k: string]: unknown;
340
- }
341
-
342
- /**
343
- * Identifies a person responsible for an action
344
- */
345
- export interface Actor {
346
- /**
347
- * List of references to W3C Verifiable Credentials
348
- */
349
- credentials?: HashedUri[] | undefined;
350
- /**
351
- * An identifier for a human actor, used when the "type" is `humanEntry.identified`
352
- */
353
- identifier?: string | undefined;
354
- [k: string]: unknown;
355
- }
356
-
357
- /**
358
- * A rating on an Assertion
359
- *
360
- * See <https://c2pa.org/specifications/specifications/1.0/specs/C2PA_Specification.html#_claim_review>
361
- */
362
- export interface ReviewRating {
363
- code?: string | undefined;
364
- explanation: string;
365
- value: number;
366
- [k: string]: unknown;
367
- }
368
-
369
- /**
370
- * Resource store to contain binary objects referenced from JSON serializable structures
371
- */
372
- export interface ResourceStore {
373
- label?: string | undefined;
374
- resources: {
375
- [k: string]: number[];
376
- };
377
- [k: string]: unknown;
378
- }
379
-
380
- /**
381
- * A `ValidationStatus` struct describes the validation status of a specific part of a manifest
382
- *
383
- * See <https://c2pa.org/specifications/specifications/1.0/specs/C2PA_Specification.html#_existing_manifests>
384
- */
385
- export interface ValidationStatus {
386
- code: string;
387
- explanation?: string | undefined;
388
- url?: string | undefined;
389
- [k: string]: unknown;
390
- }
391
-
392
- /**
393
- * Holds information about a signature
394
- */
395
- export interface SignatureInfo {
396
- /**
397
- * human readable issuing authority for this signature
398
- */
399
- alg?: SigningAlg | undefined;
400
- /**
401
- * The serial number of the certificate
402
- */
403
- cert_serial_number?: string | undefined;
404
- /**
405
- * human readable issuing authority for this signature
406
- */
407
- issuer?: string | undefined;
408
- /**
409
- * revocation status of the certificate
410
- */
411
- revocation_status?: boolean | undefined;
412
- /**
413
- * the time the signature was created
414
- */
415
- time?: string | undefined;
416
- [k: string]: unknown;
417
- }
418
-
419
- /**
420
- * From ManifestDefinition.d.ts
421
- * A Manifest Definition This is used to define a manifest and is used to build a ManifestStore A Manifest is a collection of ingredients and assertions It is used to define a claim that can be signed and embedded into a file
422
- */
423
- export interface ManifestDefinition {
424
- /**
425
- * A list of assertions
426
- */
427
- assertions?: AssertionDefinition[];
428
- /**
429
- * Clam Generator Info is always required with at least one entry
430
- */
431
- claim_generator_info?: ClaimGeneratorInfo[];
432
- /**
433
- * The format of the source file as a MIME type
434
- */
435
- format?: string;
436
- /**
437
- * A List of ingredients
438
- */
439
- ingredients?: Ingredient[];
440
- /**
441
- * Instance ID from `xmpMM:InstanceID` in XMP metadata
442
- */
443
- instance_id?: string;
444
- label?: string | undefined;
445
- /**
446
- * A list of redactions - URIs to a redacted assertions
447
- */
448
- redactions?: string[] | undefined;
449
- thumbnail?: ResourceRef | undefined;
450
- /**
451
- * A human-readable title, generally source filename
452
- */
453
- title?: string | undefined;
454
- /**
455
- * Optional prefix added to the generated Manifest Label This is typically Internet domain name for the vendor (i.e. `adobe`)
456
- */
457
- vendor?: string | undefined;
458
- [k: string]: unknown;
459
- }
460
-
461
- export interface AssertionDefinition {
462
- data: unknown;
463
- label: string;
464
- [k: string]: unknown;
465
- }
466
-
467
- /**
468
- * Types unique to index.node
469
- */
470
- export interface IngredientThumbnail {
471
- format: string;
472
- data: Uint8Array;
473
- }
474
-
475
- export interface IngredientOptions {
476
- isParent: boolean;
477
- thumbnail?: IngredientThumbnail;
478
- }
57
+ type ManifestAssertionKind = "Cbor" | "Json" | "Binary" | "Uri";
479
58
 
480
59
  /**
481
60
  * A buffer for the source asset
@@ -521,25 +100,32 @@ export type DestinationAsset = DestinationBufferAsset | FileAsset;
521
100
  /**
522
101
  * A signer that uses a local certificate and private key to sign data
523
102
  */
524
- export interface LocalSigner {
103
+ export interface LocalSignerInterface {
525
104
  sign(data: Buffer): Buffer;
526
105
  alg(): SigningAlg;
527
106
  certs(): Array<Buffer>;
528
107
  reserveSize(): number;
529
108
  timeAuthorityUrl(): string | undefined;
530
- signer(): LocalSigner;
109
+ signer(): NeonLocalSignerHandle;
531
110
  }
532
111
 
533
112
  /**
534
113
  * A signer that uses a callback to sign data.
535
114
  */
536
- export interface CallbackSigner {
115
+ export interface CallbackSignerInterface {
537
116
  sign(data: Buffer): Promise<Buffer>;
538
117
  alg(): SigningAlg;
539
118
  certs(): Array<Buffer>;
540
119
  reserveSize(): number;
541
120
  timeAuthorityUrl(): string | undefined;
542
- signer(): CallbackSigner;
121
+ signer(): NeonCallbackSignerHandle;
122
+ }
123
+
124
+ export interface CallbackCredentialHolderInterface {
125
+ sigType(): string;
126
+ reserveSize(): number;
127
+ sign(payload: SignerPayload): Promise<Buffer>;
128
+ signer(): NeonCallbackCredentialHolderHandle;
543
129
  }
544
130
 
545
131
  /**
@@ -547,6 +133,14 @@ export interface CallbackSigner {
547
133
  * Internal type used for Rust/Node.js interop
548
134
  */
549
135
  export type CallbackSignerConfig = unknown;
136
+ export type NeonCallbackSignerHandle = unknown;
137
+ export type NeonCallbackCredentialHolderHandle = unknown;
138
+ export type NeonLocalSignerHandle = unknown;
139
+ export type NeonBuilderHandle = unknown;
140
+ export type NeonReaderHandle = unknown;
141
+ export type NeonIdentityAssertionSignerHandle = unknown;
142
+ export type NeonIdentityAssertionBuilderHandle = unknown;
143
+ export type NeonTrustmarkHandle = unknown;
550
144
 
551
145
  /*
552
146
  * Configuration for an asynchronous signer.
@@ -554,14 +148,31 @@ export type CallbackSignerConfig = unknown;
554
148
  */
555
149
  export interface JsCallbackSignerConfig {
556
150
  alg: SigningAlg;
557
- certs: Buffer[];
151
+ certs?: Buffer[];
558
152
  reserveSize: number;
559
153
  tsaUrl?: string;
560
154
  tsaHeaders?: Array<[string, string]>;
561
155
  tsaBody?: Buffer;
156
+ // TODO: directCoseHandling is currently not implemented in the signing logic.
157
+ // The field is read from config but the actual signing implementation does not
158
+ // differentiate between directCoseHandling: true/false - both cases pass the
159
+ // same data to the JavaScript callback regardless of this setting.
160
+ directCoseHandling: boolean;
161
+ }
162
+
163
+ export interface SignerPayload {
164
+ referencedAssertions: HashedUri[];
165
+ sigType: string;
166
+ roles: string[];
167
+ }
168
+
169
+ export interface HashedUri {
170
+ url: string;
171
+ hash: Uint8Array;
172
+ alg?: string;
562
173
  }
563
174
 
564
- export interface Builder {
175
+ export interface BuilderInterface {
565
176
  /**
566
177
  * Set the no embed flag of the manifest
567
178
  * @param noEmbed The no embed flag of the manifest
@@ -575,11 +186,12 @@ export interface Builder {
575
186
  /**
576
187
  * Add CBOR assertion to the builder
577
188
  * @param label The label of the assertion
578
- * @param assertion The CBOR encoded assertion
189
+ * @param assertion The assertion, should be a string if the type is JSON, otherwise a JS Object
190
+ * @param assertionKind The type of assertion
579
191
  */
580
192
  addAssertion(
581
193
  label: string,
582
- assertion: string,
194
+ assertion: unknown,
583
195
  assertionKind?: ManifestAssertionKind,
584
196
  ): void;
585
197
  /**
@@ -594,10 +206,7 @@ export interface Builder {
594
206
  * @param ingredientJson The JSON representation of the ingredient
595
207
  * @param ingredient The source and format of the ingredient
596
208
  */
597
- addIngredient(
598
- ingredientJson: string,
599
- ingredient: SourceAsset,
600
- ): Promise<void>;
209
+ addIngredient(ingredientJson: string, ingredient: SourceAsset): Promise<void>;
601
210
 
602
211
  /**
603
212
  * Convert the Builder into a archive formatted buffer or file
@@ -613,7 +222,7 @@ export interface Builder {
613
222
  * @returns the bytes of the c2pa_manifest that was embedded
614
223
  */
615
224
  sign(
616
- signer: LocalSigner,
225
+ signer: LocalSignerInterface,
617
226
  input: SourceAsset,
618
227
  output: DestinationAsset,
619
228
  ): Buffer;
@@ -643,7 +252,7 @@ export interface Builder {
643
252
  * @returns the bytes of the c2pa_manifest that was embedded
644
253
  */
645
254
  signAsync(
646
- callbackSigner: CallbackSigner,
255
+ callbackSigner: CallbackSignerInterface | IdentityAssertionSignerInterface,
647
256
  input: SourceAsset,
648
257
  output: DestinationAsset,
649
258
  ): Promise<Buffer>;
@@ -656,42 +265,25 @@ export interface Builder {
656
265
  * @returns the bytes of the c2pa_manifest that was embedded
657
266
  */
658
267
  signFile(
659
- signer: LocalSigner,
268
+ signer: LocalSignerInterface,
660
269
  filePath: string,
661
270
  output: DestinationAsset,
662
271
  ): Buffer;
663
272
 
664
- /**
665
- * Sign an asset from a buffer or file asynchronously, using an
666
- * IdentityAssertionSigner
667
- * @param signer The IdentityAssertionSigner
668
- * @param source The file or buffer containing the asset
669
- * @param dest The file or buffer to write the asset to
670
- * @returns the bytes of the c2pa_manifest that was embedded
671
- */
672
- identitySignAsync(
673
- callbackSigner: IdentityAssertionSigner,
674
- input: SourceAsset,
675
- output: DestinationAsset,
676
- ): Promise<Buffer>;
677
-
678
273
  /**
679
274
  * Getter for the builder's manifest definition
680
275
  * @returns The manifest definition
681
276
  */
682
- getManifestDefinition(): ManifestDefinition;
277
+ getManifestDefinition(): Manifest;
683
278
 
684
279
  /**
685
280
  * Update a string property of the manifest
686
281
  * @returns The manifest definition
687
282
  */
688
- updateManifestProperty(
689
- property: string,
690
- value: string | ClaimVersion,
691
- ): void;
283
+ updateManifestProperty(property: string, value: string | ClaimVersion): void;
692
284
  }
693
285
 
694
- export interface Reader {
286
+ export interface ReaderInterface {
695
287
  /**
696
288
  * Get the JSON representation of the manifest
697
289
  */
@@ -720,7 +312,7 @@ export interface Reader {
720
312
  postValidateCawg(): Promise<void>;
721
313
  }
722
314
 
723
- export interface IdentityAssertionSigner {
315
+ export interface IdentityAssertionSignerInterface {
724
316
  /** Add a IdentityAssertionBuilder to be used when signing the
725
317
  * next Manifest
726
318
  *
@@ -728,11 +320,13 @@ export interface IdentityAssertionSigner {
728
320
  * IdentityAssertionBuilders will be cleared.
729
321
  */
730
322
  addIdentityAssertion(
731
- identityAssertionBuilder: IdentityAssertionBuilder,
323
+ identityAssertionBuilder: IdentityAssertionBuilderInterface,
732
324
  ): void;
325
+
326
+ signer(): NeonIdentityAssertionSignerHandle;
733
327
  }
734
328
 
735
- export interface IdentityAssertionBuilder {
329
+ export interface IdentityAssertionBuilderInterface {
736
330
  /**
737
331
  * Add assertion labels to consider as referenced_assertions.
738
332
  * If any of these labels match assertions that are present in the partial
@@ -750,10 +344,10 @@ export interface IdentityAssertionBuilder {
750
344
  /**
751
345
  * Get the underlying IdentityAssertionBuilder
752
346
  */
753
- builder(): IdentityAssertionBuilder;
347
+ builder(): NeonIdentityAssertionBuilderHandle;
754
348
  }
755
349
 
756
- export interface Trustmark {
350
+ export interface TrustmarkInterface {
757
351
  /**
758
352
  * Encode a watermark into an image.
759
353
  * @param image image to be watermarked
@@ -761,11 +355,7 @@ export interface Trustmark {
761
355
  * @param watermark optional bitstring to be encoded, automatically generated if not provided
762
356
  * @returns raw pixel data in RGB8 format (width * height * 3 bytes)
763
357
  */
764
- encode(
765
- image: Buffer,
766
- strength: number,
767
- watermark?: string,
768
- ): Promise<Buffer>;
358
+ encode(image: Buffer, strength: number, watermark?: string): Promise<Buffer>;
769
359
 
770
360
  /**
771
361
  * Decode a watermark from an image.
@@ -780,114 +370,44 @@ export interface TrustmarkConfig {
780
370
  modelPath?: string;
781
371
  }
782
372
 
783
- // Builder methods
784
- export function builderNew(): Builder;
785
- export function builderWithJson(json: string): Builder;
786
- export function builderSetNoEmbed(noEmbed: boolean): void;
787
- export function builderSetRemoteUrl(url: string): void;
788
- export function builderAddAssertion(
789
- label: string,
790
- assertion: string,
791
- assertionKind?: ManifestAssertionKind,
792
- ): void;
793
- export function builderAddResource(
794
- uri: string,
795
- resource: SourceAsset,
796
- ): Promise<void>;
797
- export function builderAddIngredient(
798
- ingredientJson: string,
799
- resource: SourceAsset,
800
- ): Promise<void>;
801
- export function builderToArchive(asset: DestinationAsset): Promise<void>;
802
- export function builderFromArchive(asset: SourceAsset): Promise<Builder>;
803
- export function builderSign(
804
- signer: LocalSigner,
805
- input: SourceAsset,
806
- output: DestinationAsset,
807
- ): Buffer;
808
- export function builderSignConfigAsync(
809
- callback: (data: Buffer) => Promise<Buffer>,
810
- signerConfig: JsCallbackSignerConfig,
811
- input: SourceAsset,
812
- output: DestinationAsset,
813
- ): Promise<Buffer | { manifest: Buffer; signedAsset: Buffer }>;
814
- export function builderSignAsync(
815
- signer: CallbackSigner,
816
- input: SourceAsset,
817
- output: DestinationAsset,
818
- ): Promise<Buffer | { manifest: Buffer; signedAsset: Buffer }>;
819
- export function builderIdentitySignAsync(
820
- signer: IdentityAssertionSigner,
821
- input: SourceAsset,
822
- output: DestinationAsset,
823
- ): Promise<Buffer | { manifest: Buffer; signedAsset: Buffer }>;
824
- export function builderManifestDefinition(): string;
825
- export function builderUpdateManifestProperty(
826
- property: string,
827
- value: string | ClaimVersion,
828
- ): void;
829
-
830
- // Reader methods
831
- export function readerFromAsset(asset: SourceAsset): Promise<Reader>;
832
- export function readerFromManifestDataAndAsset(
833
- manifestData: Buffer,
834
- asset: SourceAsset,
835
- ): Promise<Reader>;
836
- export function readerJson(): string;
837
- export function readerRemoteUrl(): string;
838
- export function readerIsEmbedded(): boolean;
839
- export function readerResourceToAsset(
840
- uri: string,
841
- output: DestinationAsset,
842
- ): Promise<number>;
843
- export function readerPostValidateCawg(): Promise<void>;
844
-
845
- // Signers
846
- export function localSignerNew(
847
- signcert: Buffer,
848
- pkey: Buffer,
849
- signingAlg: SigningAlg,
850
- tsaUrl?: string,
851
- ): LocalSigner;
852
- export function localSignerSign(data: Buffer): Buffer;
853
- export function localSignerAlg(): SigningAlg;
854
- export function localSignerCerts(): Array<Buffer>;
855
- export function localSignerReserveSize(): number;
856
- export function localSignerTimeAuthorityUrl(): string | undefined;
857
-
858
- export function callbackSignerFromConfig(
859
- config: CallbackSignerConfig,
860
- callback: (data: Buffer) => Promise<Buffer>,
861
- ): CallbackSigner;
862
- export function callbackSignerConfigFromJs(
863
- config: JsCallbackSignerConfig,
864
- ): CallbackSignerConfig;
865
- export function callbackSignerSign(data: Buffer): Promise<Buffer>;
866
- export function callbackSignerAlg(): SigningAlg;
867
- export function callbackSignerCerts(): Array<Buffer>;
868
- export function callbackSignerReserveSize(): number;
869
- export function callbackSignerTimeAuthorityUrl(): string | undefined;
870
-
871
- // CAWG Identity
872
- export function identitySignerNew(
873
- signer: CallbackSigner,
874
- ): IdentityAssertionSigner;
875
- export function identitySignerAddIdentityAssertion(
876
- identityAssertionBuilder: IdentityAssertionBuilder,
877
- ): void;
878
- export function identityBuilderForCredentialHolder(
879
- credentialHolder: CallbackSigner,
880
- ): IdentityAssertionBuilder;
881
- export function identityBuilderAddReferencedAssertions(
882
- referenced_assertions: Array<string>,
883
- ): void;
884
- export function identityBuilderAddRoles(roles: Array<string>): void;
885
-
886
- // Trustmark
887
- export function trustmarkNew(config: TrustmarkConfig): Promise<Trustmark>;
888
- export function trustmarkEncode(
889
- image: Buffer,
890
- strength: number,
891
- watermark?: string,
892
- ): Promise<Buffer>;
893
- export function trustmarkDecode(image: Buffer): Promise<string>;
373
+ /**
374
+ * Configuration for trust settings in C2PA.
375
+ * Controls certificate trust validation and trust anchor management.
376
+ */
377
+ export interface TrustConfig {
378
+ /** Whether to verify against the trust list */
379
+ verifyTrustList: boolean;
380
+ /** User-provided trust anchors (PEM format or base64-encoded certificate hashes) */
381
+ userAnchors?: string;
382
+ /** Trust anchors for validation (PEM format or base64-encoded certificate hashes) */
383
+ trustAnchors?: string;
384
+ /** Trust configuration file path */
385
+ trustConfig?: string;
386
+ /** Allowed list of certificates (PEM format or base64-encoded certificate hashes) */
387
+ allowedList?: string;
388
+ }
389
+
390
+ /**
391
+ * Configuration for verification settings in C2PA.
392
+ * Controls various verification behaviors and options.
393
+ */
394
+ export interface VerifyConfig {
395
+ /** Whether to verify after reading a manifest */
396
+ verifyAfterReading: boolean;
397
+ /** Whether to verify after signing a manifest */
398
+ verifyAfterSign: boolean;
399
+ /** Whether to verify trust during validation */
400
+ verifyTrust: boolean;
401
+ /** Whether to verify timestamp trust */
402
+ verifyTimestampTrust: boolean;
403
+ /** Whether to fetch OCSP responses */
404
+ ocspFetch: boolean;
405
+ /** Whether to fetch remote manifests */
406
+ remoteManifestFetch: boolean;
407
+ /** Whether to check ingredient trust */
408
+ checkIngredientTrust: boolean;
409
+ /** Whether to skip ingredient conflict resolution */
410
+ skipIngredientConflictResolution: boolean;
411
+ /** Whether to use strict v1 validation */
412
+ strictV1Validation: boolean;
413
+ }