2023-03-28 20:43:45 +02:00
|
|
|
package spec
|
2023-03-03 20:37:09 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"forge.cadoles.com/Cadoles/emissary/internal/spec"
|
2023-03-21 15:21:19 +01:00
|
|
|
edgeAuth "forge.cadoles.com/arcad/edge/pkg/module/auth/http"
|
2023-10-03 06:09:15 +02:00
|
|
|
"github.com/lestrrat-go/jwx/v2/jwa"
|
2023-03-03 20:37:09 +01:00
|
|
|
)
|
|
|
|
|
2024-03-12 16:22:35 +01:00
|
|
|
const (
|
|
|
|
Name string = "app.emissary.cadoles.com"
|
|
|
|
Version string = "0.0.0"
|
|
|
|
)
|
2023-03-03 20:37:09 +01:00
|
|
|
|
|
|
|
type Spec struct {
|
2023-03-21 15:21:19 +01:00
|
|
|
Revision int `json:"revision"`
|
2023-03-21 13:28:41 +01:00
|
|
|
Apps map[string]AppEntry `json:"apps"`
|
2023-03-28 20:43:45 +02:00
|
|
|
Config *Config `json:"config"`
|
2023-03-03 20:37:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type AppEntry struct {
|
2023-10-03 06:09:15 +02:00
|
|
|
URL string `json:"url"`
|
|
|
|
SHA256Sum string `json:"sha256sum"`
|
|
|
|
Address string `json:"address"`
|
|
|
|
Format string `json:"format"`
|
|
|
|
Storage *AppStorage `json:"storage"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type AppStorage struct {
|
|
|
|
ShareStoreDSN string `json:"shareStoreDsn"`
|
|
|
|
DocumentStoreDSN string `json:"documentStoreDsn"`
|
|
|
|
BlobStoreDSN string `json:"blobStoreDsn"`
|
2023-03-03 20:37:09 +01:00
|
|
|
}
|
|
|
|
|
2023-03-21 13:28:41 +01:00
|
|
|
type Auth struct {
|
2023-03-21 15:21:19 +01:00
|
|
|
Local *LocalAuth `json:"local,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type LocalAuth struct {
|
2023-10-03 06:09:15 +02:00
|
|
|
Key any `json:"key"`
|
|
|
|
SigningAlgorithm jwa.SignatureAlgorithm `json:"signingAlgorithm"`
|
|
|
|
Accounts []edgeAuth.LocalAccount `json:"accounts"`
|
|
|
|
CookieDomain string `json:"cookieDomain"`
|
|
|
|
CookieDuration string `json:"cookieDuration"`
|
2023-03-28 20:43:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type Config struct {
|
2023-04-05 23:21:43 +02:00
|
|
|
Auth *Auth `json:"auth"`
|
|
|
|
UnexpectedHostRedirect *UnexpectedHostRedirect `json:"unexpectedHostRedirect"`
|
|
|
|
AppURLResolving *AppURLResolving `json:"appUrlResolving"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type UnexpectedHostRedirect struct {
|
|
|
|
AcceptedHostPatterns []string `json:"acceptedHostPatterns"`
|
|
|
|
HostTarget string `json:"hostTarget"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type AppURLResolving struct {
|
|
|
|
IfaceMappings map[string]string `json:"ifaceMappings"`
|
|
|
|
DefaultURLTemplate string `json:"defaultUrlTemplate"`
|
2023-03-21 13:28:41 +01:00
|
|
|
}
|
|
|
|
|
2024-03-12 16:22:35 +01:00
|
|
|
func (s *Spec) SpecDefinitionName() string {
|
2023-03-28 20:43:45 +02:00
|
|
|
return Name
|
2023-03-03 20:37:09 +01:00
|
|
|
}
|
|
|
|
|
2024-03-12 16:22:35 +01:00
|
|
|
func (s *Spec) SpecDefinitionVersion() string {
|
|
|
|
return Version
|
|
|
|
}
|
|
|
|
|
2023-03-03 20:37:09 +01:00
|
|
|
func (s *Spec) SpecRevision() int {
|
|
|
|
return s.Revision
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Spec) SpecData() map[string]any {
|
|
|
|
return map[string]any{
|
2023-03-28 20:43:45 +02:00
|
|
|
"apps": s.Apps,
|
|
|
|
"config": s.Config,
|
2023-03-03 20:37:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewSpec() *Spec {
|
2023-03-13 10:44:58 +01:00
|
|
|
return &Spec{
|
|
|
|
Revision: -1,
|
|
|
|
}
|
2023-03-03 20:37:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
var _ spec.Spec = &Spec{}
|