package usecase

import "context"

// TokenType distinguishes CloudEP JWT kinds.
type TokenType string

const (
	TokenTypeAccess  TokenType = "access"
	TokenTypeRefresh TokenType = "refresh"
)

// TokenPair is issued to clients after login or register confirm.
type TokenPair struct {
	AccessToken  string
	RefreshToken string
	ExpiresIn    int64
	TokenType    string
}

// IssuePairRequest identifies the member receiving tokens.
type IssuePairRequest struct {
	TenantID string
	UID      string
	AuthGen  int64
}

// AccessClaims are parsed from a valid access JWT.
type AccessClaims struct {
	TenantID string
	UID      string
	AuthGen  int64
	JTI      string
}

// LogoutRequest revokes the current access token and its paired refresh token.
type LogoutRequest struct {
	AccessToken string
}

// TokenUseCase signs and validates CloudEP JWTs.
type TokenUseCase interface {
	IssuePair(ctx context.Context, req *IssuePairRequest) (*TokenPair, error)
	Refresh(ctx context.Context, refreshToken string) (*TokenPair, error)
	Logout(ctx context.Context, req *LogoutRequest) error
	ParseAccessToken(ctx context.Context, accessToken string) (*AccessClaims, error)
}
