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
use ;
use ;
use Uuid;
/// Core license data payload containing all license information.
///
/// This struct represents the actual data contained within a license,
/// excluding cryptographic signatures and metadata. It's the payload
/// that gets signed during license creation.
///
/// # Fields
/// - `license_id`: Unique identifier for this specific license instance
/// - `customer_id`: Identifier for the customer/organization
/// - `product_id`: Identifier for the licensed product
/// - `expires_at`: Date and time when the license becomes invalid
/// - `issued_at`: Date and time when the license was created
/// - `max_activations`: Maximum number of concurrent device activations allowed
/// - `features`: List of enabled product features
/// - `metadata`: Flexible JSON field for additional custom data
///
/// # Example JSON Representation
/// ```json
/// {
/// "license_id": "123e4567-e89b-12d3-a456-426614174000",
/// "customer_id": "customer-123",
/// "product_id": "product-pro",
/// "expires_at": "2024-12-31T23:59:59Z",
/// "issued_at": "2024-01-01T00:00:00Z",
/// "max_activations": 3,
/// "features": ["premium", "api-access", "support-24/7"],
/// "metadata": {"allowed_ips": ["192.168.1.1"], "version": "2.0"}
/// }
/// ```
/// Complete license structure including cryptographic signature.
///
/// This is the main license object that gets distributed to end-users.
/// It contains both the license data (`payload`) and its digital signature
/// to ensure authenticity and integrity.
///
/// # Fields
/// - `version`: License format version (for backward compatibility)
/// - `payload`: The actual license data (see `LicensePayload`)
/// - `signature`: Cryptographic signature of the serialized payload
/// - `algorithm`: Algorithm used for signing (e.g., "ed25519")
///
/// # Security Notes
/// - The `signature` is computed over the serialized `payload`
/// - The `algorithm` field helps with future cryptographic migrations
/// - Always verify the signature before trusting the license data
/// Structured representation of license features with typed values.
///
/// This provides a more structured alternative to the string-based
/// features list in `LicensePayload`. Useful for applications with
/// well-defined feature sets.
///
/// # Fields
/// - `premium`: Whether premium features are enabled
/// - `api_access`: Whether API access is allowed
/// - `max_users`: Maximum number of concurrent users
/// - `custom_domains`: Number of allowed custom domains
/// - `storage_gb`: Amount of storage in gigabytes
/// - `support_level`: Type of support included
/// - `expires_at`: Optional specific expiration for these features
///
/// # Example Usage
/// ```rust
/// let features = LicenseFeatures {
/// premium: true,
/// api_access: true,
/// max_users: 10,
/// custom_domains: 3,
/// storage_gb: 100,
/// support_level: "24/7".to_string(),
/// expires_at: Some(Utc::now() + chrono::Duration::days(365)),
/// };
/// ```
// Note: The `License` struct implements `Serialize` and `Deserialize`
// for easy serialization to/from JSON, CBOR, or other formats.
// This is useful for:
// - Storing licenses in files or databases
// - Transmitting licenses over networks
// - Embedding licenses in configuration files
// Note: The `metadata` field in `LicensePayload` provides flexibility
// for custom extensions without modifying the core structure.
// Common uses include:
// - IP address restrictions
// - Geographic limitations
// - Version constraints
// - Custom business logic flags
// Note: UUIDs are used for identifiers to ensure global uniqueness
// and avoid collisions across distributed systems.
// Note: All timestamps use UTC to avoid timezone confusion
// and ensure consistent validation across different regions.