Update: add component catalog transactions
This commit is contained in:
3 files changed
+540
-7
No files matched your search
@@ -9,6 +9,7 @@
|
||||
#include <chrono>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
@@ -75,6 +76,66 @@ namespace Void::Update
|
||||
std::string signedPayload;
|
||||
};
|
||||
|
||||
/// A signature-verified payload whose schema-specific parsing is left to
|
||||
/// the caller. This is useful for signed discovery documents that are not
|
||||
/// legacy aggregate feeds.
|
||||
struct VerifiedEnvelope {
|
||||
std::uint32_t schemaVersion{0};
|
||||
std::string keyId;
|
||||
std::string signedPayload;
|
||||
};
|
||||
|
||||
struct ComponentArtifact {
|
||||
std::string name;
|
||||
std::string url;
|
||||
std::string sha256;
|
||||
std::uint64_t size{0};
|
||||
std::string manifestSha256;
|
||||
std::string packageType;
|
||||
};
|
||||
|
||||
struct ComponentCatalogEntry {
|
||||
std::string componentId;
|
||||
std::optional<std::string> pluginId;
|
||||
std::string kind;
|
||||
Semver::Version componentVersion;
|
||||
std::string activation;
|
||||
std::map<std::string, Semver::VersionRange> dependencies;
|
||||
std::uint64_t sequence{0};
|
||||
std::string latestUrl;
|
||||
std::string artifactSha256;
|
||||
};
|
||||
|
||||
struct ComponentCatalog {
|
||||
std::uint32_t schemaVersion{2};
|
||||
std::string channel;
|
||||
std::uint64_t sequence{0};
|
||||
std::chrono::system_clock::time_point generatedAt;
|
||||
std::chrono::system_clock::time_point expiresAt;
|
||||
Semver::Version productVersion;
|
||||
std::vector<ComponentCatalogEntry> components;
|
||||
};
|
||||
|
||||
struct ComponentRelease {
|
||||
std::uint32_t schemaVersion{2};
|
||||
std::string channel;
|
||||
std::uint64_t sequence{0};
|
||||
std::chrono::system_clock::time_point generatedAt;
|
||||
std::chrono::system_clock::time_point expiresAt;
|
||||
Semver::Version productVersion;
|
||||
std::string componentId;
|
||||
std::optional<std::string> pluginId;
|
||||
std::string kind;
|
||||
Semver::Version componentVersion;
|
||||
std::string sourceSha;
|
||||
std::string sourceTreeHash;
|
||||
std::string abiHash;
|
||||
std::string artifactIdentity;
|
||||
std::string activation;
|
||||
std::map<std::string, Semver::VersionRange> dependencies;
|
||||
ComponentArtifact artifact;
|
||||
};
|
||||
|
||||
struct Environment {
|
||||
std::unordered_map<std::string, Semver::Version> versionContracts;
|
||||
std::unordered_map<std::string, std::string> exactContracts;
|
||||
@@ -105,6 +166,25 @@ namespace Void::Update
|
||||
verifyFeedEnvelope(std::string_view envelopeJson, const Keyring& keys,
|
||||
const VerificationPolicy& policy = {});
|
||||
|
||||
/// Verify and decode a signed envelope without assuming a payload schema.
|
||||
[[nodiscard]] Void::Result::Result<VerifiedEnvelope>
|
||||
verifyEnvelope(std::string_view envelopeJson, const Keyring& keys,
|
||||
const VerificationPolicy& policy = {});
|
||||
|
||||
[[nodiscard]] Void::Result::Result<ComponentCatalog>
|
||||
parseComponentCatalogPayload(std::string_view payload,
|
||||
const VerificationPolicy& policy = {});
|
||||
|
||||
[[nodiscard]] Void::Result::Result<ComponentRelease>
|
||||
parseComponentReleasePayload(std::string_view payload,
|
||||
const VerificationPolicy& policy = {});
|
||||
|
||||
/// Validate that a catalog and its fetched releases form one complete,
|
||||
/// dependency-compatible transaction.
|
||||
[[nodiscard]] Void::Result::Result<void> validateComponentSet(
|
||||
const ComponentCatalog& catalog,
|
||||
const std::map<std::string, ComponentRelease>& releases);
|
||||
|
||||
/// Select the greatest compatible version, independent of feed order.
|
||||
[[nodiscard]] std::optional<Release>
|
||||
selectRelease(const Feed& feed, const SelectionRequest& request);
|
||||
|
||||
Reference in new issue
Block a user