librnxengine 1.1.0

implement robust software licensing, activation, and validation systems.
Documentation
use chrono::{Duration, Utc};
use librnxengine::*;
use std::path::Path;
#[test]
fn full_license_flow_test() {
    let engine = LicenseEngine::new(Default::default());
    let keypair = engine
        .generate_keypair()
        .expect("Failed to generate keypair");
    let payload = LicensePayload {
        license_id: Uuid::new_v4(),
        customer_id: "test_customer".to_string(),
        product_id: "test_product".to_string(),
        issued_at: Utc::now(),
        expires_at: Utc::now() + Duration::days(30),
        max_activations: 5,
        features: vec!["feature_a".to_string(), "feature_b".to_string()],
        metadata: serde_json::json!({"plan": "pro"}),
    };
    let license = engine
        .create_license(&keypair, payload.clone())
        .expect("Failed to create license");
    let validation = engine
        .verify_license(&keypair.public, &license)
        .expect("License verification failed");
    assert!(validation.is_valid(), "License should be valid");
    let json = engine
        .license_to_json(&license)
        .expect("Failed to convert license to JSON");
    let license_from_json = engine
        .license_from_json(&json)
        .expect("Failed to parse license from JSON");
    assert_eq!(license.license_id(), license_from_json.license_id());
    let bytes = engine
        .license_to_bytes(&license)
        .expect("Failed to serialize license to bytes");
    let license_from_bytes = engine
        .license_from_bytes(&bytes)
        .expect("Failed to deserialize license from bytes");
    assert_eq!(license.license_id(), license_from_bytes.license_id());
    let fingerprint = HardwareFingerprint::generate().expect("Failed to generate fingerprint");
    assert!(!fingerprint.is_empty(), "Fingerprint should not be empty");
    let validator = LicenseValidator {
        allow_offline: true,
        grace_period_days: 7,
        require_hardware_check: true,
    };
    let result = validator.validate_license(&license, Some(&fingerprint), true);
    assert!(
        result.is_valid(),
        "License validation with hardware should pass"
    );
    let pub_path = Path::new("test_pubkey.json");
    keypair
        .save_to_file(pub_path)
        .expect("Failed to save keypair");
    let loaded_pub = KeyPair::load_public_from_file(pub_path).expect("Failed to load public key");
    assert_eq!(loaded_pub.to_bytes(), keypair.public.to_bytes());
    std::fs::remove_file(pub_path).ok();
}