package oauth

import (
	"git.haelnorr.com/h/golib/env"
	"github.com/pkg/errors"
)

type Config struct {
	PrivateKey string // ENV OAUTH_PRIVATE_KEY: Private key for signing OAuth state tokens (required)
}

func ConfigFromEnv() (any, error) {
	cfg := &Config{
		PrivateKey: env.String("OAUTH_PRIVATE_KEY", ""),
	}

	// Check required fields
	if cfg.PrivateKey == "" {
		return nil, errors.New("Envar not set: OAUTH_PRIVATE_KEY")
	}

	return cfg, nil
}
