| // 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_CLAIM_TIMESTAMP_UPDATER_H_ | |
| #define THIRD_PARTY_CREDENTIO_CLAIM_TIMESTAMP_UPDATER_H_ | |
| #include <memory> | |
| #include <string> | |
| #include <utility> | |
| #include "absl/base/nullability.h" | |
| #include "absl/functional/any_invocable.h" | |
| #include "absl/status/status.h" | |
| #include "async/async_context.h" | |
| #include "cose/timestamp_creator.h" | |
| namespace credentio { | |
| // Updater of claim timestamps in C2PA manifest stores. | |
| class ClaimTimestampUpdater { | |
| public: | |
| explicit ClaimTimestampUpdater( | |
| std::unique_ptr<TimestampCreator> timestamp_creator) | |
| : timestamp_creator_(std::move(timestamp_creator)) {} | |
| // Inserts a timestamp to the active manifest in the given manifest store, if | |
| // a timestamp is not found; otherwise, makes no change. If a timestamp is | |
| // inserted, it resizes the `pad` in the unprotected header to ensure the size | |
| // of the result is the same as the input. | |
| // | |
| // Returns an error if space is insufficient for padding. | |
| void InsertTimestamp(std::string* absl_nonnull manifest_store, | |
| AsyncContext async_context, | |
| absl::AnyInvocable<void(absl::Status) &&> cb) const; | |
| private: | |
| std::unique_ptr<TimestampCreator> timestamp_creator_; | |
| }; | |
| } // namespace credentio | |
| #endif // THIRD_PARTY_CREDENTIO_CLAIM_TIMESTAMP_UPDATER_H_ |