// Copyright (c) 2025-2026 Rocky Software Inc.
// All rights reserved.
//
// This file is part of the RockyGuard library and is distributed under
// the terms of the RockyGuard Library Software License Agreement. See
// docs/RockyGuard_License_Agreement.pdf in the distribution.
//
// No part of this file may be copied, modified, or distributed except
// as expressly permitted by the license agreement.

#pragma once

#include "export.h"
#include <string>
#include <vector>

namespace rockyguard {

enum class LicenseType {
    NodeLocked,
    Floating
};

enum class LicenseStatus {
    Valid,
    Expired,
    InGracePeriod,
    HardwareMismatch,
    SignatureInvalid,
    MalformedFile,
    NotYetValid,
    FeatureNotLicensed,
    NoLicensesAvailable,
    ServerUnreachable,
    LibraryNotInitialized,  // Vendor license not loaded via init()
    TierNotAuthorized,      // Feature requires a higher library tier
    GenerationLimitReached, // End-user license generation limit exceeded
    MachineNotAuthorized,   // Machine not in authorized developer seats
    ClockManipulated,       // System clock rolled back (tampering detected)
    IntegrityCheckFailed,   // Library binary has been modified (tampering)
    MachineSeatLimitReached, // Floating: this machine has reached its per-machine cap
    VersionMismatch,        // Application version does not satisfy License::version_range
};

enum class SignatureAlgorithm {
    RSA_SHA256,
    Ed25519,
    // v1.2.1+: when passed to LicenseVerifier or LicenseGenerator,
    // the algorithm is inferred from the loaded key's PEM (Ed25519
    // keys -> Ed25519, RSA keys -> RSA_SHA256). Customers no longer
    // have to track which algorithm they used at keypair creation;
    // pass this (or accept the default) and let the library figure
    // it out. Existing code that passes Ed25519 / RSA_SHA256
    // explicitly continues to work unchanged.
    AutoDetect
};

struct ROCKYGUARD_API LicenseResult {
    LicenseStatus status;
    std::string message;
    int grace_days_remaining = 0;

    explicit operator bool() const {
        return status == LicenseStatus::Valid ||
               status == LicenseStatus::InGracePeriod;
    }
};

} // namespace rockyguard
