chore: initialize standalone business plugin repository
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"git.awaioi.com/awaioi/sub2api-add/plugins/subscription-admin/internal/manifest"
|
||||
)
|
||||
|
||||
func main() {
|
||||
manifestPath := flag.String("manifest", "business-plugin-manifest.v1.json", "manifest path")
|
||||
signaturePath := flag.String("signature", "", "optional detached signature path")
|
||||
publicKeyPath := flag.String("public-key", "", "base64 Ed25519 public key file")
|
||||
flag.Parse()
|
||||
m, raw, err := manifest.Load(*manifestPath)
|
||||
if err != nil {
|
||||
fatal(err)
|
||||
}
|
||||
if (*signaturePath == "") != (*publicKeyPath == "") {
|
||||
fatal(fmt.Errorf("-signature and -public-key must be provided together"))
|
||||
}
|
||||
if *signaturePath != "" {
|
||||
signature, err := os.ReadFile(*signaturePath)
|
||||
if err != nil {
|
||||
fatal(err)
|
||||
}
|
||||
publicKey, err := os.ReadFile(*publicKeyPath)
|
||||
if err != nil {
|
||||
fatal(err)
|
||||
}
|
||||
if err := manifest.VerifyKeyID(signature, m.Publisher.KeyID); err != nil {
|
||||
fatal(err)
|
||||
}
|
||||
if err := manifest.VerifySignature(raw, signature, publicKey); err != nil {
|
||||
fatal(err)
|
||||
}
|
||||
}
|
||||
fmt.Printf("manifest valid: %s\n", *manifestPath)
|
||||
}
|
||||
|
||||
func fatal(err error) {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
Reference in New Issue
Block a user