package token

// Type represents the type of token
type Type string

const (
	TypeBearer Type = "Bearer"
	TypeBasic  Type = "Basic"
)

// String returns the string representation of TokenType
func (t Type) String() string {
	return string(t)
}

// IsValid returns true if the token type is valid
func (t Type) IsValid() bool {
	return t == TypeBearer || t == TypeBasic
}

// Redis key prefixes and patterns
const (
	AccessTokenKeyPrefix = "access_token:"

	RefreshTokenKeyPrefix = "refresh_token:"

	OneTimeTokenKeyPrefix = "one_time_token:"

	UIDTokenKeyPrefix = "uid_tokens:"

	DeviceTokenKeyPrefix = "device_tokens:"

	TicketKeyPrefix = "ticket:"

	BlacklistKeyPrefix = "blacklist:"
)

// Redis key helper functions
func GetAccessTokenRedisKey(tokenID string) string {
	return AccessTokenKeyPrefix + tokenID
}

func RefreshTokenRedisKey(tokenID string) string {
	return RefreshTokenKeyPrefix + tokenID
}

func UIDTokenRedisKey(uid string) string {
	return UIDTokenKeyPrefix + uid
}

func DeviceTokenRedisKey(deviceID string) string {
	return DeviceTokenKeyPrefix + deviceID
}

func GetBlacklistRedisKey(jti string) string {
	return BlacklistKeyPrefix + jti
}

func GetUIDTokenRedisKey(uid string) string {
	return UIDTokenKeyPrefix + uid
}

// Default expiration times (in seconds)
const (
	DefaultAccessTokenExpiry  = 15 * 60       // 15 minutes
	DefaultRefreshTokenExpiry = 7 * 24 * 3600 // 7 days
	DefaultOneTimeTokenExpiry = 5 * 60        // 5 minutes
)

// Token limits
const (
	MaxTokensPerUser   = 10 // Maximum tokens per user
	MaxTokensPerDevice = 5  // Maximum tokens per device
)
