swiftapi-python 1.2.1__py3-none-any.whl → 1.3.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.
@@ -1,255 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: swiftapi-python
3
- Version: 1.2.1
4
- Summary: SwiftAPI Python SDK - AI Action Verification Gateway
5
- Author-email: Rayan Pal <rayan@swiftapi.ai>
6
- License-Expression: MIT
7
- Project-URL: Homepage, https://swiftapi.ai
8
- Project-URL: Documentation, https://getswiftapi.com/docs
9
- Keywords: swiftapi,ai,verification,attestation,security,governance,enforcement
10
- Classifier: Development Status :: 4 - Beta
11
- Classifier: Intended Audience :: Developers
12
- Classifier: Operating System :: OS Independent
13
- Classifier: Programming Language :: Python :: 3
14
- Classifier: Programming Language :: Python :: 3.9
15
- Classifier: Programming Language :: Python :: 3.10
16
- Classifier: Programming Language :: Python :: 3.11
17
- Classifier: Programming Language :: Python :: 3.12
18
- Classifier: Topic :: Security
19
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
- Requires-Python: >=3.9
21
- Description-Content-Type: text/markdown
22
- License-File: LICENSE
23
- Requires-Dist: requests>=2.31.0
24
- Requires-Dist: pynacl>=1.5.0
25
- Requires-Dist: colorama>=0.4.6
26
- Provides-Extra: dev
27
- Requires-Dist: pytest>=7.0.0; extra == "dev"
28
- Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
29
- Requires-Dist: black>=23.0.0; extra == "dev"
30
- Requires-Dist: mypy>=1.0.0; extra == "dev"
31
- Requires-Dist: types-requests>=2.31.0; extra == "dev"
32
- Dynamic: license-file
33
-
34
- # SwiftAPI Python SDK
35
-
36
- **No AI action executes without verification.**
37
-
38
- SwiftAPI is the ignition key for AI agents. This SDK provides Python bindings for the SwiftAPI execution governance protocol.
39
-
40
- ## Installation
41
-
42
- ```bash
43
- pip install swiftapi-python
44
- ```
45
-
46
- ## Quick Start
47
-
48
- ```python
49
- from swiftapi import SwiftAPI, Enforcement
50
-
51
- # Initialize client with your API key
52
- api = SwiftAPI(key="swiftapi_live_...")
53
-
54
- # Create an enforcement point
55
- guard = Enforcement(api)
56
-
57
- # THE LINE THAT SAVES THE COMPANY
58
- guard.run(
59
- lambda: os.system("rm -rf /tmp/data"),
60
- action="file_delete",
61
- intent="Cleanup temporary files"
62
- )
63
- ```
64
-
65
- If the action is denied by policy, a `PolicyViolation` exception is raised and **nothing executes**.
66
-
67
- ## Features
68
-
69
- - **Cryptographic Enforcement**: Ed25519 signed attestations prove authorization
70
- - **Offline Verification**: Verify attestation signatures without network calls
71
- - **Policy Enforcement**: Actions blocked if they violate configured policies
72
- - **Rate Limiting**: Built-in handling for API rate limits
73
- - **Beautiful Output**: Color-coded terminal output for approvals/denials
74
-
75
- ## Usage Patterns
76
-
77
- ### 1. Direct Execution
78
-
79
- ```python
80
- from swiftapi import SwiftAPI, Enforcement
81
-
82
- api = SwiftAPI(key="swiftapi_live_...")
83
- guard = Enforcement(api)
84
-
85
- # Execute with verification
86
- result = guard.run(
87
- lambda: dangerous_operation(),
88
- action="database_write",
89
- intent="Update user preferences"
90
- )
91
- ```
92
-
93
- ### 2. Decorator
94
-
95
- ```python
96
- @guard.protect(action="api_call", intent="Send notification")
97
- def send_notification(user_id: str, message: str):
98
- # This only runs if SwiftAPI approves
99
- notification_service.send(user_id, message)
100
-
101
- # Usage - automatically enforced
102
- send_notification("user123", "Hello!")
103
- ```
104
-
105
- ### 3. Context Manager
106
-
107
- ```python
108
- with guard.guard(action="file_write", intent="Save configuration"):
109
- # This block only executes if approved
110
- with open("/etc/myapp/config.json", "w") as f:
111
- json.dump(config, f)
112
- ```
113
-
114
- ### 4. One-off Enforcement
115
-
116
- ```python
117
- from swiftapi import SwiftAPI, enforce
118
-
119
- api = SwiftAPI(key="swiftapi_live_...")
120
- enforce(api, lambda: risky_operation(), action="admin", intent="Reset system")
121
- ```
122
-
123
- ## Paranoid Mode
124
-
125
- For maximum security, enable paranoid mode to check revocation status online:
126
-
127
- ```python
128
- guard = Enforcement(api, paranoid=True)
129
- ```
130
-
131
- This adds an extra network call but ensures revoked attestations are caught in real-time.
132
-
133
- ## Offline Verification
134
-
135
- You can verify attestation signatures without any network calls:
136
-
137
- ```python
138
- from swiftapi import verify_signature, is_valid
139
-
140
- # Verify signature (raises exception if invalid)
141
- verify_signature(attestation)
142
-
143
- # Check validity without exceptions
144
- if is_valid(attestation):
145
- print("Attestation is valid")
146
- ```
147
-
148
- ## Error Handling
149
-
150
- ```python
151
- from swiftapi import (
152
- SwiftAPI,
153
- Enforcement,
154
- PolicyViolation,
155
- SignatureVerificationError,
156
- AttestationRevokedError,
157
- )
158
-
159
- api = SwiftAPI(key="swiftapi_live_...")
160
- guard = Enforcement(api)
161
-
162
- try:
163
- guard.run(lambda: delete_everything(), action="nuke", intent="YOLO")
164
- except PolicyViolation as e:
165
- print(f"Action denied: {e.denial_reason}")
166
- except SignatureVerificationError:
167
- print("CRITICAL: Attestation signature is invalid!")
168
- except AttestationRevokedError as e:
169
- print(f"Attestation {e.jti} was revoked")
170
- ```
171
-
172
- ## API Client
173
-
174
- The SDK also provides direct API access:
175
-
176
- ```python
177
- from swiftapi import SwiftAPI
178
-
179
- api = SwiftAPI(key="swiftapi_live_...")
180
-
181
- # Get API info
182
- info = api.get_info()
183
-
184
- # Verify an action
185
- result = api.verify(
186
- action_type="file_write",
187
- intent="Save user data",
188
- params={"path": "/data/users.json"}
189
- )
190
-
191
- # Check attestation revocation
192
- is_revoked = api.check_revocation(jti="attestation-id")
193
-
194
- # List authority keys (admin only)
195
- keys = api.list_keys()
196
-
197
- # Create new key (admin only)
198
- new_key = api.create_key(name="agent-1", scopes=["verify"])
199
- ```
200
-
201
- ## Configuration
202
-
203
- ```python
204
- api = SwiftAPI(
205
- key="swiftapi_live_...",
206
- base_url="https://swiftapi.ai", # Default
207
- timeout=30, # Request timeout in seconds
208
- )
209
-
210
- guard = Enforcement(
211
- client=api,
212
- paranoid=False, # Enable online revocation checks
213
- verbose=True, # Print status messages
214
- )
215
- ```
216
-
217
- ## The Golden Loop
218
-
219
- Every protected action goes through this verification chain:
220
-
221
- ```
222
- ┌─────────────────────────────────────────────────────────┐
223
- │ THE GOLDEN LOOP │
224
- ├─────────────────────────────────────────────────────────┤
225
- │ │
226
- │ 1. API CALL │
227
- │ client.verify() ──────────────────────────────┐ │
228
- │ │ │
229
- │ 2. CRYPTO CHECK (Offline Truth) │ │
230
- │ verifier.verify_signature() ◄─────────────────┤ │
231
- │ │ │
232
- │ 3. ONLINE CHECK (Optional/Paranoid) │ │
233
- │ client.check_revocation() ◄───────────────────┤ │
234
- │ │ │
235
- │ 4. EXECUTE │ │
236
- │ func() ◄──────────────────────────────────────┘ │
237
- │ │
238
- │ If ANY step fails → PolicyViolation raised │
239
- │ The action NEVER executes without full verification │
240
- │ │
241
- └─────────────────────────────────────────────────────────┘
242
- ```
243
-
244
- ## License
245
-
246
- MIT License - See LICENSE file for details.
247
-
248
- ## Links
249
-
250
- - **API**: https://swiftapi.ai
251
- - **Documentation**: https://getswiftapi.com/docs
252
-
253
- ---
254
-
255
- *Built by Rayan Pal. No AI action executes without verification.*
@@ -1,13 +0,0 @@
1
- swiftapi/__init__.py,sha256=9P71iwPdwJoTfWzks9dGBkhdeOLNN9aMpMpvGMd7nk0,2061
2
- swiftapi/anthropic.py,sha256=aTgCNWHigmJf0zUz9OpmUS3Ej_2bA_EY70lnMTlhBiI,7680
3
- swiftapi/client.py,sha256=9rIsu1lMQbb62Pt3FJ3osGvS48myQfZwSbgXYFg-rsQ,10197
4
- swiftapi/enforcement.py,sha256=L-2JKvvL5U3Q4ZU_o889RxZteuN-ELuxKGIMUXtx2sw,8725
5
- swiftapi/exceptions.py,sha256=hBleOCc1WwDEM70WNYTy1TDOSOaBJSx3PtzFzfmVOGY,1701
6
- swiftapi/openai.py,sha256=9erzv6J4Ts2PuqhV030QyIm5yE0UxomA0y2qW9-slKQ,7670
7
- swiftapi/utils.py,sha256=Sn6ED6ltECCYc-ce9fhxZxgzBthvflPCZelXPPzskZM,3145
8
- swiftapi/verifier.py,sha256=SpeTo3tHTVxz7-R8o5_kLIhEJV6aDOUG0ud4WcSWDBg,4768
9
- swiftapi_python-1.2.1.dist-info/licenses/LICENSE,sha256=btq3h42ZP3swvtQ3ak5k3sP_Y6yRwzL5zrV7EzNeRus,1087
10
- swiftapi_python-1.2.1.dist-info/METADATA,sha256=xCRpB88EJIujXFLRqMKF2OUuhcjsvkTSlPVKtE7plMk,7674
11
- swiftapi_python-1.2.1.dist-info/WHEEL,sha256=YCfwYGOYMi5Jhw2fU4yNgwErybb2IX5PEwBKV4ZbdBo,91
12
- swiftapi_python-1.2.1.dist-info/top_level.txt,sha256=oio-d2BTrT91P7dmufUhlSYjOtWBh4bOYz6rsTDDvu4,9
13
- swiftapi_python-1.2.1.dist-info/RECORD,,