You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit eaf9044
Browse filesBrowse the repository at this point in the historyBrowse files
Add keymint.offline with verify_offline_license, OfflineLicense,
OfflineLicenseError and OfflineLicenseErrorCode. It verifies a .lic file
or bare Ed25519 JWT against trusted SPKI PEM public keys, following the
shared offline-verifier spec: parse, alg EdDSA with no crit, kid match,
signature, type, product, machine, exp/sub shape, expiry with clock skew.
product_id is required (L-04): one signing key covers all of an org's
products, so skipping the product check would let one product's license
unlock another.
Adds cryptography>=41 as a required dependency. Tests run the 34 shared
fixtures plus argument-error and Python-specific edge cases; CI now runs
every test under tests/. README and CHANGELOG updated.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,12 @@
1
1
# Changelog
2
2
3
+
## Unreleased
4
+
5
+
- Add `verify_offline_license`, which verifies a signed offline license (the `.lic` file from the dashboard or `sign_key`, or the bare token) locally against your Ed25519 public keys, with no network call. It checks the algorithm, key, signature, license type, product ID, machine code and expiry, returns an `OfflineLicense`, and raises `OfflineLicenseError` with a `code` (`malformed`, `unsupported_algorithm`, `unknown_key`, `bad_signature`, `wrong_type`, `wrong_product`, `wrong_machine`, `expired`) on failure.
6
+
-`product_id` is required: one signing key covers every product in an organization, so a verifier that skips the product check would let a license for one product unlock another.
7
+
- New required dependency: `cryptography>=41`, for Ed25519.
8
+
- CI now runs every test under `tests/`, including the shared offline-license test vectors.
9
+
3
10
## 2.6.0 - 2026-10-26
4
11
5
12
- Add `expirationDate` (ISO 8601 string, or `None` when the license never expires) to the `activate_key` and `floating_checkout` response types. On checkout it is separate from `expiresAt`, the seat lease. Additive; no other fields changed.
Copy file name to clipboardExpand all lines: README.md
+76Lines changed: 76 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,7 @@ A professional, production-ready SDK for integrating with the Keymint API in Pyt
6
6
-**Type hints**: Full type hint support for better IDE integration and code safety.
7
7
-**Comprehensive**: Complete API coverage for all Keymint endpoints.
8
8
-**Consistent error handling**: All API errors are returned as structured objects or exceptions.
9
+
-**Offline licenses**: Verify signed `.lic` files locally with `verify_offline_license`.
9
10
-**Machine Identity**: Built-in utilities for hardware fingerprinting and stable installation IDs.
10
11
11
12
## Installation
@@ -66,6 +67,81 @@ else:
66
67
67
68
Store the last `expirationDate` you received. An expired license fails activation with the same generic invalid-key error as a wrong key, so the stored date is how your app can tell the user the license expired on that date instead of calling the key invalid.
68
69
70
+
## Offline Licenses
71
+
72
+
An offline license is a `.lic` file holding a token signed with your organization's Ed25519 key. Your app verifies it locally with `verify_offline_license`, with no network call.
73
+
74
+
1.**Get the `.lic` file** from the dashboard's Offline License dialog, or with `sign_key` from your own backend (it needs an admin API key, so never call it from the shipped app). The `hostId` you sign for becomes the license's machine code, so use the ID the customer's machine reports, e.g. `identity.get_or_create_installation_id()`.
75
+
76
+
```python
77
+
# On your server, with host_id sent by the customer's machine:
78
+
result = sdk.sign_key({'productId': product_id, 'licenseKey': license_key, 'hostId': host_id})
79
+
lic = result['file'] # the .lic contents; deliver this to the customer
80
+
```
81
+
82
+
2.**Bundle your public key** with the app: copy the PEM from **Developer → Public Keys** in the dashboard. It is a public key, so shipping it is safe.
83
+
84
+
3.**Verify** with the product ID and this machine's code:
85
+
86
+
```python
87
+
from keymint import OfflineLicenseError, identity, verify_offline_license
print(f'Licensed until {offline.expires_at:%Y-%m-%d}')
105
+
except OfflineLicenseError as err:
106
+
if err.code =='expired':
107
+
...# ask the customer to renew or reconnect
108
+
elif err.code in ('wrong_product', 'wrong_machine'):
109
+
...# a real license, but not for this product or this machine
110
+
else:
111
+
...# malformed, unsupported_algorithm, unknown_key, bad_signature, wrong_type: not a valid license
112
+
```
113
+
114
+
`verify_offline_license` accepts the `.lic` file contents or the bare token and returns an `OfflineLicense` with `license_key`, `product_id`, `machine_code`, `key_id`, `issued_at` (or `None`) and `expires_at` (timezone-aware UTC datetimes). On failure it raises `OfflineLicenseError`; `err.code` is one of:
115
+
116
+
| Code | Meaning |
117
+
|---|---|
118
+
|`malformed`| Not a license file or token, or required claims (`exp`, `sub`) are missing or invalid. |
119
+
|`unsupported_algorithm`| The token is not signed with EdDSA (e.g. `none`, `HS256`). |
120
+
|`unknown_key`| Signed by a key that isn't in `public_keys`. |
121
+
|`bad_signature`| The signature doesn't match: the file was altered or forged. |
122
+
|`wrong_type`| The token is not an offline license. |
123
+
|`wrong_product`| The license is for a different product. |
124
+
|`wrong_machine`| The license is for a different machine. |
125
+
|`expired`| Past its expiry, plus `clock_skew` (default 60 seconds, max 3600). |
126
+
127
+
Bad arguments (no public keys, a PEM that isn't an Ed25519 public key, an empty `product_id` or `machine_code`, `clock_skew` outside 0..3600, a naive `now`) raise `ValueError` or `TypeError`, not `OfflineLicenseError`.
128
+
129
+
**`product_id` is required.** One signing key covers all of an organization's products, so without the product check a license for a cheap product would unlock an expensive one.
130
+
131
+
**Clock rollback.** The SDK can't tell if the system clock was set back. To guard against it, store the latest time you have trusted (for example, after each successful run) and pass the later of the two as `now`. `now` must be timezone-aware:
132
+
133
+
```python
134
+
from datetime import datetime, timezone
135
+
136
+
now =max(datetime.now(timezone.utc), last_trusted_time)
`public_keys` accepts several keys, so apps are ready for key rotation. An offline license stays valid until it expires; it can't be revoked before then.
142
+
143
+
Offline verification uses the [`cryptography`](https://pypi.org/project/cryptography/) package, which `pip install keymint` installs (`cryptography>=41`).
144
+
69
145
## Machine Identity
70
146
Keymint provides utilities to uniquely identify machines for node-locking:
0 commit comments