blob: acf35ca69f55c34fbeaaaced61edaf6f602d54d6 [file]
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef THIRD_PARTY_CREDENTIO_ASSERTION_PARSE_ASSERTION_H_
#define THIRD_PARTY_CREDENTIO_ASSERTION_PARSE_ASSERTION_H_
#include <optional>
#include "absl/status/status.h"
#include "absl/strings/string_view.h"
#include "google/protobuf/struct.pb.h"
#include "proto/actions_assertion.pb.h"
#include "proto/ai_disclosure_assertion.pb.h"
#include "proto/asset_reference_assertion.pb.h"
#include "proto/asset_types_assertion.pb.h"
#include "proto/bmff_based_hash_assertion.pb.h"
#include "proto/boxes_hash_assertion.pb.h"
#include "proto/collection_data_hash_assertion.pb.h"
#include "proto/data_hash_assertion.pb.h"
#include "proto/environmental_sustainability_assertion.pb.h"
#include "proto/ingredient_assertion.pb.h"
#include "proto/metadata_assertion.pb.h"
#include "proto/multi_asset_hash_assertion.pb.h"
#include "proto/repository_receipt_assertion.pb.h"
#include "proto/soft_binding_assertion.pb.h"
#include "proto/thumbnail_assertion.pb.h"
namespace credentio {
// Parses a CBOR-encoded `actions-map-v2`.
// See
// https://spec.c2pa.org/specifications/specifications/2.4/specs/C2PA_Specification.html#_schema_and_example_8.
absl::Status ParseAssertion(absl::string_view assertion,
ActionsAssertion* proto);
// Parses a CBOR-encoded `actions-map-v1`.
absl::Status ParseAssertion(absl::string_view assertion,
ActionsAssertionV1* proto);
// Parses a CBOR-encoded `bmff-based-hash-map`.
// See
// https://spec.c2pa.org/specifications/specifications/2.4/specs/C2PA_Specification.html#_bmff_based_hash.
absl::Status ParseAssertion(absl::string_view assertion,
BmffBasedHashAssertion* proto);
// Parses a CBOR-encoded `data-hash-map`.
// See
// https://spec.c2pa.org/specifications/specifications/2.4/specs/C2PA_Specification.html#_data_hash.
absl::Status ParseAssertion(absl::string_view assertion,
DataHashAssertion* proto);
// Parses a CBOR-encoded `ingredient-map-v3`.
absl::Status ParseAssertion(absl::string_view assertion,
IngredientAssertionV3* proto);
// Parses a CBOR-encoded `asset-ref-map`.
// See
// https://spec.c2pa.org/specifications/specifications/2.4/specs/C2PA_Specification.html#_asset_reference.
absl::Status ParseAssertion(absl::string_view assertion,
AssetReferenceAssertion* proto);
// Parses a CBOR-encoded `asset-type-map`.
// See
// https://spec.c2pa.org/specifications/specifications/2.4/specs/C2PA_Specification.html#_asset_type.
absl::Status ParseAssertion(absl::string_view assertion,
AssetTypesAssertion* proto);
// Parses a CBOR-encoded `box-hash-map`.
// See
// https://spec.c2pa.org/specifications/specifications/2.4/specs/C2PA_Specification.html#_general_box_hash.
absl::Status ParseAssertion(absl::string_view assertion,
BoxesHashAssertion* proto);
// Parses a CBOR-encoded `multi-asset-hash-map`.
// See
// https://spec.c2pa.org/specifications/specifications/2.4/specs/C2PA_Specification.html#_multi_asset_hash.
absl::Status ParseAssertion(absl::string_view assertion,
MultiAssetHashAssertion* proto);
// Parses a CBOR-encoded `collection-data-hash-map`.
// See
// https://spec.c2pa.org/specifications/specifications/2.4/specs/C2PA_Specification.html#_collection_data_hash.
absl::Status ParseAssertion(absl::string_view assertion,
CollectionDataHashAssertion* proto);
absl::Status ParseAssertion(absl::string_view assertion,
AiDisclosureAssertion* proto);
absl::Status ParseAssertion(absl::string_view assertion,
EnvironmentalSustainabilityAssertion* proto);
absl::Status ParseAssertion(absl::string_view assertion,
RepositoryReceiptAssertion* proto);
absl::Status ParseAssertion(absl::string_view assertion,
SoftBindingAssertion* proto);
ThumbnailAssertion ParseThumbnailAssertion(
absl::string_view media_type, absl::string_view data,
std::optional<absl::string_view> file_name);
absl::Status ParseStruct(absl::string_view content,
google::protobuf::Struct* proto);
} // namespace credentio
#endif // THIRD_PARTY_CREDENTIO_ASSERTION_PARSE_ASSERTION_H_