Skip to content

Commit 5372664

Browse files
committed
Major updates
1 parent 7ca8c9b commit 5372664

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,3 +1098,19 @@ This project is licensed under the Elastic License 2.0 - see the [LICENSE](LICEN
10981098
---
10991099

11001100
Made with ❤️ by the LicenseChain team
1101+
1102+
## LicenseChain API (v1)
1103+
1104+
This SDK targets the **LicenseChain HTTP API v1** implemented by the open-source API service.
1105+
1106+
- **Production base URL:** https://api.licensechain.app/v1
1107+
- **API repository (source of routes & behavior):** https://github.com/LicenseChain/api
1108+
- **Baseline REST mapping (documented for integrators):**
1109+
- GET /health
1110+
- POST /auth/register
1111+
- POST /licenses/verify
1112+
- PATCH /licenses/:id/revoke
1113+
- PATCH /licenses/:id/activate
1114+
- PATCH /licenses/:id/extend
1115+
- GET /analytics/stats
1116+

licensechain/client.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
import asyncio
88
import json
9+
import hashlib
10+
import platform
11+
import socket
912
from typing import Any, Dict, List, Optional, Union
1013
from urllib.parse import urlencode
1114

@@ -455,8 +458,14 @@ async def validate_license(
455458
payload["app_id"] = app_id
456459
if hwuid and hwuid.strip():
457460
payload["hwuid"] = hwuid.strip()
461+
else:
462+
payload["hwuid"] = self._default_hwuid()
458463
return await self._post("/licenses/verify", payload)
459464

465+
def _default_hwuid(self) -> str:
466+
raw = f"{socket.gethostname()}|{platform.system()}|{platform.machine()}|{platform.version()}"
467+
return hashlib.sha256(raw.encode("utf-8")).hexdigest()
468+
460469
async def revoke_license(
461470
self, license_id: str, reason: Optional[str] = None
462471
) -> Dict[str, Any]:

licensechain/services/license_service.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
from typing import Any, Dict, List, Optional
2+
import hashlib
3+
import platform
4+
import socket
25

36
from ..exceptions import ValidationError
47
from ..utils import validate_uuid, validate_not_empty, sanitize_metadata, validate_pagination
@@ -56,6 +59,9 @@ def validate(self, license_key: str, hwuid: Optional[str] = None) -> bool:
5659
payload: Dict[str, Any] = {'key': license_key}
5760
if hwuid and hwuid.strip():
5861
payload['hwuid'] = hwuid.strip()
62+
else:
63+
raw = f"{socket.gethostname()}|{platform.system()}|{platform.machine()}|{platform.version()}"
64+
payload['hwuid'] = hashlib.sha256(raw.encode("utf-8")).hexdigest()
5965
response = self.api_client.post('/licenses/verify', payload)
6066
return response.get('valid', False)
6167

0 commit comments

Comments
 (0)