90 lines
3.5 KiB
C++
90 lines
3.5 KiB
C++
#pragma once
|
|
|
|
#include <Void/Build/Package/Solver.hpp>
|
|
#include <Void/Functional/Error.hpp>
|
|
#include <Void/Functional/Result.hpp>
|
|
|
|
#include <filesystem>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <vector>
|
|
|
|
namespace Void::Build::Package {
|
|
|
|
struct RegistryAuth {
|
|
std::string bearer_token; // Runtime-only; never written to locks or logs.
|
|
};
|
|
|
|
struct PublishOptions {
|
|
std::string registry_url;
|
|
std::string package_name;
|
|
std::string version;
|
|
std::filesystem::path archive_path;
|
|
std::string description;
|
|
bool is_private{false};
|
|
RegistryAuth auth;
|
|
// Optional Ed25519 signing seed (64 hex chars). When set, the published release carries
|
|
// X-Package-Signature / X-Package-Public-Key over the canonical package message.
|
|
std::optional<std::filesystem::path> signing_seed_path;
|
|
};
|
|
|
|
struct PublishReceipt {
|
|
std::string sha256;
|
|
bool already_published{false};
|
|
};
|
|
|
|
// Queries GET /api/v1/packages/<name> on a VBS registry and parses all release records
|
|
// into Package::ReleaseRecord entries ready for PackageIndex + PubGrub solving.
|
|
[[nodiscard]] Void::Result::Result<std::vector<ReleaseRecord>, Void::Result::Error>
|
|
fetch_package_releases(std::string_view registry_url, std::string_view package_name,
|
|
const RegistryAuth &auth = {});
|
|
|
|
// Downloads GET /api/v1/packages/<name>/<version>/download, verifies SHA-256 against
|
|
// `expected_sha256` before atomic publication to `dest_file`.
|
|
[[nodiscard]] Void::Result::Result<std::filesystem::path, Void::Result::Error>
|
|
download_release_archive(std::string_view registry_url, std::string_view package_name,
|
|
std::string_view version, std::string_view expected_sha256,
|
|
const std::filesystem::path &dest_file, const RegistryAuth &auth = {});
|
|
|
|
struct BinaryPublishOptions {
|
|
std::string registry_url;
|
|
std::string package_name;
|
|
std::string version;
|
|
std::string variant_id;
|
|
std::filesystem::path artifact_path;
|
|
std::optional<std::filesystem::path> signing_seed_path;
|
|
RegistryAuth auth;
|
|
};
|
|
|
|
struct BinaryReleaseInfo {
|
|
std::string variant_id;
|
|
std::string sha256;
|
|
std::uint64_t size_bytes{0};
|
|
bool yanked{false};
|
|
std::optional<std::string> signature;
|
|
std::optional<std::string> public_key;
|
|
};
|
|
|
|
// Publishes a prebuilt binary variant for an existing release (optionally Ed25519-signed over
|
|
// the canonical binary message) and returns the artifact SHA-256.
|
|
[[nodiscard]] Void::Result::Result<std::string, Void::Result::Error>
|
|
publish_binary_variant(const BinaryPublishOptions &options);
|
|
|
|
// Lists the binary variants stored for one release.
|
|
[[nodiscard]] Void::Result::Result<std::vector<BinaryReleaseInfo>, Void::Result::Error>
|
|
fetch_binary_variants(std::string_view registry_url, std::string_view package_name,
|
|
std::string_view version, const RegistryAuth &auth = {});
|
|
|
|
// Downloads a prebuilt binary artifact from an absolute http(s) URL into `dest_file`,
|
|
// rejecting any content whose SHA-256 differs from `expected_sha256` (verified before writing).
|
|
[[nodiscard]] Void::Result::Result<std::filesystem::path, Void::Result::Error>
|
|
download_binary_artifact(std::string_view url, std::string_view expected_sha256,
|
|
const std::filesystem::path &dest_file);
|
|
|
|
// Publishes a verified deterministic archive via PUT /api/v1/packages/<name>/<version>.
|
|
[[nodiscard]] Void::Result::Result<PublishReceipt, Void::Result::Error>
|
|
publish_package_archive(const PublishOptions &options);
|
|
|
|
} // namespace Void::Build::Package
|