Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
swap_pack.hpp File Reference

Sealed swap-pack manifest + per-file integrity. More...

#include <pulp/runtime/crypto.hpp>
#include <choc/text/choc_JSON.h>
#include <cctype>
#include <cstdint>
#include <filesystem>
#include <fstream>
#include <optional>
#include <string>
#include <string_view>
#include <system_error>
#include <vector>

Go to the source code of this file.

Classes

struct  pulp::format::reload::SwapPackFile
struct  pulp::format::reload::SwapPackManifest
struct  pulp::format::reload::SwapPackVerifyResult

Namespaces

namespace  pulp
namespace  pulp::format
 What the product grants a device: the quota table indexed by capability tier and live thermal state.
namespace  pulp::format::reload

Enumerations

enum class  pulp::format::reload::SwapPackKind {
  pulp::format::reload::UiScript , pulp::format::reload::DspGraph , pulp::format::reload::NodePack , pulp::format::reload::WasmDsp ,
  pulp::format::reload::Unknown
}
 Payload kind for one file in a swap pack. More...
enum class  pulp::format::reload::SwapPackVerify {
  pulp::format::reload::Ok = 0 , pulp::format::reload::ManifestParseError , pulp::format::reload::MissingFile , pulp::format::reload::ReadError ,
  pulp::format::reload::HashMismatch , pulp::format::reload::UntrustedSigner , pulp::format::reload::BadSignature
}

Functions

SwapPackKind pulp::format::reload::swap_pack_kind_from_string (std::string_view s)
const char * pulp::format::reload::swap_pack_kind_to_string (SwapPackKind k)
 Stable canonical spelling of a kind, for the signed message (never localized / reformatted).
std::optional< std::vector< std::uint8_t > > pulp::format::reload::swap_pack_hex_decode (std::string_view hex)
 Decode a lowercase/uppercase hex string to bytes.
std::optional< SwapPackManifest > pulp::format::reload::parse_swap_pack_manifest (std::string_view json, std::string &error)
 Parse a swap-pack manifest from JSON.
SwapPackVerifyResult pulp::format::reload::verify_swap_pack_integrity (const std::filesystem::path &root, const SwapPackManifest &manifest)
 Verify every declared file exists under root and its bytes hash to the declared SHA-256.
std::vector< std::uint8_t > pulp::format::reload::swap_pack_signed_message (const SwapPackManifest &m)
 Deterministic canonical payload the pack signature covers.
SwapPackVerifyResult pulp::format::reload::verify_swap_pack_signature (const SwapPackManifest &manifest, const std::vector< std::uint8_t > &trusted_public_key)
 Verify the pack's Ed25519 signature.
SwapPackVerifyResult pulp::format::reload::verify_swap_pack (const std::filesystem::path &root, const SwapPackManifest &manifest, const std::vector< std::uint8_t > &trusted_public_key)
 Full fail-closed verify: signature FIRST (binds the file hashes without reading the files), THEN per-file integrity (the files match the signed hashes).
std::string pulp::format::reload::swap_pack_hex_encode (const std::vector< std::uint8_t > &bytes)
 Lowercase-hex encode bytes (for signer/signature fields on the way out).
std::string pulp::format::reload::swap_pack_json_escape (std::string_view s)
 Minimal JSON string escaper for the fields the manifest emits.
std::string pulp::format::reload::serialize_swap_pack_manifest (const SwapPackManifest &m)
 Serialize a manifest to JSON that parse_swap_pack_manifest reads back verbatim (round-trips).

Detailed Description

Sealed swap-pack manifest + per-file integrity.

A swap-pack is downloadable content that hot-swaps a shipped plugin's UI/DSP: a manifest plus files (scripted-UI JS + theme + assets, .pulpgraph DSP graphs, node packs, reserved wasm-dsp). This slice defines the manifest schema and the FIRST verification layer — per-file SHA-256 — so a tampered or truncated pack fails closed at the hash layer before anything is installed or swapped. It reuses runtime::sha256_hex and mirrors the proven NodePackManifest scheme (per-file hash → typed reject codes).

Deferred to later slices (see planning/2026-07-02-phase3-consumer-substrate- scoping.md): the Ed25519 pack SIGNATURE (3.1b), registry install + driving the live swap (3.1c). This header adds NO signing and does not install anything.