package apiimp

import "github.com/tech/sendico/pkg/messaging"

type CORSSettings struct {
	MaxAge           int      `yaml:"max_age"`
	AllowedOrigins   []string `yaml:"allowed_origins"`
	AllowedMethods   []string `yaml:"allowed_methods"`
	AllowedHeaders   []string `yaml:"allowed_headers"`
	ExposedHeaders   []string `yaml:"exposed_headers"`
	AllowCredentials bool     `yaml:"allow_credentials"`
}

type SignatureConf struct {
	PublicKey  any
	PrivateKey []byte
	Algorithm  string
}

type Signature struct {
	PublicKeyEnv  string `yaml:"public_key_env,omitempty"`
	PrivateKeyEnv string `yaml:"secret_key_env"`
	Algorithm     string `yaml:"algorithm"`
}

type TokenExpiration struct {
	Account int `yaml:"account"`
	Refresh int `yaml:"refresh"`
}

type TokenConfig struct {
	Expiration TokenExpiration `yaml:"expiration_hours"`
	Length     int             `yaml:"length"`
}

type WebSocketConfig struct {
	EndpointEnv string `yaml:"endpoint_env"`
	Timeout     int    `yaml:"timeout"`
}

type PasswordChecks struct {
	Digit     bool `yaml:"digit"`
	Upper     bool `yaml:"upper"`
	Lower     bool `yaml:"lower"`
	Special   bool `yaml:"special"`
	MinLength int  `yaml:"min_length"`
}

type PasswordConfig struct {
	TokenLength int            `yaml:"token_length"`
	Check       PasswordChecks `yaml:"check"`
}

type Config struct {
	DomainEnv      string           `yaml:"domain_env"`
	EndPointEnv    string           `yaml:"api_endpoint_env"`
	APIProtocolEnv string           `yaml:"api_protocol_env"`
	Signature      Signature        `yaml:"signature"`
	CORS           CORSSettings     `yaml:"CORS"`
	WebSocket      WebSocketConfig  `yaml:"websocket"`
	Messaging      messaging.Config `yaml:"message_broker"`
	Token          TokenConfig      `yaml:"token"`
	Password       PasswordConfig   `yaml:"password"`
}

type MapClaims = map[string]any
