monemee 0.1.0__py3-none-any.whl

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.
monemee/__init__.py ADDED
@@ -0,0 +1,23 @@
1
+ """Monemee für Python.
2
+
3
+ Download-Software (CLI, Desktop):
4
+
5
+ from monemee import License
6
+ lic = License(product_id=123)
7
+ lic.activate("MM-XXXX-XXXX-XXXX-XXXX") # einmal
8
+ if lic.check().valid: ... # bei jedem Start, offline bis grace_days
9
+
10
+ Web-App mit Login (Flask, FastAPI, Django):
11
+
12
+ from monemee import App
13
+ monemee = App() # liest MONEMEE_APP_SECRET
14
+ monemee.has_access(user_id)
15
+ monemee.buy_url(user_id)
16
+ """
17
+ from ._errors import MonemeeError
18
+ from .license import License, LicenseResult
19
+ from .app import App, AccessResult
20
+ from .webhook import verify_webhook
21
+
22
+ __all__ = ["License", "LicenseResult", "App", "AccessResult", "verify_webhook", "MonemeeError"]
23
+ __version__ = "0.1.0"
monemee/_errors.py ADDED
@@ -0,0 +1,7 @@
1
+ class MonemeeError(Exception):
2
+ """Fehler bei der Kommunikation mit Monemee oder in der Konfiguration."""
3
+
4
+ def __init__(self, message, code=None, status=None):
5
+ super().__init__(message)
6
+ self.code = code
7
+ self.status = status
monemee/_http.py ADDED
@@ -0,0 +1,30 @@
1
+ import json
2
+ import urllib.error
3
+ import urllib.request
4
+
5
+ from ._errors import MonemeeError
6
+
7
+ USER_AGENT = "monemee-python/0.1.0"
8
+
9
+
10
+ def request(method, url, body=None, token=None, timeout=8):
11
+ """JSON-Request mit der Standardbibliothek. Gibt das geparste JSON zurück."""
12
+ data = json.dumps(body).encode("utf-8") if body is not None else None
13
+ req = urllib.request.Request(url, data=data, method=method)
14
+ req.add_header("Accept", "application/json")
15
+ req.add_header("User-Agent", USER_AGENT)
16
+ if data is not None:
17
+ req.add_header("Content-Type", "application/json")
18
+ if token:
19
+ req.add_header("Authorization", "Bearer " + token)
20
+ try:
21
+ with urllib.request.urlopen(req, timeout=timeout) as res:
22
+ return json.loads(res.read().decode("utf-8") or "null")
23
+ except urllib.error.HTTPError as err:
24
+ try:
25
+ payload = json.loads(err.read().decode("utf-8"))
26
+ except Exception:
27
+ payload = {}
28
+ raise MonemeeError(payload.get("message") or "HTTP %s" % err.code, code=payload.get("code") or "SERVER", status=err.code)
29
+ except (urllib.error.URLError, TimeoutError, OSError) as err:
30
+ raise MonemeeError("Monemee nicht erreichbar (%s)" % getattr(err, "reason", err), code="NETWORK")
monemee/app.py ADDED
@@ -0,0 +1,115 @@
1
+ """Zugang für Web-Apps mit Login (Flask, FastAPI, Django …)."""
2
+ import os
3
+ import re
4
+ import threading
5
+ import time
6
+ from dataclasses import dataclass
7
+ from typing import Optional
8
+ from urllib.parse import urlencode
9
+
10
+ from ._errors import MonemeeError
11
+ from . import _http
12
+ from .webhook import verify_webhook
13
+
14
+ SECRET_RE = re.compile(r"^mmapp_(test|live)_[0-9A-Za-z]{32}$")
15
+ REF_RE = re.compile(r"^[A-Za-z0-9._:@-]{1,128}$")
16
+ CACHE_EVENTS = {"license.created", "license.revoked", "license.activated", "sale.completed"}
17
+
18
+
19
+ @dataclass
20
+ class AccessResult:
21
+ access: bool
22
+ reason: Optional[str] = None
23
+ plan: Optional[str] = None
24
+ expires_at: Optional[str] = None
25
+ test: bool = False
26
+
27
+
28
+ class App:
29
+ """App(app_secret=None, product_id=None, webhook_secret=None, cache_seconds=300)
30
+
31
+ Werte kommen standardmäßig aus MONEMEE_APP_SECRET, MONEMEE_PRODUCT_ID,
32
+ MONEMEE_WEBHOOK_SECRET, MONEMEE_BASE_URL.
33
+ """
34
+
35
+ def __init__(self, app_secret=None, product_id=None, webhook_secret=None, base_url=None, cache_seconds=300, timeout=8):
36
+ self.app_secret = app_secret or os.environ.get("MONEMEE_APP_SECRET", "")
37
+ if not SECRET_RE.match(self.app_secret):
38
+ raise MonemeeError("MONEMEE_APP_SECRET fehlt oder ist ungültig (npx monemee init oder Dashboard → App-Anbindung)", code="CONFIG")
39
+ self.mode = "test" if self.app_secret.startswith("mmapp_test_") else "live"
40
+ self.product_id = product_id or os.environ.get("MONEMEE_PRODUCT_ID")
41
+ self.webhook_secret = webhook_secret or os.environ.get("MONEMEE_WEBHOOK_SECRET")
42
+ self.base_url = (base_url or os.environ.get("MONEMEE_BASE_URL") or "https://monemee.com").rstrip("/")
43
+ self.cache_seconds = cache_seconds
44
+ self.timeout = timeout
45
+ self._cache = {}
46
+ self._lock = threading.Lock()
47
+
48
+ def _api(self, method, path, body=None):
49
+ res = _http.request(method, "%s/api/v1/apps%s" % (self.base_url, path), body, token=self.app_secret, timeout=self.timeout)
50
+ return (res or {}).get("data") or {}
51
+
52
+ @staticmethod
53
+ def _ref(ref):
54
+ ref = str(ref).strip() if ref is not None else ""
55
+ if not REF_RE.match(ref):
56
+ raise MonemeeError("ref muss eine Nutzer-ID sein (max. 128 Zeichen aus A-Z a-z 0-9 . _ : @ -)", code="INVALID_REF")
57
+ return ref
58
+
59
+ @staticmethod
60
+ def _result(d):
61
+ return AccessResult(access=bool(d.get("access")), reason=d.get("reason"), plan=d.get("plan"),
62
+ expires_at=d.get("expires_at"), test=bool(d.get("test")))
63
+
64
+ def access(self, ref):
65
+ ref = self._ref(ref)
66
+ with self._lock:
67
+ hit = self._cache.get(ref)
68
+ if hit and hit[1] > time.time():
69
+ return hit[0]
70
+ result = self._result(self._api("POST", "/access", {"ref": ref}))
71
+ if self.cache_seconds > 0:
72
+ with self._lock:
73
+ self._cache[ref] = (result, time.time() + self.cache_seconds)
74
+ return result
75
+
76
+ def has_access(self, ref):
77
+ return self.access(ref).access
78
+
79
+ def unlock(self, ref, claim=None, key=None):
80
+ """Rücksprung-Token (?monemee_claim=…) oder Lizenzschlüssel einlösen und an ref binden."""
81
+ ref = self._ref(ref)
82
+ if not claim and not key:
83
+ raise MonemeeError("claim oder key ist erforderlich", code="INVALID_INPUT")
84
+ body = {"ref": ref}
85
+ if claim:
86
+ body["claim"] = claim
87
+ else:
88
+ body["key"] = key
89
+ result = self._result(self._api("POST", "/claim", body))
90
+ with self._lock:
91
+ self._cache.pop(ref, None)
92
+ return result
93
+
94
+ def buy_url(self, ref=None):
95
+ if not self.product_id:
96
+ self.product_id = self._api("GET", "/me").get("product_id")
97
+ url = "%s/buy/%s" % (self.base_url, self.product_id)
98
+ return url + ("?" + urlencode({"ref": self._ref(ref)}) if ref not in (None, "") else "")
99
+
100
+ def test_buy_url(self, ref, return_url=None):
101
+ if self.mode != "test":
102
+ raise MonemeeError("Testkäufe gehen nur mit einem Test-Secret (mmapp_test_…)", code="TEST_ONLY")
103
+ body = {"ref": self._ref(ref)}
104
+ if return_url:
105
+ body["return_url"] = return_url
106
+ return self._api("POST", "/test-claim", body).get("redirectUrl")
107
+
108
+ def handle_webhook(self, raw_body, signature_header):
109
+ """Signatur prüfen (roher Body!), Cache leeren. Gibt das Event zurück; ValueError bei falscher Signatur."""
110
+ event = verify_webhook(raw_body, signature_header, self.webhook_secret)
111
+ ref = (event.get("data") or {}).get("external_ref")
112
+ if ref and event.get("event") in CACHE_EVENTS:
113
+ with self._lock:
114
+ self._cache.pop(ref, None)
115
+ return event
monemee/license.py ADDED
@@ -0,0 +1,241 @@
1
+ """Lizenzschlüssel für Download-Software (CLI, Desktop, Skripte)."""
2
+ import base64
3
+ import hashlib
4
+ import json
5
+ import os
6
+ import re
7
+ import secrets
8
+ import time
9
+ from dataclasses import dataclass, field
10
+ from datetime import datetime, timezone
11
+ from pathlib import Path
12
+ from typing import Optional
13
+
14
+ from ._errors import MonemeeError
15
+ from . import _http
16
+
17
+ KEY_RE = re.compile(r"^MM(-[A-Z0-9]{4}){4}$")
18
+ STORE_VERSION = 1
19
+ # Public signing keys of monemee.com (also at /.well-known/monemee-license-keys.json).
20
+ # Unknown key IDs (after a key rotation) are fetched on the next online check.
21
+ BUNDLED_PUBLIC_KEYS = [
22
+ {"kid": "mm-1", "kty": "OKP", "crv": "Ed25519", "x": "-dEgFSZLvP66Cqh_ksHi4rfOJoR2IKp8k3s9LBtUMgM"},
23
+ ]
24
+
25
+
26
+ @dataclass
27
+ class LicenseResult:
28
+ valid: bool
29
+ reason: Optional[str] = None
30
+ plan: Optional[str] = None
31
+ expires_at: Optional[str] = None
32
+ test: bool = False
33
+ offline: bool = False
34
+ activations: Optional[dict] = field(default=None)
35
+
36
+
37
+ def _default_dir(app_name):
38
+ if os.name == "nt":
39
+ base = Path(os.environ.get("APPDATA", Path.home()))
40
+ else:
41
+ base = Path(os.environ.get("XDG_CONFIG_HOME", Path.home() / ".config"))
42
+ return base / app_name
43
+
44
+
45
+ def _parse_time(value):
46
+ if not value:
47
+ return None
48
+ return datetime.fromisoformat(value.replace("Z", "+00:00")).timestamp()
49
+
50
+
51
+ def _b64url(data):
52
+ return base64.urlsafe_b64decode(data + "=" * (-len(data) % 4))
53
+
54
+
55
+ def verify_signed(signed, public_keys):
56
+ """Prüft signed["signature"] über den exakten String signed["payload"]. Payload-Dict oder None."""
57
+ if not isinstance(signed, dict) or not isinstance(signed.get("payload"), str):
58
+ return None
59
+ jwk = next((k for k in public_keys or [] if k.get("kid") == signed.get("kid")), None)
60
+ if not jwk:
61
+ return None
62
+ try:
63
+ from cryptography.exceptions import InvalidSignature
64
+ from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PublicKey
65
+ except ImportError:
66
+ return None # pip install "monemee[offline]" für Offline-Prüfung
67
+ try:
68
+ Ed25519PublicKey.from_public_bytes(_b64url(jwk["x"])).verify(_b64url(signed["signature"]), signed["payload"].encode("utf-8"))
69
+ return json.loads(signed["payload"])
70
+ except (InvalidSignature, ValueError, KeyError):
71
+ return None
72
+
73
+
74
+ class License:
75
+ """Lizenz eines Produkts auf diesem Gerät.
76
+
77
+ License(product_id=123, grace_days=7, app_name=None, base_url="https://monemee.com")
78
+ """
79
+
80
+ def __init__(self, product_id, base_url=None, grace_days=7, app_name=None, store_dir=None,
81
+ device_id=None, device_name=None, public_keys=None, now=None, timeout=8):
82
+ self.product_id = int(product_id)
83
+ if self.product_id <= 0:
84
+ raise MonemeeError("product_id fehlt", code="CONFIG")
85
+ self.base_url = (base_url or os.environ.get("MONEMEE_BASE_URL") or "https://monemee.com").rstrip("/")
86
+ self.grace_seconds = grace_days * 86400
87
+ self.dir = Path(store_dir) if store_dir else _default_dir(app_name or "monemee-%d" % self.product_id)
88
+ self._device_id = device_id
89
+ self.device_name = device_name
90
+ self._keys = list(public_keys or []) + BUNDLED_PUBLIC_KEYS
91
+ self._now = now or time.time
92
+ self.timeout = timeout
93
+
94
+ # ---------- Speicher ----------
95
+ @property
96
+ def _file(self):
97
+ return self.dir / "license.json"
98
+
99
+ def _load(self):
100
+ try:
101
+ data = json.loads(self._file.read_text("utf-8"))
102
+ return data if isinstance(data, dict) else {}
103
+ except (OSError, ValueError):
104
+ return {}
105
+
106
+ def _save(self, data):
107
+ self.dir.mkdir(parents=True, exist_ok=True)
108
+ tmp = self._file.with_suffix(".tmp")
109
+ tmp.write_text(json.dumps(data), "utf-8")
110
+ try:
111
+ os.chmod(tmp, 0o600)
112
+ except OSError:
113
+ pass
114
+ tmp.replace(self._file)
115
+
116
+ def device_id(self):
117
+ if self._device_id:
118
+ return str(self._device_id)[:128]
119
+ data = self._load()
120
+ if not data.get("device"):
121
+ data["device"] = "d_" + secrets.token_hex(16)
122
+ self._save(data)
123
+ return data["device"]
124
+
125
+ # ---------- Netzwerk ----------
126
+ def _post(self, path, body):
127
+ res = _http.request("POST", "%s/api/v1/licenses/%s" % (self.base_url, path), body, timeout=self.timeout)
128
+ return (res or {}).get("data") or {}
129
+
130
+ def _add_keys(self, keys):
131
+ known = {k.get("kid") for k in self._keys}
132
+ for k in keys or []:
133
+ if isinstance(k, dict) and k.get("kid") and k.get("x") and k["kid"] not in known:
134
+ self._keys.append(k)
135
+ known.add(k["kid"])
136
+
137
+ def _ensure_keys(self, data, kid):
138
+ # Fetch keys only for a key ID we do not know yet (key rotation).
139
+ if any(k.get("kid") == kid for k in self._keys):
140
+ return
141
+ self._add_keys(data.get("keys"))
142
+ if any(k.get("kid") == kid for k in self._keys):
143
+ return
144
+ res = _http.request("GET", "%s/.well-known/monemee-license-keys.json" % self.base_url, timeout=self.timeout)
145
+ fetched = (res or {}).get("keys") or []
146
+ self._add_keys(fetched)
147
+ if fetched:
148
+ data["keys"] = fetched
149
+ self._save(data)
150
+
151
+ def _trusted(self, signed, key, device, max_age, data):
152
+ try:
153
+ self._ensure_keys(data, (signed or {}).get("kid"))
154
+ except MonemeeError:
155
+ pass
156
+ p = verify_signed(signed, self._keys)
157
+ if not p:
158
+ return None
159
+ if p.get("product_id") != self.product_id or p.get("key_sha256") != hashlib.sha256(key.encode()).hexdigest():
160
+ return None
161
+ if p.get("device_id") and p["device_id"] != device:
162
+ return None
163
+ issued = _parse_time(p.get("issued_at"))
164
+ now = self._now()
165
+ if issued is None or issued > now + 300 or now - issued > max_age:
166
+ return None
167
+ expires = _parse_time(p.get("expires_at"))
168
+ if expires is not None and expires < now:
169
+ return dict(p, valid=False, reason="expired")
170
+ return p
171
+
172
+ @staticmethod
173
+ def _result(d, **extra):
174
+ valid = bool(d.get("valid"))
175
+ return LicenseResult(valid=valid, reason=None if valid else d.get("reason"), plan=d.get("plan"),
176
+ expires_at=d.get("expires_at"), test=bool(d.get("test")), **extra)
177
+
178
+ # ---------- Öffentliche API ----------
179
+ def activate(self, key, device_name=None):
180
+ """Schlüssel einmal aktivieren (bindet ihn an dieses Gerät)."""
181
+ key = re.sub(r"\s+", "", str(key or "")).upper()
182
+ if not KEY_RE.match(key):
183
+ raise MonemeeError("Schlüssel im Format MM-XXXX-XXXX-XXXX-XXXX eingeben", code="INVALID_KEY")
184
+ device = self.device_id()
185
+ body = {"key": key, "product_id": self.product_id, "device_id": device}
186
+ if device_name or self.device_name:
187
+ body["device_name"] = device_name or self.device_name
188
+ res = self._post("activate", body)
189
+ if res.get("valid"):
190
+ data = self._load()
191
+ data.update({"v": STORE_VERSION, "key": key, "signed": res.get("signed"), "checked_at": self._now()})
192
+ self._save(data)
193
+ return self._result(res, activations=res.get("activations"))
194
+
195
+ def check(self):
196
+ """Gilt die Lizenz? Online prüfen, ohne Netz gilt die letzte signierte Antwort (grace_days)."""
197
+ data = self._load()
198
+ key = data.get("key")
199
+ if not key:
200
+ return LicenseResult(valid=False, reason="not_activated")
201
+ device = self.device_id()
202
+ try:
203
+ res = self._post("validate", {"key": key, "product_id": self.product_id, "device_id": device})
204
+ except MonemeeError as err:
205
+ if err.code not in ("NETWORK", "SERVER"):
206
+ raise
207
+ p = self._trusted(data.get("signed"), key, device, self.grace_seconds, data) if data.get("signed") else None
208
+ if not p:
209
+ return LicenseResult(valid=False, reason="offline", offline=True)
210
+ return self._result(p, offline=True)
211
+
212
+ if res.get("signed"):
213
+ p = self._trusted(res["signed"], key, device, 600, data)
214
+ if p and bool(p.get("valid")) == bool(res.get("valid")):
215
+ data.update({"signed": res["signed"], "checked_at": self._now()})
216
+ self._save(data)
217
+ elif self._keys:
218
+ return LicenseResult(valid=False, reason="invalid_signature")
219
+ if not res.get("valid") and res.get("reason") in ("revoked", "not_found", "product_mismatch"):
220
+ for k in ("key", "signed", "checked_at"):
221
+ data.pop(k, None)
222
+ self._save(data)
223
+ return self._result(res, activations=res.get("activations"))
224
+
225
+ def deactivate(self):
226
+ """Gerät freigeben und gespeicherten Schlüssel vergessen."""
227
+ data = self._load()
228
+ key = data.get("key")
229
+ if not key:
230
+ return False
231
+ try:
232
+ res = self._post("deactivate", {"key": key, "product_id": self.product_id, "device_id": self.device_id()})
233
+ finally:
234
+ for k in ("key", "signed", "checked_at"):
235
+ data.pop(k, None)
236
+ self._save(data)
237
+ return bool(res.get("deactivated"))
238
+
239
+ @property
240
+ def stored_key(self):
241
+ return self._load().get("key")
monemee/webhook.py ADDED
@@ -0,0 +1,32 @@
1
+ import hashlib
2
+ import hmac
3
+ import json
4
+ import time
5
+
6
+
7
+ def verify_webhook(raw_body, signature_header, secret, tolerance_seconds=300, now=None):
8
+ """Prüft einen Monemee-Webhook und gibt das Event zurück.
9
+
10
+ raw_body: der UNVERÄNDERTE Body (bytes oder str)
11
+ signature_header: Wert von "Monemee-Signature" (t=<unix>,v1=<hex>)
12
+ Wirft ValueError bei fehlender, falscher oder zu alter Signatur.
13
+ """
14
+ if not secret:
15
+ raise ValueError("Webhook-Secret fehlt (MONEMEE_WEBHOOK_SECRET)")
16
+ if not signature_header:
17
+ raise ValueError("Monemee-Signature-Header fehlt")
18
+ parts = dict(p.strip().split("=", 1) for p in signature_header.split(",") if "=" in p)
19
+ try:
20
+ t = int(parts.get("t", ""))
21
+ except ValueError:
22
+ raise ValueError("Signatur hat ein ungültiges Format")
23
+ v1 = parts.get("v1", "")
24
+ if len(v1) != 64:
25
+ raise ValueError("Signatur hat ein ungültiges Format")
26
+ if abs(int(now if now is not None else time.time()) - t) > tolerance_seconds:
27
+ raise ValueError("Signatur ist zu alt")
28
+ body = raw_body.decode("utf-8") if isinstance(raw_body, (bytes, bytearray)) else str(raw_body)
29
+ expected = hmac.new(secret.encode("utf-8"), ("%d.%s" % (t, body)).encode("utf-8"), hashlib.sha256).hexdigest()
30
+ if not hmac.compare_digest(expected, v1):
31
+ raise ValueError("Signatur stimmt nicht")
32
+ return json.loads(body)
@@ -0,0 +1,86 @@
1
+ Metadata-Version: 2.5
2
+ Name: monemee
3
+ Version: 0.1.0
4
+ Summary: License key validation with offline support for Python apps, plus paywall access checks for Flask, FastAPI and Django, powered by Monemee.
5
+ Project-URL: Homepage, https://dev.monemee.com
6
+ Project-URL: Source, https://github.com/monemee/monemee-sdk/tree/main/packages/python
7
+ Project-URL: Issues, https://github.com/monemee/monemee-sdk/issues
8
+ Project-URL: Changelog, https://github.com/monemee/monemee-sdk/blob/main/CHANGELOG.md
9
+ Author-email: Monemee <info@monemee.com>
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: django,ed25519,fastapi,flask,license key,license validation,monemee,offline licensing,paywall,software licensing
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Topic :: Office/Business :: Financial :: Point-Of-Sale
18
+ Classifier: Topic :: Software Development :: Libraries
19
+ Requires-Python: >=3.10
20
+ Provides-Extra: offline
21
+ Requires-Dist: cryptography>=41; extra == 'offline'
22
+ Description-Content-Type: text/markdown
23
+
24
+ # monemee (Python)
25
+
26
+ Sell your Python app through Monemee: license key validation with offline support for CLIs and desktop tools, plus access checks for web apps built with Flask, FastAPI or Django. Standard library only; `cryptography` is optional for offline verification.
27
+
28
+ [Monemee SDK](https://github.com/monemee/monemee-sdk) · [Deutsch](https://github.com/monemee/monemee-sdk/blob/main/README.de.md) · [Documentation](https://dev.monemee.com)
29
+
30
+ ```bash
31
+ pip install "monemee[offline]" # [offline] enables offline verification of signed responses
32
+ ```
33
+
34
+ ## License keys for CLIs and desktop apps
35
+
36
+ ```python
37
+ from monemee import License
38
+
39
+ lic = License(product_id=123)
40
+
41
+ if not lic.stored_key:
42
+ result = lic.activate(input("License key: "))
43
+ if not result.valid:
44
+ raise SystemExit(f"Invalid: {result.reason}")
45
+
46
+ status = lic.check() # online; offline the last check stays valid for grace_days (7)
47
+ if status.valid:
48
+ run_pro(plan=status.plan)
49
+ ```
50
+
51
+ Data is stored in `~/.config/monemee-<id>/license.json` (`%APPDATA%` on Windows). `lic.deactivate()` frees the device slot.
52
+
53
+ ## Web apps with login (Flask, FastAPI, Django)
54
+
55
+ ```python
56
+ from monemee import App
57
+ monemee = App() # reads MONEMEE_APP_SECRET (npx monemee init)
58
+
59
+ # Flask
60
+ @app.get("/pro")
61
+ def pro():
62
+ if not monemee.has_access(current_user.id):
63
+ return redirect(monemee.buy_url(current_user.id))
64
+ return render_template("pro.html")
65
+
66
+ # Return after purchase (set the return URL in Monemee to https://your-app.com/monemee/return)
67
+ @app.get("/monemee/return")
68
+ def monemee_return():
69
+ result = monemee.unlock(current_user.id, claim=request.args["monemee_claim"])
70
+ return redirect("/pro" if result.access else f"/?error={result.reason}")
71
+
72
+ # Webhook (optional, applies refunds instantly)
73
+ @app.post("/monemee/webhook")
74
+ def monemee_webhook():
75
+ try:
76
+ monemee.handle_webhook(request.get_data(), request.headers.get("Monemee-Signature"))
77
+ except ValueError:
78
+ abort(400)
79
+ return "", 204
80
+ ```
81
+
82
+ Free test purchase (with a `mmapp_test_...` secret only): `redirect(monemee.test_buy_url(current_user.id, "http://localhost:5000/monemee/return"))`.
83
+
84
+ Requires Python 3.10 or newer.
85
+
86
+ MIT License
@@ -0,0 +1,10 @@
1
+ monemee/__init__.py,sha256=-fsXwLQoZ--Z616YOk8CyT79DrieR8pvkbOKiPpygJw,748
2
+ monemee/_errors.py,sha256=o4lSFi5CWXWS6TimFMR0Yguv5tr97vL0DK8rHx9R0q0,255
3
+ monemee/_http.py,sha256=jkfchjAmWqhunqIa-kUJneIIILNNmAml8-d9flPQbHY,1272
4
+ monemee/app.py,sha256=Nnp-aQnKkvTEgrK1Fym2JhtOTdNYJ4e020gQueOnyZQ,4758
5
+ monemee/license.py,sha256=eM6r7JqPvZTxNZ02UCBZFZ7_aX10oto8gVPcX-Rg6Jw,9408
6
+ monemee/webhook.py,sha256=Gbahi4ejAPpmHd8xEJyDwoL_trfmH_Sshgxnjb5Sy5E,1396
7
+ monemee-0.1.0.dist-info/METADATA,sha256=FkAQEQnK0_wle80FpWc0IpIqoWaTUElnBDVnSBf5vqo,3360
8
+ monemee-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
9
+ monemee-0.1.0.dist-info/licenses/LICENSE,sha256=Ihl9v08aPvpUIGy1XX-A2wgeZf0jAeyKRe8U_xyPCB8,1064
10
+ monemee-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Monemee
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.