setsig-sdk 1.0.0__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.
- setsig_sdk-1.0.0/LICENSE +17 -0
- setsig_sdk-1.0.0/PKG-INFO +145 -0
- setsig_sdk-1.0.0/README.md +122 -0
- setsig_sdk-1.0.0/pyproject.toml +35 -0
- setsig_sdk-1.0.0/setup.cfg +4 -0
- setsig_sdk-1.0.0/src/setsig/__init__.py +71 -0
- setsig_sdk-1.0.0/src/setsig/client.py +555 -0
- setsig_sdk-1.0.0/src/setsig/crypto.py +72 -0
- setsig_sdk-1.0.0/src/setsig/errors.py +108 -0
- setsig_sdk-1.0.0/src/setsig/types.py +175 -0
- setsig_sdk-1.0.0/src/setsig/webhooks.py +88 -0
- setsig_sdk-1.0.0/src/setsig_sdk.egg-info/PKG-INFO +145 -0
- setsig_sdk-1.0.0/src/setsig_sdk.egg-info/SOURCES.txt +15 -0
- setsig_sdk-1.0.0/src/setsig_sdk.egg-info/dependency_links.txt +1 -0
- setsig_sdk-1.0.0/src/setsig_sdk.egg-info/top_level.txt +1 -0
- setsig_sdk-1.0.0/tests/test_client.py +180 -0
- setsig_sdk-1.0.0/tests/test_crypto.py +54 -0
setsig_sdk-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
Copyright 2026 setsig (AVCI Ventures)
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: setsig-sdk
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Official Python SDK for setsig.com, Proof of Physical Presence and Verification Infrastructure
|
|
5
|
+
Author-email: setsig Developer Relations <dev@setsig.com>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://setsig.com
|
|
8
|
+
Project-URL: Documentation, https://setsig.com/docs
|
|
9
|
+
Project-URL: Repository, https://github.com/setsig/setsig-python
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Topic :: Security :: Cryptography
|
|
18
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
# setsig-python
|
|
25
|
+
|
|
26
|
+
Official Python SDK for [setsig.com](https://setsig.com) — Physical Presence & Verification Infrastructure-as-a-Service (PaaS/IaaS).
|
|
27
|
+
|
|
28
|
+
[](https://badge.fury.io/py/setsig)
|
|
29
|
+
[](LICENSE)
|
|
30
|
+
|
|
31
|
+
Zero external dependencies! Built natively using the Python standard library (`urllib.request`, `hmac`, `hashlib`, `dataclasses`).
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pip install setsig-sdk
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Requirements: Python 3.10 or newer.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Quickstart
|
|
46
|
+
|
|
47
|
+
### 1. Initialize Client
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from setsig import Setsig, TokenFormat
|
|
51
|
+
|
|
52
|
+
client = Setsig(
|
|
53
|
+
api_key="sk_live_...",
|
|
54
|
+
timeout=10.0,
|
|
55
|
+
max_retries=3,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
# Generate a dynamic presence QR token for your venue
|
|
59
|
+
token = client.tokens.generate(
|
|
60
|
+
venue_id="ven_ist_headquarters",
|
|
61
|
+
ttl=60,
|
|
62
|
+
format=TokenFormat.SVG,
|
|
63
|
+
idempotency_key="idemp_tok_001",
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
print(f"Dynamic Token Generated: {token.dynamic_code} (Expires: {token.expires_at})")
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
### 2. Verify Session (Telemetric Presence & Attestation)
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
from setsig import (
|
|
75
|
+
Setsig,
|
|
76
|
+
ReplayAttackError,
|
|
77
|
+
GeofenceOutOfBoundsError,
|
|
78
|
+
InsufficientCreditsError,
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
try:
|
|
82
|
+
result = client.sessions.verify(
|
|
83
|
+
venue_id="ven_ist_headquarters",
|
|
84
|
+
token_id=token.token_id,
|
|
85
|
+
client_token="device_bound_token_...",
|
|
86
|
+
latitude=41.0082,
|
|
87
|
+
longitude=28.9784,
|
|
88
|
+
accuracy=4.2,
|
|
89
|
+
attestation_token="hardware_attest_jwt_...",
|
|
90
|
+
visual_proof_token="vpt_...",
|
|
91
|
+
)
|
|
92
|
+
print(f"Verified! Distance: {result.distance_meters}m, Risk: {result.risk_score}")
|
|
93
|
+
except ReplayAttackError as e:
|
|
94
|
+
print(f"Security Alert: Double-spend / Replay detected: {e}")
|
|
95
|
+
except GeofenceOutOfBoundsError as e:
|
|
96
|
+
print(f"Boundary Alert: User outside geofence perimeter: {e}")
|
|
97
|
+
except InsufficientCreditsError as e:
|
|
98
|
+
print(f"Billing Alert: Credits exhausted: {e}")
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
### 3. Verify Incoming Webhooks (Timing-Safe Comparison)
|
|
104
|
+
|
|
105
|
+
Cryptographic replay resistance and timing attack mitigation:
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
from setsig import Webhooks, SignatureVerificationError
|
|
109
|
+
|
|
110
|
+
webhooks = Webhooks(secret="whsec_...")
|
|
111
|
+
|
|
112
|
+
# Inside your FastAPI / Flask / Django request handler:
|
|
113
|
+
try:
|
|
114
|
+
event = webhooks.construct_event(
|
|
115
|
+
payload=raw_request_body_bytes,
|
|
116
|
+
header=request.headers.get("X-Setsig-Signature"),
|
|
117
|
+
tolerance=300.0, # 5 minutes
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
if event.event == "session.verified":
|
|
121
|
+
print(f"Session {event.data['session_id']} verified physically!")
|
|
122
|
+
elif event.event == "venue.anomaly_detected":
|
|
123
|
+
print(f"Venue alert: {event.data}")
|
|
124
|
+
|
|
125
|
+
except SignatureVerificationError as exc:
|
|
126
|
+
# 401 Unauthorized
|
|
127
|
+
print(f"Tampered webhook rejected: {exc}")
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Features
|
|
133
|
+
|
|
134
|
+
- **Zero External Dependencies:** No bloat, pure Python standard library.
|
|
135
|
+
- **Timing-Safe Cryptography:** Signature verification uses `hmac.compare_digest` to defend against timing side-channel attacks.
|
|
136
|
+
- **Automatic Retries & Exponential Backoff with Jitter:** Handles 429 Rate Limits and 5xx network interruptions gracefully.
|
|
137
|
+
- **Idempotency Keys:** Supports `idempotency_key` parameter to prevent accidental duplicate token generation or double-charges.
|
|
138
|
+
- **Typed Error Hierarchy:** Clean exceptions matching the setsig error model (`AuthenticationError`, `ReplayAttackError`, `GeofenceOutOfBoundsError`, `InsufficientCreditsError`, `RateLimitError`).
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## License
|
|
143
|
+
|
|
144
|
+
Apache-2.0 License. Commercial verification engine intellectual property held by AVCI Ventures.
|
|
145
|
+
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# setsig-python
|
|
2
|
+
|
|
3
|
+
Official Python SDK for [setsig.com](https://setsig.com) — Physical Presence & Verification Infrastructure-as-a-Service (PaaS/IaaS).
|
|
4
|
+
|
|
5
|
+
[](https://badge.fury.io/py/setsig)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
Zero external dependencies! Built natively using the Python standard library (`urllib.request`, `hmac`, `hashlib`, `dataclasses`).
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pip install setsig-sdk
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Requirements: Python 3.10 or newer.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Quickstart
|
|
23
|
+
|
|
24
|
+
### 1. Initialize Client
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
from setsig import Setsig, TokenFormat
|
|
28
|
+
|
|
29
|
+
client = Setsig(
|
|
30
|
+
api_key="sk_live_...",
|
|
31
|
+
timeout=10.0,
|
|
32
|
+
max_retries=3,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
# Generate a dynamic presence QR token for your venue
|
|
36
|
+
token = client.tokens.generate(
|
|
37
|
+
venue_id="ven_ist_headquarters",
|
|
38
|
+
ttl=60,
|
|
39
|
+
format=TokenFormat.SVG,
|
|
40
|
+
idempotency_key="idemp_tok_001",
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
print(f"Dynamic Token Generated: {token.dynamic_code} (Expires: {token.expires_at})")
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
### 2. Verify Session (Telemetric Presence & Attestation)
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from setsig import (
|
|
52
|
+
Setsig,
|
|
53
|
+
ReplayAttackError,
|
|
54
|
+
GeofenceOutOfBoundsError,
|
|
55
|
+
InsufficientCreditsError,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
try:
|
|
59
|
+
result = client.sessions.verify(
|
|
60
|
+
venue_id="ven_ist_headquarters",
|
|
61
|
+
token_id=token.token_id,
|
|
62
|
+
client_token="device_bound_token_...",
|
|
63
|
+
latitude=41.0082,
|
|
64
|
+
longitude=28.9784,
|
|
65
|
+
accuracy=4.2,
|
|
66
|
+
attestation_token="hardware_attest_jwt_...",
|
|
67
|
+
visual_proof_token="vpt_...",
|
|
68
|
+
)
|
|
69
|
+
print(f"Verified! Distance: {result.distance_meters}m, Risk: {result.risk_score}")
|
|
70
|
+
except ReplayAttackError as e:
|
|
71
|
+
print(f"Security Alert: Double-spend / Replay detected: {e}")
|
|
72
|
+
except GeofenceOutOfBoundsError as e:
|
|
73
|
+
print(f"Boundary Alert: User outside geofence perimeter: {e}")
|
|
74
|
+
except InsufficientCreditsError as e:
|
|
75
|
+
print(f"Billing Alert: Credits exhausted: {e}")
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
### 3. Verify Incoming Webhooks (Timing-Safe Comparison)
|
|
81
|
+
|
|
82
|
+
Cryptographic replay resistance and timing attack mitigation:
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
from setsig import Webhooks, SignatureVerificationError
|
|
86
|
+
|
|
87
|
+
webhooks = Webhooks(secret="whsec_...")
|
|
88
|
+
|
|
89
|
+
# Inside your FastAPI / Flask / Django request handler:
|
|
90
|
+
try:
|
|
91
|
+
event = webhooks.construct_event(
|
|
92
|
+
payload=raw_request_body_bytes,
|
|
93
|
+
header=request.headers.get("X-Setsig-Signature"),
|
|
94
|
+
tolerance=300.0, # 5 minutes
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
if event.event == "session.verified":
|
|
98
|
+
print(f"Session {event.data['session_id']} verified physically!")
|
|
99
|
+
elif event.event == "venue.anomaly_detected":
|
|
100
|
+
print(f"Venue alert: {event.data}")
|
|
101
|
+
|
|
102
|
+
except SignatureVerificationError as exc:
|
|
103
|
+
# 401 Unauthorized
|
|
104
|
+
print(f"Tampered webhook rejected: {exc}")
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Features
|
|
110
|
+
|
|
111
|
+
- **Zero External Dependencies:** No bloat, pure Python standard library.
|
|
112
|
+
- **Timing-Safe Cryptography:** Signature verification uses `hmac.compare_digest` to defend against timing side-channel attacks.
|
|
113
|
+
- **Automatic Retries & Exponential Backoff with Jitter:** Handles 429 Rate Limits and 5xx network interruptions gracefully.
|
|
114
|
+
- **Idempotency Keys:** Supports `idempotency_key` parameter to prevent accidental duplicate token generation or double-charges.
|
|
115
|
+
- **Typed Error Hierarchy:** Clean exceptions matching the setsig error model (`AuthenticationError`, `ReplayAttackError`, `GeofenceOutOfBoundsError`, `InsufficientCreditsError`, `RateLimitError`).
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## License
|
|
120
|
+
|
|
121
|
+
Apache-2.0 License. Commercial verification engine intellectual property held by AVCI Ventures.
|
|
122
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "setsig-sdk"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Official Python SDK for setsig.com, Proof of Physical Presence and Verification Infrastructure"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = { text = "Apache-2.0" }
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "setsig Developer Relations", email = "dev@setsig.com" }
|
|
14
|
+
]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 5 - Production/Stable",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"License :: OSI Approved :: Apache Software License",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Topic :: Security :: Cryptography",
|
|
24
|
+
"Topic :: Software Development :: Libraries :: Python Modules"
|
|
25
|
+
]
|
|
26
|
+
dependencies = []
|
|
27
|
+
|
|
28
|
+
[project.urls]
|
|
29
|
+
Homepage = "https://setsig.com"
|
|
30
|
+
Documentation = "https://setsig.com/docs"
|
|
31
|
+
Repository = "https://github.com/setsig/setsig-python"
|
|
32
|
+
|
|
33
|
+
[tool.setuptools.packages.find]
|
|
34
|
+
where = ["src"]
|
|
35
|
+
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""setsig Python SDK."""
|
|
2
|
+
|
|
3
|
+
from .client import Setsig
|
|
4
|
+
from .crypto import compute_signature, verify_signature
|
|
5
|
+
from .errors import (
|
|
6
|
+
AuthenticationError,
|
|
7
|
+
GeofenceOutOfBoundsError,
|
|
8
|
+
InsufficientCreditsError,
|
|
9
|
+
PaywallBlockedError,
|
|
10
|
+
CrossBorderCreditRequiredError,
|
|
11
|
+
PaywallTierRequiredError,
|
|
12
|
+
AttestationFailedError,
|
|
13
|
+
VisualProofRequiredError,
|
|
14
|
+
StaleVisualProofError,
|
|
15
|
+
InvalidImageHashError,
|
|
16
|
+
RateLimitError,
|
|
17
|
+
ReplayAttackError,
|
|
18
|
+
SetsigError,
|
|
19
|
+
SignatureVerificationError,
|
|
20
|
+
)
|
|
21
|
+
from .types import (
|
|
22
|
+
BillingBalance,
|
|
23
|
+
CreateVenueRequest,
|
|
24
|
+
EstimateCostRequest,
|
|
25
|
+
EstimateCostResponse,
|
|
26
|
+
GenerateTokenRequest,
|
|
27
|
+
GenerateTokenResponse,
|
|
28
|
+
TokenFormat,
|
|
29
|
+
UpdateVenueRequest,
|
|
30
|
+
Venue,
|
|
31
|
+
VerifySessionRequest,
|
|
32
|
+
VerifySessionResponse,
|
|
33
|
+
VisualProofSummary,
|
|
34
|
+
WebhookEvent,
|
|
35
|
+
)
|
|
36
|
+
from .webhooks import Webhooks
|
|
37
|
+
|
|
38
|
+
__all__ = [
|
|
39
|
+
"Setsig",
|
|
40
|
+
"Webhooks",
|
|
41
|
+
"compute_signature",
|
|
42
|
+
"verify_signature",
|
|
43
|
+
"SetsigError",
|
|
44
|
+
"AuthenticationError",
|
|
45
|
+
"InsufficientCreditsError",
|
|
46
|
+
"PaywallBlockedError",
|
|
47
|
+
"CrossBorderCreditRequiredError",
|
|
48
|
+
"PaywallTierRequiredError",
|
|
49
|
+
"AttestationFailedError",
|
|
50
|
+
"VisualProofRequiredError",
|
|
51
|
+
"StaleVisualProofError",
|
|
52
|
+
"InvalidImageHashError",
|
|
53
|
+
"ReplayAttackError",
|
|
54
|
+
"GeofenceOutOfBoundsError",
|
|
55
|
+
"RateLimitError",
|
|
56
|
+
"SignatureVerificationError",
|
|
57
|
+
"TokenFormat",
|
|
58
|
+
"GenerateTokenRequest",
|
|
59
|
+
"GenerateTokenResponse",
|
|
60
|
+
"VerifySessionRequest",
|
|
61
|
+
"VerifySessionResponse",
|
|
62
|
+
"VisualProofSummary",
|
|
63
|
+
"Venue",
|
|
64
|
+
"CreateVenueRequest",
|
|
65
|
+
"UpdateVenueRequest",
|
|
66
|
+
"BillingBalance",
|
|
67
|
+
"EstimateCostRequest",
|
|
68
|
+
"EstimateCostResponse",
|
|
69
|
+
"WebhookEvent",
|
|
70
|
+
]
|
|
71
|
+
|