Live video on the AT Protocol
1// Code generated from JSON Schema using quicktype. DO NOT EDIT.
2// To parse and unparse this JSON data, add this code to your project and do:
3//
4// c2Patypes, err := UnmarshalC2Patypes(bytes)
5// bytes, err = c2Patypes.Marshal()
6
7package c2patypes
8
9import "bytes"
10import "errors"
11
12import "encoding/json"
13
14func UnmarshalC2Patypes(data []byte) (C2Patypes, error) {
15 var r C2Patypes
16 err := json.Unmarshal(data, &r)
17 return r, err
18}
19
20func (r *C2Patypes) Marshal() ([]byte, error) {
21 return json.Marshal(r)
22}
23
24type C2Patypes struct {
25 Builder Builder `json:"builder"`
26 ManifestDefinition ManifestDefinition `json:"manifest_definition"`
27 Reader Reader `json:"reader"`
28}
29
30// Use a Builder to add a signed manifest to an asset.
31//
32// # Example: Building and signing a manifest
33//
34// ``` use c2pa::Result; use std::path::PathBuf;
35//
36// use c2pa::{create_signer, Builder, SigningAlg}; use serde::Serialize; use
37// serde_json::json; use tempfile::tempdir;
38//
39// #[derive(Serialize)] struct Test { my_tag: usize, }
40//
41// # fn main() -> Result<()> { #[cfg(feature = "file_io")] { let manifest_json = json!({
42// "claim_generator_info": [ { "name": "c2pa_test", "version": "1.0.0" } ], "title":
43// "Test_Manifest" }).to_string();
44//
45// let mut builder = Builder::from_json(&manifest_json)?;
46// builder.add_assertion("org.contentauth.test", &Test { my_tag: 42 })?;
47//
48// let source = PathBuf::from("tests/fixtures/C.jpg"); let dir = tempdir()?; let dest =
49// dir.path().join("test_file.jpg");
50//
51// // Create a ps256 signer using certs and key files. TO DO: Update example. let
52// signcert_path = "tests/fixtures/certs/ps256.pub"; let pkey_path =
53// "tests/fixtures/certs/ps256.pem"; let signer = create_signer::from_files(signcert_path,
54// pkey_path, SigningAlg::Ps256, None)?;
55//
56// // embed a manifest using the signer builder.sign_file( signer.as_ref(), &source,
57// &dest)?; } # Ok(()) # } ```
58type Builder struct {
59 // A list of assertions
60 Assertions []AssertionDefinition `json:"assertions,omitempty"`
61 // Base path to search for resources.
62 BasePath *string `json:"base_path"`
63 // The type of builder being used.
64 BuilderFlow *BuilderFlowUnion `json:"builder_flow"`
65 // Claim Generator Info is always required with at least one entry
66 ClaimGeneratorInfo []ClaimGeneratorInfo `json:"claim_generator_info,omitempty"`
67 // The version of the claim. Defaults to 1.
68 ClaimVersion *int64 `json:"claim_version"`
69 // The format of the source file as a MIME type.
70 Format *string `json:"format,omitempty"`
71 // A List of ingredients
72 Ingredients []Ingredient `json:"ingredients,omitempty"`
73 // Instance ID from `xmpMM:InstanceID` in XMP metadata.
74 InstanceID *string `json:"instance_id,omitempty"`
75 // Allows you to pre-define the manifest label, which must be unique. Not intended for
76 // general use. If not set, it will be assigned automatically.
77 Label *string `json:"label"`
78 // Optional manifest metadata. This will be deprecated in the future; not recommended to use.
79 Metadata []AssertionMetadata `json:"metadata"`
80 // If true, the manifest store will not be embedded in the asset on sign
81 NoEmbed bool `json:"no_embed"`
82 // A list of redactions - URIs to redacted assertions.
83 Redactions []string `json:"redactions"`
84 // Optional remote URL for the manifest
85 RemoteURL *string `json:"remote_url"`
86 // An optional ResourceRef to a thumbnail image that represents the asset that was signed.
87 // Must be available when the manifest is signed.
88 Thumbnail *IngredientResourceRef `json:"thumbnail"`
89 // A human-readable title, generally source filename.
90 Title *string `json:"title"`
91 // Optional prefix added to the generated Manifest Label This is typically a reverse domain
92 // name.
93 Vendor *string `json:"vendor"`
94}
95
96// Defines an assertion that consists of a label that can be either a C2PA-defined assertion
97// label or a custom label in reverse domain format.
98type AssertionDefinition struct {
99 Data interface{} `json:"data"`
100 Label string `json:"label"`
101}
102
103type BuilderFlowClass struct {
104 Create DigitalSourceType `json:"Create"`
105}
106
107// Description of the claim generator, or the software used in generating the claim.
108//
109// This structure is also used for actions softwareAgent
110type ClaimGeneratorInfo struct {
111 // hashed URI to the icon (either embedded or remote)
112 Icon *ResourceRef `json:"icon"`
113 // A human readable string naming the claim_generator
114 Name string `json:"name"`
115 // A human readable string of the OS the claim generator is running on
116 OperatingSystem *string `json:"operating_system"`
117 // A human readable string of the product's version
118 Version *string `json:"version"`
119}
120
121// A reference to a resource to be used in JSON serialization.
122//
123// The underlying data can be read as a stream via
124// [`Reader::resource_to_stream`][crate::Reader::resource_to_stream].
125//
126// A `HashedUri` provides a reference to content available within the same manifest store.
127//
128// This is described in [§8.3, URI References], of the C2PA Technical Specification.
129//
130// [§8.3, URI References]:
131// https://c2pa.org/specifications/specifications/2.1/specs/C2PA_Specification.html#_uri_references
132type ResourceRef struct {
133 // The algorithm used to hash the resource (if applicable).
134 //
135 // A string identifying the cryptographic hash algorithm used to compute the hash
136 Alg *string `json:"alg"`
137 // More detailed data types as defined in the C2PA spec.
138 DataTypes []AssetType `json:"data_types"`
139 // The mime type of the referenced resource.
140 Format *string `json:"format,omitempty"`
141 // The hash of the resource (if applicable).
142 //
143 // Byte string containing the hash value
144 Hash *BasePath `json:"hash"`
145 // A URI that identifies the resource as referenced from the manifest.
146 //
147 // This may be a JUMBF URI, a file path, a URL or any other string. Relative JUMBF URIs will
148 // be resolved with the manifest label. Relative file paths will be resolved with the base
149 // path if provided.
150 Identifier *string `json:"identifier,omitempty"`
151 // JUMBF URI reference
152 URL *string `json:"url,omitempty"`
153}
154
155type AssetType struct {
156 Type string `json:"type"`
157 Version *string `json:"version"`
158}
159
160// An `Ingredient` is any external asset that has been used in the creation of an asset.
161type Ingredient struct {
162 // The active manifest label (if one exists).
163 //
164 // If this ingredient has a [`ManifestStore`], this will hold the label of the active
165 // [`Manifest`].
166 //
167 // [`Manifest`]: crate::Manifest [`ManifestStore`]: crate::ManifestStore
168 ActiveManifest *string `json:"active_manifest"`
169 // A reference to the actual data of the ingredient.
170 Data *IngredientResourceRef `json:"data"`
171 // Additional information about the data's type to the ingredient V2 structure.
172 DataTypes []AssetType `json:"data_types"`
173 // Additional description of the ingredient.
174 Description *string `json:"description"`
175 // Document ID from `xmpMM:DocumentID` in XMP metadata.
176 DocumentID *string `json:"document_id"`
177 // The format of the source file as a MIME type.
178 Format *string `json:"format"`
179 // An optional hash of the asset to prevent duplicates.
180 Hash *string `json:"hash"`
181 // URI to an informational page about the ingredient or its data.
182 InformationalURI *string `json:"informational_URI"`
183 // Instance ID from `xmpMM:InstanceID` in XMP metadata.
184 InstanceID *string `json:"instance_id"`
185 // The ingredient's label as assigned in the manifest.
186 Label *string `json:"label"`
187 // A [`ManifestStore`] from the source asset extracted as a binary C2PA blob.
188 //
189 // [`ManifestStore`]: crate::ManifestStore
190 ManifestData *IngredientResourceRef `json:"manifest_data"`
191 // Any additional [`Metadata`] as defined in the C2PA spec.
192 //
193 // [`Metadata`]: crate::Metadata
194 Metadata *AssertionMetadata `json:"metadata"`
195 // URI from `dcterms:provenance` in XMP metadata.
196 Provenance *string `json:"provenance"`
197 // Set to `ParentOf` if this is the parent ingredient.
198 //
199 // There can only be one parent ingredient in the ingredients.
200 Relationship *Relationship `json:"relationship,omitempty"`
201 Resources *ResourceStore `json:"resources,omitempty"`
202 // A thumbnail image capturing the visual state at the time of import.
203 //
204 // A tuple of thumbnail MIME format (for example `image/jpeg`) and binary bits of the image.
205 Thumbnail *IngredientResourceRef `json:"thumbnail"`
206 // A human-readable title, generally source filename.
207 Title *string `json:"title"`
208 // Validation results (Ingredient.V3)
209 ValidationResults *ValidationResults `json:"validation_results"`
210 // Validation status (Ingredient v1 & v2)
211 ValidationStatus []ValidationStatus `json:"validation_status"`
212}
213
214// A reference to a resource to be used in JSON serialization.
215//
216// The underlying data can be read as a stream via
217// [`Reader::resource_to_stream`][crate::Reader::resource_to_stream].
218type IngredientResourceRef struct {
219 // The algorithm used to hash the resource (if applicable).
220 Alg *string `json:"alg"`
221 // More detailed data types as defined in the C2PA spec.
222 DataTypes []AssetType `json:"data_types"`
223 // The mime type of the referenced resource.
224 Format string `json:"format"`
225 // The hash of the resource (if applicable).
226 Hash *string `json:"hash"`
227 // A URI that identifies the resource as referenced from the manifest.
228 //
229 // This may be a JUMBF URI, a file path, a URL or any other string. Relative JUMBF URIs will
230 // be resolved with the manifest label. Relative file paths will be resolved with the base
231 // path if provided.
232 Identifier string `json:"identifier"`
233}
234
235// A region of interest within an asset describing the change.
236//
237// This struct can be used from [`Action::changes`][crate::assertions::Action::changes] or
238// [`AssertionMetadata::region_of_interest`][crate::assertions::AssertionMetadata::region_of_interest].
239type RegionOfInterest struct {
240 // A free-text string.
241 Description *string `json:"description"`
242 // A free-text string representing a machine-readable, unique to this assertion, identifier
243 // for the region.
244 Identifier *string `json:"identifier"`
245 // Additional information about the asset.
246 Metadata *AssertionMetadata `json:"metadata"`
247 // A free-text string representing a human-readable name for the region which might be used
248 // in a user interface.
249 Name *string `json:"name"`
250 // A range describing the region of interest for the specific asset.
251 Region []Range `json:"region"`
252 // A value from our controlled vocabulary or an entity-specific value (e.g.,
253 // com.litware.coolArea) that represents the role of a region among other regions.
254 Role *Role `json:"role"`
255 // A value from a controlled vocabulary such as
256 // <https://cv.iptc.org/newscodes/imageregiontype/> or an entity-specific value (e.g.,
257 // com.litware.newType) that represents the type of thing(s) depicted by a region.
258 //
259 // Note this field serializes/deserializes into the name `type`.
260 Type *string `json:"type"`
261}
262
263// The AssertionMetadata structure can be used as part of other assertions or on its own to
264// reference others
265type AssertionMetadata struct {
266 DataSource *DataSource `json:"dataSource"`
267 DateTime *string `json:"dateTime"`
268 Reference *HashedURI `json:"reference"`
269 RegionOfInterest *RegionOfInterest `json:"regionOfInterest"`
270 ReviewRatings []ReviewRating `json:"reviewRatings"`
271}
272
273// A spatial, temporal, frame, or textual range describing the region of interest.
274type Range struct {
275 // A frame range.
276 Frame *Frame `json:"frame"`
277 // A item identifier.
278 Item *Item `json:"item"`
279 // A spatial range.
280 Shape *Shape `json:"shape"`
281 // A textual range.
282 Text *Text `json:"text"`
283 // A temporal range.
284 Time *Time `json:"time"`
285 // The type of range of interest.
286 Type RangeType `json:"type"`
287}
288
289// A frame range representing starting and ending frames or pages.
290//
291// If both `start` and `end` are missing, the frame will span the entire asset.
292type Frame struct {
293 // The end of the frame inclusive or the end of the asset if not present.
294 End *int64 `json:"end"`
295 // The start of the frame or the end of the asset if not present.
296 //
297 // The first frame/page starts at 0.
298 Start *int64 `json:"start"`
299}
300
301// Description of the boundaries of an identified range.
302type Item struct {
303 // The container-specific term used to identify items, such as "track_id" for MP4 or
304 // "item_ID" for HEIF.
305 Identifier string `json:"identifier"`
306 // The value of the identifier, e.g. a value of "2" for an identifier of "track_id" would
307 // imply track 2 of the asset.
308 Value string `json:"value"`
309}
310
311// A spatial range representing rectangle, circle, or a polygon.
312type Shape struct {
313 // The height of a rectnagle.
314 //
315 // This field can be ignored for circles and polygons.
316 Height *float64 `json:"height"`
317 // If the range is inside the shape.
318 //
319 // The default value is true.
320 Inside *bool `json:"inside"`
321 // THe origin of the coordinate in the shape.
322 Origin Coordinate `json:"origin"`
323 // The type of shape.
324 Type ShapeType `json:"type"`
325 // The type of unit for the shape range.
326 Unit UnitType `json:"unit"`
327 // The vertices of the polygon.
328 //
329 // This field can be ignored for rectangles and circles.
330 Vertices []Coordinate `json:"vertices"`
331 // The width for rectangles or diameter for circles.
332 //
333 // This field can be ignored for polygons.
334 Width *float64 `json:"width"`
335}
336
337// THe origin of the coordinate in the shape.
338//
339// An x, y coordinate used for specifying vertices in polygons.
340type Coordinate struct {
341 // The coordinate along the x-axis.
342 X float64 `json:"x"`
343 // The coordinate along the y-axis.
344 Y float64 `json:"y"`
345}
346
347// A textual range representing multiple (possibly discontinuous) ranges of text.
348type Text struct {
349 // The ranges of text to select.
350 Selectors []TextSelectorRange `json:"selectors"`
351}
352
353// One or two [`TextSelector`][TextSelector] identifiying the range to select.
354type TextSelectorRange struct {
355 // The end of the text range.
356 End *TextSelector `json:"end"`
357 // The start (or entire) text range.
358 Selector TextSelector `json:"selector"`
359}
360
361// Selects a range of text via a fragment identifier.
362//
363// This is modeled after the W3C Web Annotation selector model.
364//
365// The start (or entire) text range.
366type TextSelector struct {
367 // The end character offset or the end of the fragment if not present.
368 End *int64 `json:"end"`
369 // Fragment identifier as per RFC3023 (XML) or ISO 32000-2 (PDF), Annex O.
370 Fragment string `json:"fragment"`
371 // The start character offset or the start of the fragment if not present.
372 Start *int64 `json:"start"`
373}
374
375// A temporal range representing a starting time to an ending time.
376type Time struct {
377 // The end time or the end of the asset if not present.
378 End *string `json:"end"`
379 // The start time or the start of the asset if not present.
380 Start *string `json:"start"`
381 // The type of time.
382 Type *TimeType `json:"type,omitempty"`
383}
384
385// A description of the source for assertion data
386type DataSource struct {
387 // A list of [`Actor`]s associated with this source.
388 Actors []Actor `json:"actors"`
389 // A human-readable string giving details about the source of the assertion data.
390 Details *string `json:"details"`
391 // A value from among the enumerated list indicating the source of the assertion.
392 Type string `json:"type"`
393}
394
395// Identifies a person responsible for an action.
396type Actor struct {
397 // List of references to W3C Verifiable Credentials.
398 Credentials []HashedURI `json:"credentials"`
399 // An identifier for a human actor, used when the "type" is `humanEntry.identified`.
400 Identifier *string `json:"identifier"`
401}
402
403// A `HashedUri` provides a reference to content available within the same manifest store.
404//
405// This is described in [§8.3, URI References], of the C2PA Technical Specification.
406//
407// [§8.3, URI References]:
408// https://c2pa.org/specifications/specifications/2.1/specs/C2PA_Specification.html#_uri_references
409type HashedURI struct {
410 // A string identifying the cryptographic hash algorithm used to compute the hash
411 Alg *string `json:"alg"`
412 // Byte string containing the hash value
413 Hash []int64 `json:"hash"`
414 // JUMBF URI reference
415 URL string `json:"url"`
416}
417
418// A rating on an Assertion.
419//
420// See
421// <https://c2pa.org/specifications/specifications/2.2/specs/C2PA_Specification.html#_review_ratings>.
422type ReviewRating struct {
423 Code *string `json:"code"`
424 Explanation string `json:"explanation"`
425 Value int64 `json:"value"`
426}
427
428// Resource store to contain binary objects referenced from JSON serializable structures
429//
430// container for binary assets (like thumbnails)
431type ResourceStore struct {
432 BasePath *string `json:"base_path"`
433 Label *string `json:"label"`
434 Resources map[string][]int64 `json:"resources"`
435}
436
437// A map of validation results for a manifest store.
438//
439// The map contains the validation results for the active manifest and any ingredient
440// deltas. It is normal for there to be many
441type ValidationResults struct {
442 ActiveManifest *StatusCodes `json:"activeManifest"`
443 IngredientDeltas []IngredientDeltaValidationResult `json:"ingredientDeltas"`
444}
445
446// Contains a set of success, informational, and failure validation status codes.
447//
448// Validation results for the ingredient's active manifest
449type StatusCodes struct {
450 Failure []ValidationStatus `json:"failure"`
451 Informational []ValidationStatus `json:"informational"`
452 Success []ValidationStatus `json:"success"`
453}
454
455// A `ValidationStatus` struct describes the validation status of a specific part of a
456// manifest.
457//
458// See
459// <https://c2pa.org/specifications/specifications/2.2/specs/C2PA_Specification.html#_existing_manifests>.
460type ValidationStatus struct {
461 Code string `json:"code"`
462 Explanation *string `json:"explanation"`
463 Success *bool `json:"success"`
464 URL *string `json:"url"`
465}
466
467// Represents any changes or deltas between the current and previous validation results for
468// an ingredient's manifest.
469type IngredientDeltaValidationResult struct {
470 // JUMBF URI reference to the ingredient assertion
471 IngredientAssertionURI string `json:"ingredientAssertionURI"`
472 // Validation results for the ingredient's active manifest
473 ValidationDeltas StatusCodes `json:"validationDeltas"`
474}
475
476// Use a ManifestDefinition to define a manifest and to build a `ManifestStore`. A manifest
477// is a collection of ingredients and assertions used to define a claim that can be signed
478// and embedded into a file.
479type ManifestDefinition struct {
480 // A list of assertions
481 Assertions []AssertionDefinition `json:"assertions,omitempty"`
482 // Claim Generator Info is always required with at least one entry
483 ClaimGeneratorInfo []ClaimGeneratorInfo `json:"claim_generator_info,omitempty"`
484 // The version of the claim. Defaults to 1.
485 ClaimVersion *int64 `json:"claim_version"`
486 // The format of the source file as a MIME type.
487 Format *string `json:"format,omitempty"`
488 // A List of ingredients
489 Ingredients []Ingredient `json:"ingredients,omitempty"`
490 // Instance ID from `xmpMM:InstanceID` in XMP metadata.
491 InstanceID *string `json:"instance_id,omitempty"`
492 // Allows you to pre-define the manifest label, which must be unique. Not intended for
493 // general use. If not set, it will be assigned automatically.
494 Label *string `json:"label"`
495 // Optional manifest metadata. This will be deprecated in the future; not recommended to use.
496 Metadata []AssertionMetadata `json:"metadata"`
497 // A list of redactions - URIs to redacted assertions.
498 Redactions []string `json:"redactions"`
499 // An optional ResourceRef to a thumbnail image that represents the asset that was signed.
500 // Must be available when the manifest is signed.
501 Thumbnail *IngredientResourceRef `json:"thumbnail"`
502 // A human-readable title, generally source filename.
503 Title *string `json:"title"`
504 // Optional prefix added to the generated Manifest Label This is typically a reverse domain
505 // name.
506 Vendor *string `json:"vendor"`
507}
508
509// Use a Reader to read and validate a manifest store.
510type Reader struct {
511 // A label for the active (most recent) manifest in the store
512 ActiveManifest *string `json:"active_manifest"`
513 // A HashMap of Manifests
514 Manifests map[string]Manifest `json:"manifests"`
515 // ValidationStatus generated when loading the ManifestStore from an asset
516 ValidationResults *ValidationResults `json:"validation_results"`
517 // The validation state of the manifest store
518 ValidationState *ValidationState `json:"validation_state"`
519 // ValidationStatus generated when loading the ManifestStore from an asset
520 ValidationStatus []ValidationStatus `json:"validation_status"`
521}
522
523// A Manifest represents all the information in a c2pa manifest
524type Manifest struct {
525 // A list of assertions
526 Assertions []ManifestAssertion `json:"assertions,omitempty"`
527 // A User Agent formatted string identifying the software/hardware/system produced this
528 // claim Spaces are not allowed in names, versions can be specified with product/1.0 syntax.
529 ClaimGenerator *string `json:"claim_generator"`
530 // A list of claim generator info data identifying the software/hardware/system produced
531 // this claim.
532 ClaimGeneratorInfo []ClaimGeneratorInfo `json:"claim_generator_info"`
533 // A List of verified credentials
534 Credentials []interface{} `json:"credentials"`
535 // The format of the source file as a MIME type.
536 Format *string `json:"format"`
537 // A List of ingredients
538 Ingredients []Ingredient `json:"ingredients,omitempty"`
539 // Instance ID from `xmpMM:InstanceID` in XMP metadata.
540 InstanceID *string `json:"instance_id,omitempty"`
541 Label *string `json:"label"`
542 // A list of user metadata for this claim.
543 Metadata []AssertionMetadata `json:"metadata"`
544 // A list of redactions - URIs to a redacted assertions
545 Redactions []string `json:"redactions"`
546 // container for binary assets (like thumbnails)
547 Resources *ResourceStore `json:"resources,omitempty"`
548 // Signature data (only used for reporting)
549 SignatureInfo *SignatureInfo `json:"signature_info"`
550 Thumbnail *IngredientResourceRef `json:"thumbnail"`
551 // A human-readable title, generally source filename.
552 Title *string `json:"title"`
553 // Optional prefix added to the generated Manifest label. This is typically an internet
554 // domain name for the vendor (i.e. `adobe`).
555 Vendor *string `json:"vendor"`
556}
557
558// A labeled container for an Assertion value in a Manifest
559type ManifestAssertion struct {
560 // The data of the assertion as Value
561 Data interface{} `json:"data"`
562 // There can be more than one assertion for any label
563 Instance *int64 `json:"instance"`
564 // The [ManifestAssertionKind] for this assertion (as stored in c2pa content)
565 Kind *ManifestAssertionKind `json:"kind"`
566 // An assertion label in reverse domain format
567 Label string `json:"label"`
568}
569
570// Holds information about a signature
571type SignatureInfo struct {
572 // Human-readable issuing authority for this signature.
573 Alg *SigningAlg `json:"alg"`
574 // The serial number of the certificate.
575 CERTSerialNumber *string `json:"cert_serial_number"`
576 // Human-readable issuing authority for this signature.
577 Issuer *string `json:"issuer"`
578 // Revocation status of the certificate.
579 RevocationStatus *bool `json:"revocation_status"`
580 // The time the signature was created.
581 Time *string `json:"time"`
582}
583
584// Media whose digital content is effectively empty, such as a blank canvas or zero-length
585// video.
586//
587// Data that is the result of algorithmically using a model derived from sampled content and
588// data. Differs from
589// <http://cv.iptc.org/newscodes/digitalsourcetype/>trainedAlgorithmicMedia in that the
590// result isn’t a media type (e.g., image or video) but is a data format (e.g., CSV, pickle).
591type DigitalSourceType string
592
593const (
594 Empty DigitalSourceType = "Empty"
595 TrainedAlgorithmicData DigitalSourceType = "TrainedAlgorithmicData"
596)
597
598type BuilderFlowEnum string
599
600const (
601 Open BuilderFlowEnum = "Open"
602 Update BuilderFlowEnum = "Update"
603)
604
605// The type of shape.
606//
607// The type of shape for the range.
608//
609// A rectangle.
610//
611// A circle.
612//
613// A polygon.
614type ShapeType string
615
616const (
617 Circle ShapeType = "circle"
618 Polygon ShapeType = "polygon"
619 Rectangle ShapeType = "rectangle"
620)
621
622// The type of unit for the shape range.
623//
624// The type of unit for the range.
625//
626// Use pixels.
627//
628// Use percentage.
629type UnitType string
630
631const (
632 Percent UnitType = "percent"
633 Pixel UnitType = "pixel"
634)
635
636// The type of time.
637//
638// Times are described using Normal Play Time (npt) as described in RFC 2326.
639type TimeType string
640
641const (
642 Npt TimeType = "npt"
643)
644
645// The type of range of interest.
646//
647// The type of range for the region of interest.
648//
649// A spatial range, see [`Shape`] for more details.
650//
651// A temporal range, see [`Time`] for more details.
652//
653// A spatial range, see [`Frame`] for more details.
654//
655// A textual range, see [`Text`] for more details.
656//
657// A range identified by a specific identifier and value, see [`Item`] for more details.
658type RangeType string
659
660const (
661 Identified RangeType = "identified"
662 RangeTypeFrame RangeType = "frame"
663 Spatial RangeType = "spatial"
664 Temporal RangeType = "temporal"
665 Textual RangeType = "textual"
666)
667
668// Arbitrary area worth identifying.
669//
670// This area is all that is left after a crop action.
671//
672// This area has had edits applied to it.
673//
674// The area where an ingredient was placed/added.
675//
676// Something in this area was redacted.
677//
678// Area specific to a subject (human or not).
679//
680// A range of information was removed/deleted.
681//
682// Styling was applied to this area.
683//
684// Invisible watermarking was applied to this area for the purpose of soft binding.
685type Role string
686
687const (
688 C2PaAreaOfInterest Role = "c2pa.areaOfInterest"
689 C2PaCropped Role = "c2pa.cropped"
690 C2PaDeleted Role = "c2pa.deleted"
691 C2PaEdited Role = "c2pa.edited"
692 C2PaPlaced Role = "c2pa.placed"
693 C2PaRedacted Role = "c2pa.redacted"
694 C2PaStyled Role = "c2pa.styled"
695 C2PaSubjectArea Role = "c2pa.subjectArea"
696 C2PaWatermarked Role = "c2pa.watermarked"
697)
698
699// Set to `ParentOf` if this is the parent ingredient.
700//
701// There can only be one parent ingredient in the ingredients.
702//
703// The relationship of the ingredient to the current asset.
704//
705// The current asset is derived from this ingredient.
706//
707// The current asset is a part of this ingredient.
708//
709// The ingredient was used as an input to a computational process to create or modify the
710// asset.
711type Relationship string
712
713const (
714 ComponentOf Relationship = "componentOf"
715 InputTo Relationship = "inputTo"
716 ParentOf Relationship = "parentOf"
717)
718
719// Assertions in C2PA can be stored in several formats
720type ManifestAssertionKind string
721
722const (
723 Binary ManifestAssertionKind = "Binary"
724 Cbor ManifestAssertionKind = "Cbor"
725 JSON ManifestAssertionKind = "Json"
726 URI ManifestAssertionKind = "Uri"
727)
728
729// ECDSA with SHA-256
730//
731// # ECDSA with SHA-256 on secp256k1 curve
732//
733// # ECDSA with SHA-384
734//
735// # ECDSA with SHA-512
736//
737// # RSASSA-PSS using SHA-256 and MGF1 with SHA-256
738//
739// # RSASSA-PSS using SHA-384 and MGF1 with SHA-384
740//
741// # RSASSA-PSS using SHA-512 and MGF1 with SHA-512
742//
743// Edwards-Curve DSA (Ed25519 instance only)
744type SigningAlg string
745
746const (
747 Ed25519 SigningAlg = "Ed25519"
748 Es256 SigningAlg = "Es256"
749 Es256K SigningAlg = "Es256K"
750 Es384 SigningAlg = "Es384"
751 Es512 SigningAlg = "Es512"
752 Ps256 SigningAlg = "Ps256"
753 Ps384 SigningAlg = "Ps384"
754 Ps512 SigningAlg = "Ps512"
755)
756
757// Errors were found in the manifest store.
758//
759// No errors were found in validation, but the active signature is not trusted.
760//
761// The manifest store is valid and the active signature is trusted.
762type ValidationState string
763
764const (
765 Invalid ValidationState = "Invalid"
766 Trusted ValidationState = "Trusted"
767 Valid ValidationState = "Valid"
768)
769
770// The type of builder being used.
771type BuilderFlowUnion struct {
772 BuilderFlowClass *BuilderFlowClass
773 Enum *BuilderFlowEnum
774}
775
776func (x *BuilderFlowUnion) UnmarshalJSON(data []byte) error {
777 x.BuilderFlowClass = nil
778 x.Enum = nil
779 var c BuilderFlowClass
780 object, err := unmarshalUnion(data, nil, nil, nil, nil, false, nil, true, &c, false, nil, true, &x.Enum, true)
781 if err != nil {
782 return err
783 }
784 if object {
785 x.BuilderFlowClass = &c
786 }
787 return nil
788}
789
790func (x *BuilderFlowUnion) MarshalJSON() ([]byte, error) {
791 return marshalUnion(nil, nil, nil, nil, false, nil, x.BuilderFlowClass != nil, x.BuilderFlowClass, false, nil, x.Enum != nil, x.Enum, true)
792}
793
794type BasePath struct {
795 IntegerArray []int64
796 String *string
797}
798
799func (x *BasePath) UnmarshalJSON(data []byte) error {
800 x.IntegerArray = nil
801 object, err := unmarshalUnion(data, nil, nil, nil, &x.String, true, &x.IntegerArray, false, nil, false, nil, false, nil, true)
802 if err != nil {
803 return err
804 }
805 if object {
806 }
807 return nil
808}
809
810func (x *BasePath) MarshalJSON() ([]byte, error) {
811 return marshalUnion(nil, nil, nil, x.String, x.IntegerArray != nil, x.IntegerArray, false, nil, false, nil, false, nil, true)
812}
813
814func unmarshalUnion(data []byte, pi **int64, pf **float64, pb **bool, ps **string, haveArray bool, pa interface{}, haveObject bool, pc interface{}, haveMap bool, pm interface{}, haveEnum bool, pe interface{}, nullable bool) (bool, error) {
815 if pi != nil {
816 *pi = nil
817 }
818 if pf != nil {
819 *pf = nil
820 }
821 if pb != nil {
822 *pb = nil
823 }
824 if ps != nil {
825 *ps = nil
826 }
827
828 dec := json.NewDecoder(bytes.NewReader(data))
829 dec.UseNumber()
830 tok, err := dec.Token()
831 if err != nil {
832 return false, err
833 }
834
835 switch v := tok.(type) {
836 case json.Number:
837 if pi != nil {
838 i, err := v.Int64()
839 if err == nil {
840 *pi = &i
841 return false, nil
842 }
843 }
844 if pf != nil {
845 f, err := v.Float64()
846 if err == nil {
847 *pf = &f
848 return false, nil
849 }
850 return false, errors.New("Unparsable number")
851 }
852 return false, errors.New("Union does not contain number")
853 case float64:
854 return false, errors.New("Decoder should not return float64")
855 case bool:
856 if pb != nil {
857 *pb = &v
858 return false, nil
859 }
860 return false, errors.New("Union does not contain bool")
861 case string:
862 if haveEnum {
863 return false, json.Unmarshal(data, pe)
864 }
865 if ps != nil {
866 *ps = &v
867 return false, nil
868 }
869 return false, errors.New("Union does not contain string")
870 case nil:
871 if nullable {
872 return false, nil
873 }
874 return false, errors.New("Union does not contain null")
875 case json.Delim:
876 if v == '{' {
877 if haveObject {
878 return true, json.Unmarshal(data, pc)
879 }
880 if haveMap {
881 return false, json.Unmarshal(data, pm)
882 }
883 return false, errors.New("Union does not contain object")
884 }
885 if v == '[' {
886 if haveArray {
887 return false, json.Unmarshal(data, pa)
888 }
889 return false, errors.New("Union does not contain array")
890 }
891 return false, errors.New("Cannot handle delimiter")
892 }
893 return false, errors.New("Cannot unmarshal union")
894}
895
896func marshalUnion(pi *int64, pf *float64, pb *bool, ps *string, haveArray bool, pa interface{}, haveObject bool, pc interface{}, haveMap bool, pm interface{}, haveEnum bool, pe interface{}, nullable bool) ([]byte, error) {
897 if pi != nil {
898 return json.Marshal(*pi)
899 }
900 if pf != nil {
901 return json.Marshal(*pf)
902 }
903 if pb != nil {
904 return json.Marshal(*pb)
905 }
906 if ps != nil {
907 return json.Marshal(*ps)
908 }
909 if haveArray {
910 return json.Marshal(pa)
911 }
912 if haveObject {
913 return json.Marshal(pc)
914 }
915 if haveMap {
916 return json.Marshal(pm)
917 }
918 if haveEnum {
919 return json.Marshal(pe)
920 }
921 if nullable {
922 return json.Marshal(nil)
923 }
924 return nil, errors.New("Union must not be null")
925}