sunlicense 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Hapangama
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,102 @@
1
+ Metadata-Version: 2.4
2
+ Name: sunlicense
3
+ Version: 0.0.1
4
+ Summary: Official SunLicense client for Python — licence key management and validation for indie software developers.
5
+ Author-email: Hapangama <kasun@hapangama.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://sunlicense.com
8
+ Project-URL: Documentation, https://docs.sunlicense.hapangama.com
9
+ Project-URL: Repository, https://github.com/sunlicense-com/sunlicense-py
10
+ Project-URL: Issues, https://github.com/sunlicense-com/sunlicense-py/issues
11
+ Keywords: license,licence,licensing,license-key,activation,drm,anti-piracy,sunlicense
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.8
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Classifier: Topic :: Security
24
+ Requires-Python: >=3.8
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Dynamic: license-file
28
+
29
+ # SunLicense — Python Client
30
+
31
+ Official Python client for [SunLicense](https://sunlicense.com), a licence management and
32
+ anti-piracy system for indie software developers.
33
+
34
+ SunLicense issues, validates and revokes licence keys for Minecraft plugins, Discord bots,
35
+ FiveM scripts, desktop apps and other paid software — with marketplace automation for
36
+ BuiltByBit and Polymart.
37
+
38
+ > **Early release.** Licence validation works today. The wider client surface — activations,
39
+ > entitlements and offline verification — is in active development.
40
+
41
+ ## Install
42
+
43
+ ```bash
44
+ pip install sunlicense
45
+ ```
46
+
47
+ No dependencies — standard library only.
48
+
49
+ ## Usage
50
+
51
+ ```python
52
+ from sunlicense import SunLicense
53
+
54
+ client = SunLicense(
55
+ base_url="https://your-instance.example.com",
56
+ token="optional-api-token",
57
+ )
58
+
59
+ result = client.validate("LICENCE-KEY-HERE")
60
+
61
+ if result.valid:
62
+ print("Licence is valid")
63
+ else:
64
+ print("Rejected:", result.status, result.data)
65
+ ```
66
+
67
+ Pass extra context as keyword arguments:
68
+
69
+ ```python
70
+ result = client.validate("LICENCE-KEY-HERE", product="my-plugin", host="server-01")
71
+ ```
72
+
73
+ ### `SunLicense(...)`
74
+
75
+ | Argument | Type | Default | Description |
76
+ |---|---|---|---|
77
+ | `base_url` | `str` | — | **Required.** Base URL of your SunLicense instance |
78
+ | `token` | `str` | `None` | API token, if your endpoint requires one |
79
+ | `timeout` | `float` | `10.0` | Request timeout in seconds |
80
+
81
+ ### `validate(license_key, **context) -> ValidationResult`
82
+
83
+ Returns a named tuple with `valid` (`bool`), `status` (`int`) and `data` (parsed JSON or
84
+ `None`).
85
+
86
+ ## Requirements
87
+
88
+ Python 3.8 or newer.
89
+
90
+ ## Other clients
91
+
92
+ SunLicense also provides clients for **Java**, **JavaScript**, **PHP** and **Lua**.
93
+
94
+ ## Links
95
+
96
+ - Website — https://sunlicense.com
97
+ - Documentation — https://docs.sunlicense.hapangama.com
98
+ - Issues — https://github.com/sunlicense-com/sunlicense-py/issues
99
+
100
+ ## Licence
101
+
102
+ MIT © Hapangama
@@ -0,0 +1,74 @@
1
+ # SunLicense — Python Client
2
+
3
+ Official Python client for [SunLicense](https://sunlicense.com), a licence management and
4
+ anti-piracy system for indie software developers.
5
+
6
+ SunLicense issues, validates and revokes licence keys for Minecraft plugins, Discord bots,
7
+ FiveM scripts, desktop apps and other paid software — with marketplace automation for
8
+ BuiltByBit and Polymart.
9
+
10
+ > **Early release.** Licence validation works today. The wider client surface — activations,
11
+ > entitlements and offline verification — is in active development.
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ pip install sunlicense
17
+ ```
18
+
19
+ No dependencies — standard library only.
20
+
21
+ ## Usage
22
+
23
+ ```python
24
+ from sunlicense import SunLicense
25
+
26
+ client = SunLicense(
27
+ base_url="https://your-instance.example.com",
28
+ token="optional-api-token",
29
+ )
30
+
31
+ result = client.validate("LICENCE-KEY-HERE")
32
+
33
+ if result.valid:
34
+ print("Licence is valid")
35
+ else:
36
+ print("Rejected:", result.status, result.data)
37
+ ```
38
+
39
+ Pass extra context as keyword arguments:
40
+
41
+ ```python
42
+ result = client.validate("LICENCE-KEY-HERE", product="my-plugin", host="server-01")
43
+ ```
44
+
45
+ ### `SunLicense(...)`
46
+
47
+ | Argument | Type | Default | Description |
48
+ |---|---|---|---|
49
+ | `base_url` | `str` | — | **Required.** Base URL of your SunLicense instance |
50
+ | `token` | `str` | `None` | API token, if your endpoint requires one |
51
+ | `timeout` | `float` | `10.0` | Request timeout in seconds |
52
+
53
+ ### `validate(license_key, **context) -> ValidationResult`
54
+
55
+ Returns a named tuple with `valid` (`bool`), `status` (`int`) and `data` (parsed JSON or
56
+ `None`).
57
+
58
+ ## Requirements
59
+
60
+ Python 3.8 or newer.
61
+
62
+ ## Other clients
63
+
64
+ SunLicense also provides clients for **Java**, **JavaScript**, **PHP** and **Lua**.
65
+
66
+ ## Links
67
+
68
+ - Website — https://sunlicense.com
69
+ - Documentation — https://docs.sunlicense.hapangama.com
70
+ - Issues — https://github.com/sunlicense-com/sunlicense-py/issues
71
+
72
+ ## Licence
73
+
74
+ MIT © Hapangama
@@ -0,0 +1,46 @@
1
+ [project]
2
+ name = "sunlicense"
3
+ version = "0.0.1"
4
+ description = "Official SunLicense client for Python — licence key management and validation for indie software developers."
5
+ readme = "README.md"
6
+ requires-python = ">=3.8"
7
+ license = { text = "MIT" }
8
+ authors = [{ name = "Hapangama", email = "kasun@hapangama.com" }]
9
+ keywords = [
10
+ "license",
11
+ "licence",
12
+ "licensing",
13
+ "license-key",
14
+ "activation",
15
+ "drm",
16
+ "anti-piracy",
17
+ "sunlicense",
18
+ ]
19
+ classifiers = [
20
+ "Development Status :: 3 - Alpha",
21
+ "Intended Audience :: Developers",
22
+ "License :: OSI Approved :: MIT License",
23
+ "Operating System :: OS Independent",
24
+ "Programming Language :: Python :: 3",
25
+ "Programming Language :: Python :: 3.8",
26
+ "Programming Language :: Python :: 3.9",
27
+ "Programming Language :: Python :: 3.10",
28
+ "Programming Language :: Python :: 3.11",
29
+ "Programming Language :: Python :: 3.12",
30
+ "Topic :: Software Development :: Libraries :: Python Modules",
31
+ "Topic :: Security",
32
+ ]
33
+ dependencies = []
34
+
35
+ [project.urls]
36
+ Homepage = "https://sunlicense.com"
37
+ Documentation = "https://docs.sunlicense.hapangama.com"
38
+ Repository = "https://github.com/sunlicense-com/sunlicense-py"
39
+ Issues = "https://github.com/sunlicense-com/sunlicense-py/issues"
40
+
41
+ [build-system]
42
+ requires = ["setuptools>=61"]
43
+ build-backend = "setuptools.build_meta"
44
+
45
+ [tool.setuptools.packages.find]
46
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,107 @@
1
+ """SunLicense — official Python client.
2
+
3
+ Early release. Licence validation works against the SunLicense REST API; the wider
4
+ client surface (activations, entitlements, offline verification) is in development.
5
+
6
+ Docs: https://docs.sunlicense.hapangama.com
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import json
12
+ import urllib.error
13
+ import urllib.request
14
+ from typing import Any, Dict, NamedTuple, Optional
15
+
16
+ __version__ = "0.0.1"
17
+ __all__ = ["SunLicense", "ValidationResult", "__version__"]
18
+
19
+
20
+ class ValidationResult(NamedTuple):
21
+ """Outcome of a licence validation call."""
22
+
23
+ valid: bool
24
+ status: int
25
+ data: Optional[Any]
26
+
27
+
28
+ class SunLicense:
29
+ """A SunLicense API client.
30
+
31
+ Example:
32
+ >>> client = SunLicense(base_url="https://your-instance.example.com")
33
+ >>> result = client.validate("LICENCE-KEY-HERE")
34
+ >>> if result.valid:
35
+ ... print("ok")
36
+ """
37
+
38
+ def __init__(
39
+ self,
40
+ base_url: str,
41
+ token: Optional[str] = None,
42
+ timeout: float = 10.0,
43
+ ) -> None:
44
+ """
45
+ Args:
46
+ base_url: Base URL of your SunLicense instance.
47
+ token: API token, if your endpoint requires one.
48
+ timeout: Request timeout in seconds.
49
+ """
50
+ if not base_url:
51
+ raise ValueError('SunLicense: "base_url" is required')
52
+ self.base_url = base_url.rstrip("/")
53
+ self.token = token
54
+ self.timeout = timeout
55
+
56
+ def validate(
57
+ self,
58
+ license_key: str,
59
+ **context: Any,
60
+ ) -> ValidationResult:
61
+ """Validate a licence key.
62
+
63
+ Args:
64
+ license_key: The licence key to check.
65
+ **context: Optional extra fields, e.g. ``product=...``, ``host=...``.
66
+
67
+ Returns:
68
+ A :class:`ValidationResult`.
69
+
70
+ Raises:
71
+ ValueError: If ``license_key`` is empty.
72
+ urllib.error.URLError: On network failure.
73
+ """
74
+ if not license_key:
75
+ raise ValueError('SunLicense: "license_key" is required')
76
+
77
+ payload: Dict[str, Any] = {"license": license_key, **context}
78
+ headers = {"Content-Type": "application/json"}
79
+ if self.token:
80
+ headers["Authorization"] = "Bearer " + self.token
81
+
82
+ request = urllib.request.Request(
83
+ self.base_url + "/api/v2/license/validate",
84
+ data=json.dumps(payload).encode("utf-8"),
85
+ headers=headers,
86
+ method="POST",
87
+ )
88
+
89
+ try:
90
+ with urllib.request.urlopen(request, timeout=self.timeout) as response:
91
+ body = response.read().decode("utf-8", errors="replace")
92
+ return ValidationResult(
93
+ valid=200 <= response.status < 300,
94
+ status=response.status,
95
+ data=_maybe_json(body),
96
+ )
97
+ except urllib.error.HTTPError as error:
98
+ body = error.read().decode("utf-8", errors="replace")
99
+ return ValidationResult(valid=False, status=error.code, data=_maybe_json(body))
100
+
101
+
102
+ def _maybe_json(body: str) -> Optional[Any]:
103
+ """Parse *body* as JSON, returning None when it isn't valid JSON."""
104
+ try:
105
+ return json.loads(body)
106
+ except ValueError:
107
+ return None
@@ -0,0 +1,102 @@
1
+ Metadata-Version: 2.4
2
+ Name: sunlicense
3
+ Version: 0.0.1
4
+ Summary: Official SunLicense client for Python — licence key management and validation for indie software developers.
5
+ Author-email: Hapangama <kasun@hapangama.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://sunlicense.com
8
+ Project-URL: Documentation, https://docs.sunlicense.hapangama.com
9
+ Project-URL: Repository, https://github.com/sunlicense-com/sunlicense-py
10
+ Project-URL: Issues, https://github.com/sunlicense-com/sunlicense-py/issues
11
+ Keywords: license,licence,licensing,license-key,activation,drm,anti-piracy,sunlicense
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.8
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Classifier: Topic :: Security
24
+ Requires-Python: >=3.8
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Dynamic: license-file
28
+
29
+ # SunLicense — Python Client
30
+
31
+ Official Python client for [SunLicense](https://sunlicense.com), a licence management and
32
+ anti-piracy system for indie software developers.
33
+
34
+ SunLicense issues, validates and revokes licence keys for Minecraft plugins, Discord bots,
35
+ FiveM scripts, desktop apps and other paid software — with marketplace automation for
36
+ BuiltByBit and Polymart.
37
+
38
+ > **Early release.** Licence validation works today. The wider client surface — activations,
39
+ > entitlements and offline verification — is in active development.
40
+
41
+ ## Install
42
+
43
+ ```bash
44
+ pip install sunlicense
45
+ ```
46
+
47
+ No dependencies — standard library only.
48
+
49
+ ## Usage
50
+
51
+ ```python
52
+ from sunlicense import SunLicense
53
+
54
+ client = SunLicense(
55
+ base_url="https://your-instance.example.com",
56
+ token="optional-api-token",
57
+ )
58
+
59
+ result = client.validate("LICENCE-KEY-HERE")
60
+
61
+ if result.valid:
62
+ print("Licence is valid")
63
+ else:
64
+ print("Rejected:", result.status, result.data)
65
+ ```
66
+
67
+ Pass extra context as keyword arguments:
68
+
69
+ ```python
70
+ result = client.validate("LICENCE-KEY-HERE", product="my-plugin", host="server-01")
71
+ ```
72
+
73
+ ### `SunLicense(...)`
74
+
75
+ | Argument | Type | Default | Description |
76
+ |---|---|---|---|
77
+ | `base_url` | `str` | — | **Required.** Base URL of your SunLicense instance |
78
+ | `token` | `str` | `None` | API token, if your endpoint requires one |
79
+ | `timeout` | `float` | `10.0` | Request timeout in seconds |
80
+
81
+ ### `validate(license_key, **context) -> ValidationResult`
82
+
83
+ Returns a named tuple with `valid` (`bool`), `status` (`int`) and `data` (parsed JSON or
84
+ `None`).
85
+
86
+ ## Requirements
87
+
88
+ Python 3.8 or newer.
89
+
90
+ ## Other clients
91
+
92
+ SunLicense also provides clients for **Java**, **JavaScript**, **PHP** and **Lua**.
93
+
94
+ ## Links
95
+
96
+ - Website — https://sunlicense.com
97
+ - Documentation — https://docs.sunlicense.hapangama.com
98
+ - Issues — https://github.com/sunlicense-com/sunlicense-py/issues
99
+
100
+ ## Licence
101
+
102
+ MIT © Hapangama
@@ -0,0 +1,8 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/sunlicense/__init__.py
5
+ src/sunlicense.egg-info/PKG-INFO
6
+ src/sunlicense.egg-info/SOURCES.txt
7
+ src/sunlicense.egg-info/dependency_links.txt
8
+ src/sunlicense.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ sunlicense