1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
/// # librnxengine - Comprehensive License Management System for Rust Applications
///
/// A robust, production-ready library for implementing license management,
/// activation, validation, and cryptographic signing in Rust applications.
/// Provides both client-side and server-side components for building
/// complete license management solutions.
///
/// ## Key Features
///
/// - **Cryptographic Security**: Ed25519 digital signatures for license integrity
/// - **Hardware Binding**: Unique device fingerprints to prevent license sharing
/// - **Offline/Online Validation**: Flexible validation modes for different deployment scenarios
/// - **Grace Periods**: Configurable grace periods for license renewals
/// - **Revocation Support**: Server-side license revocation capabilities
/// - **Multi-Platform**: Works on Windows, macOS, and Linux
/// - **Async Ready**: Built with async/await for modern Rust applications
///
/// ## Quick Start
///
/// ```rust
/// use librnxengine::*;
/// use uuid::Uuid;
/// use chrono::{Utc, Duration};
///
/// #[tokio::main]
/// async fn main() -> Result<(), LicenseError> {
/// // 1. Initialize the license engine
/// let engine = LicenseEngine::new(LicenseConfig::default());
///
/// // 2. Generate cryptographic keys
/// let keypair = engine.generate_keypair()?;
///
/// // 3. Create a license
/// let payload = LicensePayload {
/// license_id: Uuid::new_v4(),
/// customer_id: "customer-123".to_string(),
/// product_id: "myapp-pro".to_string(),
/// expires_at: Utc::now() + Duration::days(365),
/// issued_at: Utc::now(),
/// max_activations: 3,
/// features: vec!["premium".to_string(), "api-access".to_string()],
/// metadata: serde_json::json!({}),
/// };
///
/// let license = engine.create_license(&keypair, payload)?;
///
/// // 4. Verify the license
/// let result = engine.verify_license(&keypair.public, &license)?;
///
/// if result.is_valid() {
/// println!("License is valid!");
/// println!("Features: {:?}", result.features);
/// println!("Days remaining: {:?}", result.days_remaining);
/// }
///
/// Ok(())
/// }
/// ```
///
/// ## Module Structure
///
/// The library is organized into the following modules, each with a specific purpose:
///
/// - **`activation`**: Activation request/response structures for license-server communication
/// - **`client`**: HTTP client for remote license server operations (activation, validation, revocation)
/// - **`crypto`**: Cryptographic primitives (Ed25519 key generation, signing, verification)
/// - **`engine`**: Core license engine for creation, validation, and management
/// - **`error``: Comprehensive error types for all license operations
/// - **`hardware`**: Hardware fingerprint generation for device binding
/// - **`license`**: License data structures and serialization
/// - **`validation``: Validation logic and result reporting
///
/// ## Architecture Overview
///
/// ```text
/// ┌─────────────────────────────────────────────────────────────┐
/// │ Application Layer │
/// │ Uses: LicenseEngine, LicenseClient, HardwareFingerprint │
/// └─────────────────┬───────────────────────────────────────────┘
/// │
/// ┌─────────────────▼───────────────────────────────────────────┐
/// │ Core Service Layer │
/// │ Provides: License creation, validation, crypto operations │
/// └─────────────────┬───────────────────────────────────────────┘
/// │
/// ┌─────────────────▼───────────────────────────────────────────┐
/// │ Infrastructure Layer │
/// │ Handles: HTTP communication, hardware info, serialization │
/// └─────────────────────────────────────────────────────────────┘
/// ```
///
/// ## Usage Patterns
///
/// ### 1. Software Vendor (License Issuance)
///
/// ```rust
/// // Generate keys once and store securely
/// let keypair = KeyPair::generate();
/// keypair.save_to_file("public_key.json")?;
///
/// // Create licenses for customers
/// let license = engine.create_license(&keypair, customer_payload)?;
/// let license_json = engine.license_to_json(&license)?;
///
/// // Distribute license.json to customer
/// ```
///
/// ### 2. End User Application (License Validation)
///
/// ```rust
/// // Load public key provided by vendor
/// let public_key = KeyPair::load_public_from_file("vendor_public_key.json")?;
///
/// // Load user's license
/// let license_json = std::fs::read_to_string("license.json")?;
/// let license = engine.license_from_json(&license_json)?;
///
/// // Validate license
/// let result = engine.verify_license(&public_key, &license)?;
///
/// // Check features
/// if license.has_feature("premium") {
/// enable_premium_features();
/// }
/// ```
///
/// ### 3. Online Activation Flow
///
/// ```rust
/// // Generate hardware fingerprint
/// let fingerprint = HardwareFingerprint::generate()?;
///
/// // Create activation request
/// let request = ActivationRequest {
/// license_id: license.license_id(),
/// hardware_fingerprint: fingerprint,
/// machine_name: get_hostname(),
/// timestamp: Utc::now(),
/// nonce: Uuid::new_v4().to_string(),
/// ..Default::default()
/// };
///
/// // Send to license server
/// let client = LicenseClient::new("https://license.example.com");
/// let response = client.activate_license(&request).await?;
///
/// // Store activation token securely
/// save_activation_token(response.activation_token);
/// ```
///
/// ## Security Considerations
///
/// ### Private Key Security
/// - **NEVER** embed private keys in client applications
/// - Use hardware security modules (HSMs) for production private key storage
/// - Implement key rotation policies
/// - Monitor for unauthorized key usage
///
/// ### License Validation
/// - Always verify cryptographic signatures before trusting license data
/// - Implement revocation checks for sensitive applications
/// - Use hardware binding to prevent license sharing
/// - Consider implementing tamper detection mechanisms
///
/// ### Network Security
/// - Use HTTPS for all license server communications
/// - Implement rate limiting to prevent brute force attacks
/// - Use secure token storage on client devices
/// - Implement proper session management
///
/// ## Performance Characteristics
///
/// - **License Verification**: ~0.1ms (Ed25519 verification is very fast)
/// - **Hardware Fingerprint Generation**: ~5-50ms (depends on system)
/// - **Network Operations**: Varies (typically 100-500ms for server calls)
/// - **Memory Usage**: Minimal (structures are small and efficient)
///
/// ## Error Handling
///
/// All operations return `Result<T, LicenseError>` with comprehensive error types:
///
/// ```rust
/// match engine.verify_license(&public_key, &license) {
/// Ok(result) => {
/// if !result.is_valid() {
/// // Handle validation warnings/violations
/// for violation in result.violations {
/// eprintln!("Violation: {}", violation);
/// }
/// }
/// }
/// Err(LicenseError::SignatureValidationFailed) => {
/// // Handle tampered license
/// show_error("License has been tampered with!");
/// }
/// Err(LicenseError::LicenseExpired) => {
/// // Handle expired license
/// prompt_for_renewal();
/// }
/// Err(e) => {
/// // Handle other errors
/// eprintln!("License error: {}", e);
/// }
/// }
/// ```
///
/// ## Configuration Examples
///
/// ### Strict Validation (Security-Focused)
///
/// ```rust
/// let strict_config = LicenseConfig {
/// allow_offline: false, // Require online validation
/// grace_period_days: 0, // No grace period
/// max_clock_skew_seconds: 60, // Strict time sync requirement
/// require_hardware_binding: true, // Enforce hardware binding
/// enable_revocation_check: true, // Check revocation status
/// };
/// ```
///
/// ### Flexible Validation (User-Friendly)
///
/// ```rust
/// let flexible_config = LicenseConfig {
/// allow_offline: true, // Allow offline use
/// grace_period_days: 30, // 30-day grace period
/// max_clock_skew_seconds: 3600, // 1-hour clock skew tolerance
/// require_hardware_binding: false, // No hardware binding
/// enable_revocation_check: false, // No revocation checks
/// };
/// ```
///
/// ## Integration Examples
///
/// ### Desktop Application
///
/// ```rust
/// // Check license on application startup
/// fn check_license() -> Result<(), LicenseError> {
/// let engine = LicenseEngine::new(LicenseConfig::default());
/// let public_key = load_vendor_public_key();
/// let license = load_user_license();
///
/// let result = engine.verify_license(&public_key, &license)?;
///
/// if !result.is_valid() {
/// return Err(LicenseError::ValidationFailed(
/// result.violations.join(", ")
/// ));
/// }
///
/// Ok(())
/// }
/// ```
///
/// ### Web Service Backend
///
/// ```rust
/// // Validate license for API requests
/// async fn validate_api_license(
/// license_id: Uuid,
/// activation_token: &str,
/// ) -> Result<License, LicenseError> {
/// let client = LicenseClient::new(env::var("LICENSE_SERVER_URL")?);
/// let license = client.validate_license(&license_id, activation_token).await?;
///
/// if license.is_expired() {
/// return Err(LicenseError::LicenseExpired);
/// }
///
/// Ok(license)
/// }
/// ```
///
/// ### Command Line Tool
///
/// ```rust
/// // License activation command
/// #[derive(clap::Parser)]
/// struct ActivateCommand {
/// #[arg(short, long)]
/// license_key: String,
/// }
///
/// impl ActivateCommand {
/// async fn execute(&self) -> Result<(), LicenseError> {
/// let fingerprint = HardwareFingerprint::generate()?;
/// let request = create_activation_request(&self.license_key, fingerprint)?;
///
/// let client = LicenseClient::new("https://license.example.com");
/// let response = client.activate_license(&request).await?;
///
/// save_activation_response(response);
/// println!("License activated successfully!");
///
/// Ok(())
/// }
/// }
/// ```
///
/// ## Testing
///
/// The library includes comprehensive test utilities. Example test:
///
/// ```rust
/// #[cfg(test)]
/// mod tests {
/// use super::*;
///
/// #[test]
/// fn test_license_creation_and_verification() {
/// let engine = LicenseEngine::new(LicenseConfig::default());
/// let keypair = engine.generate_keypair().unwrap();
///
/// let payload = LicensePayload {
/// license_id: Uuid::new_v4(),
/// customer_id: "test".to_string(),
/// product_id: "test".to_string(),
/// expires_at: Utc::now() + Duration::days(1),
/// issued_at: Utc::now(),
/// max_activations: 1,
/// features: vec!["test-feature".to_string()],
/// metadata: serde_json::json!({}),
/// };
///
/// let license = engine.create_license(&keypair, payload).unwrap();
/// let result = engine.verify_license(&keypair.public, &license).unwrap();
///
/// assert!(result.is_valid());
/// assert!(license.has_feature("test-feature"));
/// }
/// }
/// ```
///
/// ## Dependencies
///
/// Key dependencies and their purposes:
///
/// - `chrono`: Date and time handling for license expiration
/// - `ed25519-dalek`: Ed25519 cryptographic signatures
/// - `reqwest`: HTTP client for license server communication
/// - `serde`: Serialization/deserialization for license data
/// - `thiserror`: Comprehensive error types
/// - `tracing`: Structured logging for debugging and monitoring
/// - `uuid`: Unique identifier generation
/// - `zeroize`: Secure memory zeroing for cryptographic keys
///
/// ## Platform Support
///
/// | Platform | Hardware Fingerprint | Notes |
/// |----------|---------------------|-------|
/// | Windows 10/11 | ✓ | Uses WMI for hardware information |
/// | macOS 10.15+ | ✓ | Uses system_profiler and ioreg |
/// | Linux (glibc) | ✓ | Uses /proc and /sys filesystems |
/// | Linux (musl) | ✓ | Alpine Linux supported |
/// | WebAssembly | ✗ | Hardware fingerprint not available |
/// | Android/iOS | ⚠️ | Limited hardware information |
///
/// ## Contributing
///
/// 1. Fork the repository
/// 2. Create a feature branch
/// 3. Add tests for new functionality
/// 4. Ensure all tests pass: `cargo test`
/// 5. Run clippy: `cargo clippy -- -D warnings`
/// 6. Format code: `cargo fmt`
/// 7. Submit a pull request
///
/// ## License
///
/// This library is dual-licensed under:
///
/// - Apache License, Version 2.0
/// - MIT License
///
/// See LICENSE-APACHE and LICENSE-MIT for details.
///
/// ## Support
///
/// - **Documentation**: [docs.rs/librnxengine](https://docs.rs/librnxengine)
/// - **Issues**: [GitHub Issues](https://github.com/neuxdotdev/librnxengine/issues)
/// - **Discussions**: [GitHub Discussions](https://github.com/neuxdotdev/librnxengine/discussions)
/// - **Security Issues**: security@neuxdotdev.my.id
///
/// ## Versioning
///
/// Follows [Semantic Versioning 2.0.0](https://semver.org/):
///
/// - **MAJOR**: Incompatible API changes
/// - **MINOR**: Backward-compatible new functionality
/// - **PATCH**: Backward-compatible bug fixes
///
/// ## Acknowledgments
///
/// - The Rust Crypto team for excellent cryptographic primitives
/// - The Tokio team for async runtime foundations
/// - All contributors and users of the library
///
/// ## See Also
///
/// - [crates.io/crates/librnxengine](https://crates.io/crates/librnxengine)
/// - [API Reference](https://docs.rs/librnxengine/latest/librnxengine/)
/// - [Examples](https://github.com/neuxdotdev/librnxengine/tree/main/examples)
/// - [Changelog](https://github.com/neuxdotdev/librnxengine/blob/main/CHANGELOG.md)
///
// ============================================================================
// Module Declarations
// ============================================================================
/// License activation structures and server communication protocols.
///
/// Contains request/response types for license activation flows including
/// hardware binding, token management, and activation records.
/// HTTP client for remote license server operations.
///
/// Provides async methods for license activation, validation, and revocation
/// checking against a remote license management server.
/// Cryptographic primitives for license signing and verification.
///
/// Implements Ed25519 key generation, signing, verification, and secure
/// key management with automatic memory zeroization.
/// Core license engine for creation, validation, and management.
///
/// Main entry point for license operations. Handles cryptographic signing,
/// content validation, serialization, and configuration-based validation rules.
/// Comprehensive error types for all license operations.
///
/// Defines detailed error variants for cryptographic failures, validation
/// errors, network issues, and license-specific error conditions.
/// Hardware fingerprint generation for device identification.
///
/// Platform-specific hardware information collection and unique fingerprint
/// generation for license binding and anti-piracy measures.
/// License data structures and serialization formats.
///
/// Core license data types including payloads, complete licenses, and
/// structured feature definitions with serialization support.
/// Validation logic and result reporting.
///
/// Lightweight validation components for runtime license checking with
/// configurable validation rules and detailed result reporting.
// ============================================================================
// Re-exports for Convenient Library Usage
// ============================================================================
/// Re-exports activation request and response types.
///
/// Use these types to communicate with license servers for activation flows.
pub use crate;
/// Re-exports the HTTP client for remote license operations.
///
/// Use `LicenseClient` to interact with license management servers over HTTP.
pub use crateLicenseClient;
/// Re-exports cryptographic key pair structure.
///
/// Use `KeyPair` for generating and managing cryptographic keys for
/// license signing and verification.
pub use crateKeyPair;
/// Re-exports the core license engine.
///
/// Use `LicenseEngine` as the primary interface for license creation,
/// validation, and management operations.
pub use crateLicenseEngine;
/// Re-exports comprehensive error enumeration.
///
/// Use `LicenseError` for error handling across all license operations.
pub use crateLicenseError;
/// Re-exports hardware fingerprint generator.
///
/// Use `HardwareFingerprint` to generate unique device identifiers for
/// license binding and activation.
pub use crateHardwareFingerprint;
/// Re-exports license data structures.
///
/// Use `License`, `LicenseFeatures`, and `LicensePayload` to work with
/// license data at different levels of abstraction.
pub use crate;
/// Re-exports validation components.
///
/// Use `LicenseValidator` and `ValidationResult` for runtime license
/// validation with configurable rules and detailed reporting.
pub use crate;
/// Re-exports chrono types for convenient date/time handling.
///
/// Provides `DateTime<Utc>` for working with timestamps in license operations.
pub use ;
/// Re-exports UUID type for identifier generation.
///
/// Provides `Uuid` for generating and working with unique identifiers
/// in license systems.
pub use Uuid;
// ============================================================================
// Library-Level Configuration and Constants
// ============================================================================
/// Current version of the librnxengine library.
///
/// Follows semantic versioning (MAJOR.MINOR.PATCH). This constant is used
/// internally and can be used by dependents to check library version.
pub const LIBRARY_VERSION: &str = env!;
/// Minimum supported Rust version (MSRV).
///
/// The library guarantees compatibility with this Rust version and newer.
/// Breaking changes to MSRV will result in a MAJOR version bump.
pub const MSRV: &str = "1.70.0";
/// Default license file extension.
///
/// The recommended file extension for license files saved to disk.
pub const DEFAULT_LICENSE_EXTENSION: &str = ".license.json";
/// Default public key file extension.
///
/// The recommended file extension for public key files saved to disk.
pub const DEFAULT_PUBKEY_EXTENSION: &str = ".pubkey.json";
/// Maximum license size in bytes.
///
/// Licenses larger than this will be rejected to prevent denial of service
/// attacks via extremely large license files.
pub const MAX_LICENSE_SIZE: usize = 1024 * 1024; // 1 MB
/// Supported signature algorithms.
///
/// List of cryptographic algorithms supported for license signing.
/// Currently only Ed25519 is supported, but this may expand in future versions.
pub const SUPPORTED_ALGORITHMS: & = &;
/// Default license server API path prefix.
///
/// The standard API path prefix used by license servers. Used internally
/// by `LicenseClient` when constructing URLs.
pub const DEFAULT_API_PATH_PREFIX: &str = "/api/v1/licenses";
// ============================================================================
// Pre-defined License Configurations
// ============================================================================
/// Returns a strict license configuration for high-security applications.
///
/// This configuration enforces:
/// - Online validation only (no offline mode)
/// - No grace period (immediate expiration enforcement)
/// - Strict clock synchronization requirements
/// - Hardware binding enforcement
/// - Revocation checking enabled
///
/// # Example
/// ```rust
/// use librnxengine::engine::LicenseConfig;
///
/// let config = strict_license_config();
/// let engine = LicenseEngine::new(config);
/// ```
/// Returns a flexible license configuration for user-friendly applications.
///
/// This configuration provides:
/// - Offline validation allowed
/// - Generous grace period for renewals
/// - Lenient clock synchronization
/// - Optional hardware binding
/// - Basic revocation checking
///
/// # Example
/// ```rust
/// use librnxengine::engine::LicenseConfig;
///
/// let config = flexible_license_config();
/// let engine = LicenseEngine::new(config);
/// ```
/// Returns a development/testing license configuration.
///
/// This configuration is suitable for development and testing:
/// - Allows all validation modes
/// - Extended grace periods
/// - Very lenient clock requirements
/// - No hardware binding
/// - No revocation checks
///
/// # Warning
/// Do not use this configuration in production!
///
/// # Example
/// ```rust
/// use librnxengine::engine::LicenseConfig;
///
/// let config = development_license_config();
/// let engine = LicenseEngine::new(config);
/// ```
// ============================================================================
// Convenience Functions
// ============================================================================
/// Creates a new license engine with default configuration.
///
/// Shortcut for `LicenseEngine::new(LicenseConfig::default())`.
///
/// # Returns
/// A new `LicenseEngine` instance with sensible default settings.
///
/// # Example
/// ```rust
/// use librnxengine::new_license_engine;
///
/// let engine = new_license_engine();
/// ```
/// Creates a new license client with the specified base URL.
///
/// Shortcut for `LicenseClient::new(base_url)`.
///
/// # Parameters
/// - `base_url`: Base URL of the license management server
///
/// # Returns
/// A new `LicenseClient` instance configured for the specified server.
///
/// # Example
/// ```rust
/// use librnxengine::new_license_client;
///
/// let client = new_license_client("https://license.example.com");
/// ```
/// Generates a new cryptographic key pair.
///
/// Shortcut for creating a key pair with secure random generation.
/// Uses the operating system's cryptographically secure random number generator.
///
/// # Returns
/// A new `KeyPair` suitable for license signing and verification.
///
/// # Example
/// ```rust
/// use librnxengine::generate_keypair;
///
/// let keypair = generate_keypair()?;
/// ```
/// Validates that a license string is properly formatted.
///
/// Performs basic validation on a license JSON string without full
/// cryptographic verification. Useful for quick sanity checks.
///
/// # Parameters
/// - `license_json`: JSON string containing license data
///
/// # Returns
/// - `Ok(())`: License is properly formatted
/// - `Err(LicenseError)`: License has formatting issues
///
/// # Example
/// ```rust
/// use librnxengine::validate_license_format;
///
/// let license_json = std::fs::read_to_string("license.json")?;
/// validate_license_format(&license_json)?;
/// ```
/// Checks if the current system supports hardware fingerprint generation.
///
/// Tests whether the hardware fingerprint generation will work on the
/// current platform and configuration. Useful for feature detection.
///
/// # Returns
/// - `true`: Hardware fingerprint generation is supported
/// - `false`: Hardware fingerprint generation is not available
///
/// # Example
/// ```rust
/// use librnxengine::is_hardware_fingerprint_supported;
///
/// if is_hardware_fingerprint_supported() {
/// println!("Hardware binding is available");
/// } else {
/// println!("Hardware binding is not supported on this system");
/// }
/// ```
// ============================================================================
// Integration Helpers
// ============================================================================
/// Trait for applications to implement custom license storage.
///
/// Implement this trait to provide custom license storage mechanisms
/// (e.g., encrypted files, secure enclaves, cloud storage).
///
/// # Example
/// ```rust
/// use librnxengine::{LicenseStorage, License, LicenseError};
///
/// struct EncryptedFileStorage {
/// path: std::path::PathBuf,
/// encryption_key: [u8; 32],
/// }
///
/// impl LicenseStorage for EncryptedFileStorage {
/// fn save_license(&self, license: &License) -> Result<(), LicenseError> {
/// // Custom encryption logic here
/// Ok(())
/// }
///
/// fn load_license(&self) -> Result<License, LicenseError> {
/// // Custom decryption logic here
/// todo!()
/// }
/// }
/// ```
/// Trait for applications to implement custom license validation hooks.
///
/// Implement this trait to add custom validation logic beyond the
/// standard license validation (e.g., business rules, external checks).
///
/// # Example
/// ```rust
/// use librnxengine::{LicenseValidationHook, License, ValidationResult};
///
/// struct UsageLimitHook {
/// max_usage_hours: u32,
/// usage_tracker: UsageTracker,
/// }
///
/// impl LicenseValidationHook for UsageLimitHook {
/// fn validate(&self, license: &License, base_result: &mut ValidationResult) {
/// let usage_hours = self.usage_tracker.get_usage_hours();
/// if usage_hours > self.max_usage_hours {
/// base_result.add_violation(
/// format!("Usage limit exceeded: {}/{} hours",
/// usage_hours, self.max_usage_hours)
/// );
/// }
/// }
/// }
/// ```
// ============================================================================
// Type Aliases for Common Use Cases
// ============================================================================
/// Alias for license ID type for cleaner code.
///
/// Use `LicenseId` instead of `Uuid` when referring to license identifiers
/// for better code clarity and future-proofing.
pub type LicenseId = Uuid;
/// Alias for activation token type.
///
/// Use `ActivationToken` for strings that contain JWT or similar activation tokens.
pub type ActivationToken = String;
/// Alias for hardware fingerprint type.
///
/// Use `HardwareFingerprintString` for strings that contain hardware fingerprints.
pub type HardwareFingerprintString = String;
/// Alias for feature list type.
///
/// Use `FeatureList` for vectors containing license feature names.
pub type FeatureList = ;
/// Alias for license metadata type.
///
/// Use `LicenseMetadata` for JSON values containing license metadata.
pub type LicenseMetadata = Value;
// ============================================================================
// Deprecation Notices and Compatibility
// ============================================================================
// Note: The following items are kept for backward compatibility.
// They will be removed in a future major version.
pub type LicenseManager = LicenseEngine;
// ============================================================================
// Unit Tests (Example)
// ============================================================================
// ============================================================================
// End of Library Definition
// ============================================================================