Change module path from forge.lthn.ai/core/go-scm to dappco.re/go/core/scm. Update all Go source imports for migrated packages: - go-log -> dappco.re/go/core/log - go-io -> dappco.re/go/core/io - go-i18n -> dappco.re/go/core/i18n - go-ws -> dappco.re/go/core/ws - api -> dappco.re/go/core/api Non-migrated packages (cli, config) left on forge.lthn.ai paths. Replace directives use local paths (../go, ../go-io, etc.) until the dappco.re vanity URL server resolves these modules. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package manifest
|
|
|
|
import (
|
|
"crypto/ed25519"
|
|
"path/filepath"
|
|
|
|
coreerr "dappco.re/go/core/log"
|
|
"dappco.re/go/core/io"
|
|
"gopkg.in/yaml.v3"
|
|
)
|
|
|
|
const manifestPath = ".core/manifest.yaml"
|
|
|
|
// MarshalYAML serializes a manifest to YAML bytes.
|
|
func MarshalYAML(m *Manifest) ([]byte, error) {
|
|
return yaml.Marshal(m)
|
|
}
|
|
|
|
// Load reads and parses a .core/manifest.yaml from the given root directory.
|
|
func Load(medium io.Medium, root string) (*Manifest, error) {
|
|
path := filepath.Join(root, manifestPath)
|
|
data, err := medium.Read(path)
|
|
if err != nil {
|
|
return nil, coreerr.E("manifest.Load", "read failed", err)
|
|
}
|
|
return Parse([]byte(data))
|
|
}
|
|
|
|
// LoadVerified reads, parses, and verifies the ed25519 signature.
|
|
func LoadVerified(medium io.Medium, root string, pub ed25519.PublicKey) (*Manifest, error) {
|
|
m, err := Load(medium, root)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ok, err := Verify(m, pub)
|
|
if err != nil {
|
|
return nil, coreerr.E("manifest.LoadVerified", "verification error", err)
|
|
}
|
|
if !ok {
|
|
return nil, coreerr.E("manifest.LoadVerified", "signature verification failed for "+m.Code, nil)
|
|
}
|
|
return m, nil
|
|
}
|