package app

import "strings"

const (
	ServiceEventSubscriptionScopeRead  = "service_event_subscription.read"
	ServiceEventSubscriptionScopeWrite = "service_event_subscription.write"

	legacyProviderWatchScopeRead  = "provider" + "_watch.read"
	legacyProviderWatchScopeWrite = "provider" + "_watch.write"
)

func normalizeServiceEventAuthorizationScope(scope string) string {
	switch strings.TrimSpace(scope) {
	case legacyProviderWatchScopeRead:
		return ServiceEventSubscriptionScopeRead
	case legacyProviderWatchScopeWrite:
		return ServiceEventSubscriptionScopeWrite
	default:
		return strings.TrimSpace(scope)
	}
}
