Skip to content

Commit 7ca8c9b

Browse files
committed
Major updates
1 parent d8d0632 commit 7ca8c9b

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

licensechain/client.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,22 +437,24 @@ async def delete_license(self, license_id: str) -> Dict[str, Any]:
437437
return await self._delete(f"/licenses/{license_id}")
438438

439439
async def validate_license(
440-
self, license_key: str, app_id: Optional[str] = None
440+
self, license_key: str, app_id: Optional[str] = None, hwuid: Optional[str] = None
441441
) -> Dict[str, Any]:
442442
"""
443443
Validate a license key.
444444
445445
Args:
446446
license_key: License key to validate
447447
app_id: Application ID for validation (optional)
448+
hwuid: Optional hardware/device ID for ecosystem HMAC/HWUID contract
448449
449450
Returns:
450451
License validation result
451452
"""
452-
# Use /licenses/verify endpoint with 'key' parameter to match API
453-
payload = {"key": license_key}
453+
payload: Dict[str, Any] = {"key": license_key}
454454
if app_id:
455455
payload["app_id"] = app_id
456+
if hwuid and hwuid.strip():
457+
payload["hwuid"] = hwuid.strip()
456458
return await self._post("/licenses/verify", payload)
457459

458460
async def revoke_license(

licensechain/services/license_service.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,13 @@ def revoke(self, license_id: str) -> bool:
5050
self.api_client.delete(f'/licenses/{license_id}')
5151
return True
5252

53-
def validate(self, license_key: str) -> bool:
54-
"""Validate a license key."""
53+
def validate(self, license_key: str, hwuid: Optional[str] = None) -> bool:
54+
"""Validate a license key. Optional hwuid for ecosystem HMAC/HWUID contract."""
5555
validate_not_empty(license_key, 'license_key')
56-
57-
# Use /licenses/verify endpoint with 'key' parameter to match API
58-
response = self.api_client.post('/licenses/verify', {'key': license_key})
56+
payload: Dict[str, Any] = {'key': license_key}
57+
if hwuid and hwuid.strip():
58+
payload['hwuid'] = hwuid.strip()
59+
response = self.api_client.post('/licenses/verify', payload)
5960
return response.get('valid', False)
6061

6162
def list_user_licenses(self, user_id: str, page: Optional[int] = None, limit: Optional[int] = None) -> Dict[str, Any]:

0 commit comments

Comments
 (0)