/*
 * Copyright 2026 Oleg Borodin <onborodin@gmail.com>
 *
 * This work is published and licensed under a Creative Commons
 * Attribution-NonCommercial-NoDerivatives 4.0 International License.
 *
 * Distribution of this work is permitted, but commercial use and
 * modifications are strictly prohibited.
 */
package auxoci

import (
	"encoding/json"
	"fmt"

	ocidigest "github.com/opencontainers/go-digest"
	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)

func ParseOCIManifest(rawManifest []byte) (*ocispec.Manifest, error) {
	manifest := &ocispec.Manifest{}
	err := json.Unmarshal(rawManifest, &manifest)
	if err != nil {
		err = fmt.Errorf("Manifest parsing error: %v", err)
		return manifest, err
	}
	return manifest, err
}

func SHA256DigestFromString(payload string) ocidigest.Digest {
	return ocidigest.SHA256.FromString(payload)
}
