@contentauth/c2pa-node 0.1.0 → 0.1.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.
@@ -0,0 +1,771 @@
1
+ // Copyright 2024 Adobe. All rights reserved.
2
+ // This file is licensed to you under the Apache License,
3
+ // Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
4
+ // or the MIT license (http://opensource.org/licenses/MIT),
5
+ // at your option.
6
+
7
+ // Unless required by applicable law or agreed to in writing,
8
+ // this software is distributed on an "AS IS" BASIS, WITHOUT
9
+ // WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or
10
+ // implied. See the LICENSE-MIT and LICENSE-APACHE files for the
11
+ // specific language governing permissions and limitations under
12
+ // each license.
13
+
14
+ 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";
22
+ /**
23
+ * Describes the digital signature algorithms allowed by the C2PA spec
24
+ *
25
+ * Per <https://c2pa.org/specifications/specifications/1.0/specs/C2PA_Specification.html#_digital_signatures>:
26
+ *
27
+ * > All digital signatures that are stored in a C2PA Manifest shall > be generated using one of the digital signature algorithms and > key types listed as described in this section
28
+ */
29
+ export type SigningAlg =
30
+ | "es256"
31
+ | "es384"
32
+ | "es512"
33
+ | "ps256"
34
+ | "ps384"
35
+ | "ps512"
36
+ | "ed25519";
37
+
38
+ // A claim_version field is now allowed in a manifest definition for Builder and, if set to 2 will generate v2 claims
39
+ export type ClaimVersion = 1 | 2;
40
+
41
+ // Trustmark Versions
42
+ export type TrustmarkVersion =
43
+ // Tolerates 8 bit flips
44
+ | "BchSuper"
45
+ // Tolerates 5 bit flips
46
+ | "Bch5"
47
+ // Tolerates 4 bit flips
48
+ | "Bch4"
49
+ // Tolerates 3 bit flips
50
+ | "Bch3";
51
+
52
+ // Trustmark Variants. See https://github.com/adobe/trustmark/blob/main/FAQ.md for more
53
+ export type TrustmarkVariant =
54
+ // Original Trustmark model
55
+ | "B"
56
+ // Compact Trustmark model
57
+ | "C"
58
+ // Perceptual model
59
+ | "P"
60
+ // Quality Trustmark model
61
+ | "Q";
62
+
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
+ }
479
+
480
+ /**
481
+ * A buffer for the source asset
482
+ */
483
+ export interface SourceBufferAsset {
484
+ // A buffer containing the asset data
485
+ buffer: Buffer;
486
+ // The MIME type of the asset, for instance `image/jpeg`
487
+ mimeType: string;
488
+ }
489
+
490
+ /**
491
+ * A buffer for the destination asset
492
+ */
493
+ export interface DestinationBufferAsset {
494
+ // An initially empty buffer that will be filled with the signed asset
495
+ buffer: Buffer | null;
496
+ }
497
+
498
+ /**
499
+ * A file that can be used either the source or destination
500
+ */
501
+ export interface FileAsset {
502
+ // The path to the asset
503
+ path: string;
504
+ // The optional MIME type of the asset, for instance `image/jpeg`.
505
+ // If not supplied, the MIME type will be inferred from the file extension, if available.
506
+ mimeType?: string;
507
+ }
508
+
509
+ /**
510
+ * A source asset that can either be in memory or on disk
511
+ * This is a workaround since Neon does not support streams
512
+ */
513
+ export type SourceAsset = SourceBufferAsset | FileAsset;
514
+
515
+ /**
516
+ * An destination asset that can either be in memory or on disk
517
+ * This is a workaround since Neon does not support streams
518
+ */
519
+ export type DestinationAsset = DestinationBufferAsset | FileAsset;
520
+
521
+ /**
522
+ * A signer that uses a local certificate and private key to sign data
523
+ */
524
+ export interface LocalSignerInterface {
525
+ sign(data: Buffer): Buffer;
526
+ alg(): SigningAlg;
527
+ certs(): Array<Buffer>;
528
+ reserveSize(): number;
529
+ timeAuthorityUrl(): string | undefined;
530
+ signer(): LocalSignerInterface;
531
+ }
532
+
533
+ /**
534
+ * A signer that uses a callback to sign data.
535
+ */
536
+ export interface CallbackSignerInterface {
537
+ sign(data: Buffer): Promise<Buffer>;
538
+ alg(): SigningAlg;
539
+ certs(): Array<Buffer>;
540
+ reserveSize(): number;
541
+ timeAuthorityUrl(): string | undefined;
542
+ signer(): CallbackSignerInterface;
543
+ }
544
+
545
+ /**
546
+ * @internal
547
+ * Internal type used for Rust/Node.js interop
548
+ */
549
+ export type CallbackSignerConfig = unknown;
550
+
551
+ /*
552
+ * Configuration for an asynchronous signer.
553
+ * This allows signing without passing a private key.
554
+ */
555
+ export interface JsCallbackSignerConfig {
556
+ alg: SigningAlg;
557
+ certs: Buffer[];
558
+ reserveSize: number;
559
+ tsaUrl?: string;
560
+ tsaHeaders?: Array<[string, string]>;
561
+ tsaBody?: Buffer;
562
+ }
563
+
564
+ export interface BuilderInterface {
565
+ /**
566
+ * Set the no embed flag of the manifest
567
+ * @param noEmbed The no embed flag of the manifest
568
+ */
569
+ setNoEmbed(noEmbed: boolean): void;
570
+ /**
571
+ * Set the remote URL of the manifest
572
+ * @param url The remote URL of the manifest
573
+ */
574
+ setRemoteUrl(url: string): void;
575
+ /**
576
+ * Add CBOR assertion to the builder
577
+ * @param label The label of the assertion
578
+ * @param assertion The CBOR encoded assertion
579
+ */
580
+ addAssertion(
581
+ label: string,
582
+ assertion: string,
583
+ assertionKind?: ManifestAssertionKind,
584
+ ): void;
585
+ /**
586
+ * Add a resource from a buffer or file
587
+ * @param uri The URI of the resource
588
+ * @param resource The source and format of the resource
589
+ */
590
+ addResource(uri: string, resource: SourceAsset): Promise<void>;
591
+
592
+ /**
593
+ * Add an ingredient from a buffer or file
594
+ * @param ingredientJson The JSON representation of the ingredient
595
+ * @param ingredient The source and format of the ingredient
596
+ */
597
+ addIngredient(ingredientJson: string, ingredient: SourceAsset): Promise<void>;
598
+
599
+ /**
600
+ * Convert the Builder into a archive formatted buffer or file
601
+ * @param asset The file or buffer for the archive
602
+ */
603
+ toArchive(asset: DestinationAsset): Promise<void>;
604
+
605
+ /**
606
+ * Sign an asset from a buffer or file
607
+ * @param signer The local signer to use
608
+ * @param source The file or buffer containing the asset
609
+ * @param dest The file or buffer to write the asset to
610
+ * @returns the bytes of the c2pa_manifest that was embedded
611
+ */
612
+ sign(
613
+ signer: LocalSignerInterface,
614
+ input: SourceAsset,
615
+ output: DestinationAsset,
616
+ ): Buffer;
617
+
618
+ /**
619
+ * Sign an asset from a buffer or file asynchronously, using a callback
620
+ * and not passing a private key
621
+ * @param signerConfig The configuration for the signer
622
+ * @param callback The callback function to sign the asset
623
+ * @param source The file or buffer containing the asset
624
+ * @param dest The file or buffer to write the asset to
625
+ * @returns the bytes of the c2pa_manifest that was embedded
626
+ */
627
+ signConfigAsync(
628
+ callback: (data: Buffer) => Promise<Buffer>,
629
+ signerConfig: JsCallbackSignerConfig,
630
+ input: SourceAsset,
631
+ output: DestinationAsset,
632
+ ): Promise<Buffer>;
633
+
634
+ /**
635
+ * Sign an asset from a buffer or file asynchronously, using a
636
+ * CallbackSigner
637
+ * @param callbackSigner The CallbackSigner
638
+ * @param source The file or buffer containing the asset
639
+ * @param dest The file or buffer to write the asset to
640
+ * @returns the bytes of the c2pa_manifest that was embedded
641
+ */
642
+ signAsync(
643
+ callbackSigner: CallbackSignerInterface,
644
+ input: SourceAsset,
645
+ output: DestinationAsset,
646
+ ): Promise<Buffer>;
647
+
648
+ /**
649
+ * Embed a signed manifest into a stream using the LocalSigner
650
+ * @param signer The local signer to use
651
+ * @param source The file or buffer containing the asset
652
+ * @param dest The file or buffer to write the asset to
653
+ * @returns the bytes of the c2pa_manifest that was embedded
654
+ */
655
+ signFile(
656
+ signer: LocalSignerInterface,
657
+ filePath: string,
658
+ output: DestinationAsset,
659
+ ): Buffer;
660
+
661
+ /**
662
+ * Sign an asset from a buffer or file asynchronously, using an
663
+ * IdentityAssertionSigner
664
+ * @param signer The IdentityAssertionSigner
665
+ * @param source The file or buffer containing the asset
666
+ * @param dest The file or buffer to write the asset to
667
+ * @returns the bytes of the c2pa_manifest that was embedded
668
+ */
669
+ identitySignAsync(
670
+ callbackSigner: IdentityAssertionSignerInterface,
671
+ input: SourceAsset,
672
+ output: DestinationAsset,
673
+ ): Promise<Buffer>;
674
+
675
+ /**
676
+ * Getter for the builder's manifest definition
677
+ * @returns The manifest definition
678
+ */
679
+ getManifestDefinition(): ManifestDefinition;
680
+
681
+ /**
682
+ * Update a string property of the manifest
683
+ * @returns The manifest definition
684
+ */
685
+ updateManifestProperty(property: string, value: string | ClaimVersion): void;
686
+ }
687
+
688
+ export interface ReaderInterface {
689
+ /**
690
+ * Get the JSON representation of the manifest
691
+ */
692
+ json(): ManifestStore;
693
+
694
+ /**
695
+ * Get the remote url of the manifest if this reader obtained the manifest remotely
696
+ */
697
+ remoteUrl(): string;
698
+
699
+ /**
700
+ * Returns true if the the reader was created from an embedded manifest
701
+ */
702
+ isEmbedded(): boolean;
703
+
704
+ /**
705
+ * Write a resource to a buffer or file
706
+ * @param uri The URI of the resource
707
+ * @param filePath The path to the file
708
+ */
709
+ resourceToAsset(uri: string, output: DestinationAsset): Promise<number>;
710
+
711
+ /**
712
+ * Run CAWG validation
713
+ */
714
+ postValidateCawg(): Promise<void>;
715
+ }
716
+
717
+ export interface IdentityAssertionSignerInterface {
718
+ /** Add a IdentityAssertionBuilder to be used when signing the
719
+ * next Manifest
720
+ *
721
+ * IMPORTANT: When sign() is called, the list of
722
+ * IdentityAssertionBuilders will be cleared.
723
+ */
724
+ addIdentityAssertion(
725
+ identityAssertionBuilder: IdentityAssertionBuilderInterface,
726
+ ): void;
727
+ }
728
+
729
+ export interface IdentityAssertionBuilderInterface {
730
+ /**
731
+ * Add assertion labels to consider as referenced_assertions.
732
+ * If any of these labels match assertions that are present in the partial
733
+ * claim submitted during signing, they will be added to the
734
+ * `referenced_assertions` list for this identity assertion.
735
+ * @param referencedAssertions The list of assertion labels to add
736
+ */
737
+ addReferencedAssertions(referencedAssertions: string[]): void;
738
+ /**
739
+ * Add roles to attach to the named actor for this identity assertion.
740
+ * @param roles Named actor roles
741
+ */
742
+ addRoles(roles: string[]): void;
743
+
744
+ /**
745
+ * Get the underlying IdentityAssertionBuilder
746
+ */
747
+ builder(): IdentityAssertionBuilderInterface;
748
+ }
749
+
750
+ export interface TrustmarkInterface {
751
+ /**
752
+ * Encode a watermark into an image.
753
+ * @param image image to be watermarked
754
+ * @param strength number between 0 and 1 indicating how strongly the watermark should be applied
755
+ * @param watermark optional bitstring to be encoded, automatically generated if not provided
756
+ * @returns raw pixel data in RGB8 format (width * height * 3 bytes)
757
+ */
758
+ encode(image: Buffer, strength: number, watermark?: string): Promise<Buffer>;
759
+
760
+ /**
761
+ * Decode a watermark from an image.
762
+ * @param image image to extract the watermark from (must be in a supported image format like JPEG, PNG, etc.)
763
+ */
764
+ decode(image: Buffer): Promise<string>;
765
+ }
766
+
767
+ export interface TrustmarkConfig {
768
+ variant: TrustmarkVariant;
769
+ version: TrustmarkVersion;
770
+ modelPath?: string;
771
+ }