This commit is contained in:
@@ -23,6 +23,7 @@ const (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Onboarding OnboardingConfig
|
||||
VikingResourceID string
|
||||
VikingCollectionName string
|
||||
VikingAPIKey string
|
||||
@@ -254,6 +255,7 @@ func Load(serviceName string) (Config, error) {
|
||||
}
|
||||
environment := stringEnv("APP_ENV", EnvironmentLocal)
|
||||
secretValues, err := loadSecretValues(
|
||||
"ONBOARDING_MASTER_KEY", "ONBOARDING_SMS_GATEWAY_TOKEN",
|
||||
"DATABASE_URL", "REDIS_PASSWORD", "DEVICE_LOCAL_SECRET", "DEVICE_CREDENTIAL_MASTER_KEY", "MODEL_CREDENTIAL_MASTER_KEY", "RTC_APP_KEY", "RTC_TOKEN_SIGNING_SECRET",
|
||||
"CURSOR_SIGNING_SECRET", "SHARE_TOKEN_SIGNING_SECRET", "PROVIDER_CALLBACK_SECRET", "PLATFORM_HEALTH_CALLBACK_SECRET",
|
||||
"VOLC_SUBTITLE_CALLBACK_SECRET", "VIKING_MEMORY_API_KEY",
|
||||
@@ -485,6 +487,10 @@ func Load(serviceName string) (Config, error) {
|
||||
return Config{}, err
|
||||
}
|
||||
|
||||
cfg.Onboarding, err = loadOnboardingConfig(secretValues)
|
||||
if err != nil {
|
||||
return Config{}, err
|
||||
}
|
||||
if err := cfg.Validate(); err != nil {
|
||||
return Config{}, err
|
||||
}
|
||||
@@ -492,6 +498,9 @@ func Load(serviceName string) (Config, error) {
|
||||
}
|
||||
|
||||
func (c Config) Validate() error {
|
||||
if err := c.Onboarding.validate(c.Environment); err != nil {
|
||||
return err
|
||||
}
|
||||
if c.SubtitleCallbackURL != "" || c.SubtitleCallbackSecret != "" || c.SubtitlePrimary {
|
||||
u, err := url.Parse(c.SubtitleCallbackURL)
|
||||
if err != nil || u.Scheme != "https" || u.Host == "" || u.RawQuery != "" || u.Fragment != "" || u.User != nil || len(c.SubtitleCallbackSecret) < 32 {
|
||||
@@ -607,7 +616,7 @@ func (c Config) Validate() error {
|
||||
if c.VolcHardwareTransport != "high_quality" && c.VolcHardwareTransport != "low_load" {
|
||||
return errors.New("VOLC_HARDWARE_AGENT_TRANSPORT must be high_quality or low_load")
|
||||
}
|
||||
if c.ServiceName == "api" && c.VolcHardwareProvisioningEnabled {
|
||||
if (c.ServiceName == "api" && c.VolcHardwareProvisioningEnabled) || ((c.ServiceName == "api" || c.ServiceName == "worker") && c.Onboarding.ActivationEnabled) {
|
||||
providerKey, err := hex.DecodeString(c.VolcHardwareDeviceCredentialMasterKey)
|
||||
if err != nil || len(providerKey) != 32 {
|
||||
return errors.New("VOLC_HARDWARE_DEVICE_CREDENTIAL_MASTER_KEY must be 32 bytes encoded as 64 hexadecimal characters")
|
||||
|
||||
Reference in New Issue
Block a user