veilio-sdk 1.1.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.
@@ -0,0 +1,3 @@
1
+ include README.md
2
+ include LICENSE
3
+ recursive-include veilio_sdk *.py
@@ -0,0 +1,337 @@
1
+ Metadata-Version: 2.4
2
+ Name: veilio-sdk
3
+ Version: 1.1.0
4
+ Summary: Official Veilio SDK for Python - Data tokenization and cyber-resilience API client
5
+ Home-page: https://github.com/veilio/veilio-sdk-python
6
+ Author: Veilio
7
+ Author-email: support@veilio.xyz
8
+ Project-URL: Documentation, https://docs.veilio.com
9
+ Project-URL: Source, https://github.com/veilio/veilio-sdk-python
10
+ Project-URL: Support, https://veilio.com/support
11
+ Keywords: veilio tokenization data-protection cyber-resilience privacy security api-client
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
15
+ Classifier: Topic :: Security
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.8
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Requires-Python: >=3.8
24
+ Description-Content-Type: text/markdown
25
+ Requires-Dist: requests>=2.28.0
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>=22.0.0; extra == "dev"
30
+ Requires-Dist: mypy>=0.991; extra == "dev"
31
+ Dynamic: author
32
+ Dynamic: author-email
33
+ Dynamic: classifier
34
+ Dynamic: description
35
+ Dynamic: description-content-type
36
+ Dynamic: home-page
37
+ Dynamic: keywords
38
+ Dynamic: project-url
39
+ Dynamic: provides-extra
40
+ Dynamic: requires-dist
41
+ Dynamic: requires-python
42
+ Dynamic: summary
43
+
44
+ # veilio-sdk
45
+
46
+ Official Python SDK for Veilio - Data tokenization and cyber-resilience API.
47
+
48
+ ## Installation
49
+
50
+ ```bash
51
+ pip install veilio-sdk
52
+ ```
53
+
54
+ ## Quick Start
55
+
56
+ ```python
57
+ from veilio_sdk import VeilioClient
58
+
59
+ # Initialize client
60
+ client = VeilioClient(
61
+ api_key="veil_dev_your-api-key-here",
62
+ base_url="https://api.veilio.com/api" # Optional, defaults to production
63
+ )
64
+
65
+ # Tokenize sensitive data
66
+ result = client.tokenize(
67
+ data="john@example.com",
68
+ type="email"
69
+ )
70
+
71
+ print(f"Token: {result['token']}")
72
+
73
+ # Detokenize when needed
74
+ original = client.detokenize(
75
+ token=result["token"],
76
+ reason="Send email notification"
77
+ )
78
+
79
+ print(f"Original: {original['data']}")
80
+ ```
81
+
82
+ ## Features
83
+
84
+ - ✅ **Simple tokenization** - Tokenize single fields
85
+ - ✅ **Bulk operations** - Tokenize/detokenize multiple fields at once
86
+ - ✅ **Multi-format support** - JSON, CSV, SQL formats
87
+ - ✅ **Crypto shredding** - Immediate token shredding (`shred_token`)
88
+ - ✅ **Retention policies** - Automatic shredding via `retention`
89
+ - ✅ **Automatic retries** - Handles rate limits and network errors
90
+ - ✅ **Error handling** - Clear error messages and types
91
+ - ✅ **Type hints** - Full type annotations included
92
+
93
+ ## API Reference
94
+
95
+ ### Constructor
96
+
97
+ ```python
98
+ client = VeilioClient(
99
+ api_key: str, # Required: Your Veilio API key
100
+ base_url: str = "https://api.veilio.com/api", # Optional
101
+ timeout: int = 30, # Optional: Request timeout in seconds
102
+ max_retries: int = 3 # Optional: Max retries for failed requests
103
+ )
104
+ ```
105
+
106
+ ### Methods
107
+
108
+ #### `tokenize(data, type=None, metadata=None, retention=None)`
109
+
110
+ Tokenize a single field.
111
+
112
+ ```python
113
+ result = client.tokenize(
114
+ data="john@example.com",
115
+ type="email", # Optional
116
+ metadata={"source": "form"}, # Optional
117
+ retention={ # Optional
118
+ "ttlDays": 30
119
+ # or "retentionUntil": "2026-12-31T23:59:59.000Z"
120
+ }
121
+ )
122
+
123
+ # Returns: {"token": str, "createdAt": str, "retentionUntil": str | None}
124
+ ```
125
+
126
+ #### `tokenize_bulk(fields)`
127
+
128
+ Tokenize multiple fields in one request.
129
+
130
+ ```python
131
+ result = client.tokenize_bulk([
132
+ {"data": "john@example.com", "type": "email"},
133
+ {"data": "+33612345678", "type": "phone"}
134
+ ])
135
+
136
+ # Returns: {
137
+ # "tokens": [...],
138
+ # "summary": {"total": int, "success": int, "failed": int},
139
+ # "errors": [...], # Optional
140
+ # "createdAt": str
141
+ # }
142
+ ```
143
+
144
+ #### `detokenize(token, reason=None)`
145
+
146
+ Detokenize a single token.
147
+
148
+ ```python
149
+ result = client.detokenize(
150
+ token="tok_abc123...",
151
+ reason="Send email" # Optional
152
+ )
153
+
154
+ # Returns: {"data": str, "accessedAt": str}
155
+ ```
156
+
157
+ #### `shred_token(token, reason=None)`
158
+
159
+ Shred a token immediately (cryptographic erasure).
160
+
161
+ ```python
162
+ result = client.shred_token(
163
+ token="tok_abc123...",
164
+ reason="GDPR delete request" # Optional
165
+ )
166
+
167
+ # Returns: {"token": str, "shreddedAt": str}
168
+ ```
169
+
170
+ #### `detokenize_bulk(tokens)`
171
+
172
+ Detokenize multiple tokens in one request.
173
+
174
+ ```python
175
+ result = client.detokenize_bulk([
176
+ {"token": "tok_abc123...", "reason": "Processing"},
177
+ {"token": "tok_def456...", "reason": "Processing"}
178
+ ])
179
+
180
+ # Returns: {
181
+ # "results": [...],
182
+ # "summary": {"total": int, "success": int, "failed": int},
183
+ # "errors": [...], # Optional
184
+ # "accessedAt": str
185
+ # }
186
+ ```
187
+
188
+ #### `tokenize_format(data, format=None, options=None)`
189
+
190
+ Tokenize structured data (JSON, CSV, SQL).
191
+
192
+ ```python
193
+ json_data = '{"email": "john@example.com"}'
194
+
195
+ result = client.tokenize_format(
196
+ data=json_data,
197
+ format="json", # Optional: auto-detected if omitted
198
+ options={
199
+ "fields": ["email"] # Optional: tokenize only specific fields
200
+ }
201
+ )
202
+
203
+ # Returns: {
204
+ # "format": str,
205
+ # "tokenizedData": str,
206
+ # "tokens": [...],
207
+ # "metadata": {...},
208
+ # "summary": {"totalFields": int, "tokenizedFields": int}
209
+ # }
210
+ ```
211
+
212
+ #### `detokenize_format(tokenized_data, format, tokens)`
213
+
214
+ Detokenize structured data.
215
+
216
+ ```python
217
+ result = client.detokenize_format(
218
+ tokenized_data='{"email": "tok_abc123..."}',
219
+ format="json",
220
+ tokens=[{"path": "email", "token": "tok_abc123..."}]
221
+ )
222
+
223
+ # Returns: {
224
+ # "format": str,
225
+ # "detokenizedData": str,
226
+ # "summary": {"tokensProcessed": int}
227
+ # }
228
+ ```
229
+
230
+ ## Examples
231
+
232
+ ### Basic Usage
233
+
234
+ ```python
235
+ from veilio_sdk import VeilioClient
236
+ import os
237
+
238
+ client = VeilioClient(api_key=os.getenv("VEILIO_API_KEY"))
239
+
240
+ # Tokenize
241
+ token = client.tokenize(data="sensitive@data.com", type="email")
242
+
243
+ # Store token in your database
244
+ # db.execute("INSERT INTO users (email) VALUES (?)", (token["token"],))
245
+
246
+ # Later, detokenize when needed
247
+ user = db.get_user(user_id)
248
+ email = client.detokenize(token=user.email, reason="Send notification")
249
+ ```
250
+
251
+ ### Bulk Operations
252
+
253
+ ```python
254
+ # Tokenize multiple fields at once
255
+ result = client.tokenize_bulk([
256
+ {"data": "john@example.com", "type": "email"},
257
+ {"data": "+33612345678", "type": "phone"},
258
+ {"data": "123-45-6789", "type": "ssn"}
259
+ ])
260
+
261
+ # Check for errors
262
+ if result["summary"]["failed"] > 0:
263
+ print(f"Errors: {result.get('errors', [])}")
264
+
265
+ # Use the tokens
266
+ for token_result in result["tokens"]:
267
+ print(f"Token: {token_result['token']}")
268
+ ```
269
+
270
+ ### Format Tokenization
271
+
272
+ ```python
273
+ # Tokenize JSON data
274
+ json_data = json.dumps({
275
+ "users": [
276
+ {"email": "john@example.com", "phone": "+33612345678"}
277
+ ]
278
+ })
279
+
280
+ result = client.tokenize_format(data=json_data, format="json")
281
+
282
+ # Store tokenized JSON
283
+ # db.save(result["tokenizedData"])
284
+
285
+ # Later, detokenize
286
+ recovered = client.detokenize_format(
287
+ tokenized_data=result["tokenizedData"],
288
+ format="json",
289
+ tokens=[{"path": t["path"], "token": t["token"]} for t in result["tokens"]]
290
+ )
291
+ ```
292
+
293
+ ## Error Handling
294
+
295
+ ```python
296
+ from veilio_sdk import (
297
+ VeilioClient,
298
+ VeilioError,
299
+ AuthenticationError,
300
+ RateLimitError,
301
+ TokenShreddedError,
302
+ )
303
+
304
+ try:
305
+ result = client.tokenize(data="test")
306
+ except AuthenticationError as e:
307
+ print(f"Auth error: {e.message}")
308
+ except RateLimitError as e:
309
+ print(f"Rate limit: {e.message}, retry after {e.retry_after}s")
310
+ except TokenShreddedError as e:
311
+ print(f"Token shredded: {e.message}")
312
+ except VeilioError as e:
313
+ print(f"API error: {e.code} - {e.message}")
314
+ ```
315
+
316
+ ## Error Codes
317
+
318
+ - `AUTH_ERROR` - Invalid or missing API key
319
+ - `VALIDATION_ERROR` - Invalid request data
320
+ - `RATE_LIMIT_ERROR` - Rate limit exceeded
321
+ - `PLAN_LIMIT` - Plan limit exceeded
322
+ - `TOKEN_SHREDDED` - Token has been cryptographically shredded
323
+ - `INTERNAL_ERROR` - Server error
324
+
325
+ ## Requirements
326
+
327
+ - Python 3.8+
328
+ - `requests` library
329
+
330
+ ## License
331
+
332
+ MIT
333
+
334
+ ## Support
335
+
336
+ - Documentation: https://docs.veilio.com
337
+ - Support: support@veilio.xyz
@@ -0,0 +1,294 @@
1
+ # veilio-sdk
2
+
3
+ Official Python SDK for Veilio - Data tokenization and cyber-resilience API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install veilio-sdk
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```python
14
+ from veilio_sdk import VeilioClient
15
+
16
+ # Initialize client
17
+ client = VeilioClient(
18
+ api_key="veil_dev_your-api-key-here",
19
+ base_url="https://api.veilio.com/api" # Optional, defaults to production
20
+ )
21
+
22
+ # Tokenize sensitive data
23
+ result = client.tokenize(
24
+ data="john@example.com",
25
+ type="email"
26
+ )
27
+
28
+ print(f"Token: {result['token']}")
29
+
30
+ # Detokenize when needed
31
+ original = client.detokenize(
32
+ token=result["token"],
33
+ reason="Send email notification"
34
+ )
35
+
36
+ print(f"Original: {original['data']}")
37
+ ```
38
+
39
+ ## Features
40
+
41
+ - ✅ **Simple tokenization** - Tokenize single fields
42
+ - ✅ **Bulk operations** - Tokenize/detokenize multiple fields at once
43
+ - ✅ **Multi-format support** - JSON, CSV, SQL formats
44
+ - ✅ **Crypto shredding** - Immediate token shredding (`shred_token`)
45
+ - ✅ **Retention policies** - Automatic shredding via `retention`
46
+ - ✅ **Automatic retries** - Handles rate limits and network errors
47
+ - ✅ **Error handling** - Clear error messages and types
48
+ - ✅ **Type hints** - Full type annotations included
49
+
50
+ ## API Reference
51
+
52
+ ### Constructor
53
+
54
+ ```python
55
+ client = VeilioClient(
56
+ api_key: str, # Required: Your Veilio API key
57
+ base_url: str = "https://api.veilio.com/api", # Optional
58
+ timeout: int = 30, # Optional: Request timeout in seconds
59
+ max_retries: int = 3 # Optional: Max retries for failed requests
60
+ )
61
+ ```
62
+
63
+ ### Methods
64
+
65
+ #### `tokenize(data, type=None, metadata=None, retention=None)`
66
+
67
+ Tokenize a single field.
68
+
69
+ ```python
70
+ result = client.tokenize(
71
+ data="john@example.com",
72
+ type="email", # Optional
73
+ metadata={"source": "form"}, # Optional
74
+ retention={ # Optional
75
+ "ttlDays": 30
76
+ # or "retentionUntil": "2026-12-31T23:59:59.000Z"
77
+ }
78
+ )
79
+
80
+ # Returns: {"token": str, "createdAt": str, "retentionUntil": str | None}
81
+ ```
82
+
83
+ #### `tokenize_bulk(fields)`
84
+
85
+ Tokenize multiple fields in one request.
86
+
87
+ ```python
88
+ result = client.tokenize_bulk([
89
+ {"data": "john@example.com", "type": "email"},
90
+ {"data": "+33612345678", "type": "phone"}
91
+ ])
92
+
93
+ # Returns: {
94
+ # "tokens": [...],
95
+ # "summary": {"total": int, "success": int, "failed": int},
96
+ # "errors": [...], # Optional
97
+ # "createdAt": str
98
+ # }
99
+ ```
100
+
101
+ #### `detokenize(token, reason=None)`
102
+
103
+ Detokenize a single token.
104
+
105
+ ```python
106
+ result = client.detokenize(
107
+ token="tok_abc123...",
108
+ reason="Send email" # Optional
109
+ )
110
+
111
+ # Returns: {"data": str, "accessedAt": str}
112
+ ```
113
+
114
+ #### `shred_token(token, reason=None)`
115
+
116
+ Shred a token immediately (cryptographic erasure).
117
+
118
+ ```python
119
+ result = client.shred_token(
120
+ token="tok_abc123...",
121
+ reason="GDPR delete request" # Optional
122
+ )
123
+
124
+ # Returns: {"token": str, "shreddedAt": str}
125
+ ```
126
+
127
+ #### `detokenize_bulk(tokens)`
128
+
129
+ Detokenize multiple tokens in one request.
130
+
131
+ ```python
132
+ result = client.detokenize_bulk([
133
+ {"token": "tok_abc123...", "reason": "Processing"},
134
+ {"token": "tok_def456...", "reason": "Processing"}
135
+ ])
136
+
137
+ # Returns: {
138
+ # "results": [...],
139
+ # "summary": {"total": int, "success": int, "failed": int},
140
+ # "errors": [...], # Optional
141
+ # "accessedAt": str
142
+ # }
143
+ ```
144
+
145
+ #### `tokenize_format(data, format=None, options=None)`
146
+
147
+ Tokenize structured data (JSON, CSV, SQL).
148
+
149
+ ```python
150
+ json_data = '{"email": "john@example.com"}'
151
+
152
+ result = client.tokenize_format(
153
+ data=json_data,
154
+ format="json", # Optional: auto-detected if omitted
155
+ options={
156
+ "fields": ["email"] # Optional: tokenize only specific fields
157
+ }
158
+ )
159
+
160
+ # Returns: {
161
+ # "format": str,
162
+ # "tokenizedData": str,
163
+ # "tokens": [...],
164
+ # "metadata": {...},
165
+ # "summary": {"totalFields": int, "tokenizedFields": int}
166
+ # }
167
+ ```
168
+
169
+ #### `detokenize_format(tokenized_data, format, tokens)`
170
+
171
+ Detokenize structured data.
172
+
173
+ ```python
174
+ result = client.detokenize_format(
175
+ tokenized_data='{"email": "tok_abc123..."}',
176
+ format="json",
177
+ tokens=[{"path": "email", "token": "tok_abc123..."}]
178
+ )
179
+
180
+ # Returns: {
181
+ # "format": str,
182
+ # "detokenizedData": str,
183
+ # "summary": {"tokensProcessed": int}
184
+ # }
185
+ ```
186
+
187
+ ## Examples
188
+
189
+ ### Basic Usage
190
+
191
+ ```python
192
+ from veilio_sdk import VeilioClient
193
+ import os
194
+
195
+ client = VeilioClient(api_key=os.getenv("VEILIO_API_KEY"))
196
+
197
+ # Tokenize
198
+ token = client.tokenize(data="sensitive@data.com", type="email")
199
+
200
+ # Store token in your database
201
+ # db.execute("INSERT INTO users (email) VALUES (?)", (token["token"],))
202
+
203
+ # Later, detokenize when needed
204
+ user = db.get_user(user_id)
205
+ email = client.detokenize(token=user.email, reason="Send notification")
206
+ ```
207
+
208
+ ### Bulk Operations
209
+
210
+ ```python
211
+ # Tokenize multiple fields at once
212
+ result = client.tokenize_bulk([
213
+ {"data": "john@example.com", "type": "email"},
214
+ {"data": "+33612345678", "type": "phone"},
215
+ {"data": "123-45-6789", "type": "ssn"}
216
+ ])
217
+
218
+ # Check for errors
219
+ if result["summary"]["failed"] > 0:
220
+ print(f"Errors: {result.get('errors', [])}")
221
+
222
+ # Use the tokens
223
+ for token_result in result["tokens"]:
224
+ print(f"Token: {token_result['token']}")
225
+ ```
226
+
227
+ ### Format Tokenization
228
+
229
+ ```python
230
+ # Tokenize JSON data
231
+ json_data = json.dumps({
232
+ "users": [
233
+ {"email": "john@example.com", "phone": "+33612345678"}
234
+ ]
235
+ })
236
+
237
+ result = client.tokenize_format(data=json_data, format="json")
238
+
239
+ # Store tokenized JSON
240
+ # db.save(result["tokenizedData"])
241
+
242
+ # Later, detokenize
243
+ recovered = client.detokenize_format(
244
+ tokenized_data=result["tokenizedData"],
245
+ format="json",
246
+ tokens=[{"path": t["path"], "token": t["token"]} for t in result["tokens"]]
247
+ )
248
+ ```
249
+
250
+ ## Error Handling
251
+
252
+ ```python
253
+ from veilio_sdk import (
254
+ VeilioClient,
255
+ VeilioError,
256
+ AuthenticationError,
257
+ RateLimitError,
258
+ TokenShreddedError,
259
+ )
260
+
261
+ try:
262
+ result = client.tokenize(data="test")
263
+ except AuthenticationError as e:
264
+ print(f"Auth error: {e.message}")
265
+ except RateLimitError as e:
266
+ print(f"Rate limit: {e.message}, retry after {e.retry_after}s")
267
+ except TokenShreddedError as e:
268
+ print(f"Token shredded: {e.message}")
269
+ except VeilioError as e:
270
+ print(f"API error: {e.code} - {e.message}")
271
+ ```
272
+
273
+ ## Error Codes
274
+
275
+ - `AUTH_ERROR` - Invalid or missing API key
276
+ - `VALIDATION_ERROR` - Invalid request data
277
+ - `RATE_LIMIT_ERROR` - Rate limit exceeded
278
+ - `PLAN_LIMIT` - Plan limit exceeded
279
+ - `TOKEN_SHREDDED` - Token has been cryptographically shredded
280
+ - `INTERNAL_ERROR` - Server error
281
+
282
+ ## Requirements
283
+
284
+ - Python 3.8+
285
+ - `requests` library
286
+
287
+ ## License
288
+
289
+ MIT
290
+
291
+ ## Support
292
+
293
+ - Documentation: https://docs.veilio.com
294
+ - Support: support@veilio.xyz
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,51 @@
1
+ """
2
+ Setup configuration for Veilio Python SDK
3
+ """
4
+
5
+ from setuptools import setup, find_packages
6
+
7
+ with open("README.md", "r", encoding="utf-8") as fh:
8
+ long_description = fh.read()
9
+
10
+ setup(
11
+ name="veilio-sdk",
12
+ version="1.1.0",
13
+ author="Veilio",
14
+ author_email="support@veilio.xyz",
15
+ description="Official Veilio SDK for Python - Data tokenization and cyber-resilience API client",
16
+ long_description=long_description,
17
+ long_description_content_type="text/markdown",
18
+ url="https://github.com/veilio/veilio-sdk-python",
19
+ packages=find_packages(),
20
+ classifiers=[
21
+ "Development Status :: 4 - Beta",
22
+ "Intended Audience :: Developers",
23
+ "Topic :: Software Development :: Libraries :: Python Modules",
24
+ "Topic :: Security",
25
+ "License :: OSI Approved :: MIT License",
26
+ "Programming Language :: Python :: 3",
27
+ "Programming Language :: Python :: 3.8",
28
+ "Programming Language :: Python :: 3.9",
29
+ "Programming Language :: Python :: 3.10",
30
+ "Programming Language :: Python :: 3.11",
31
+ "Programming Language :: Python :: 3.12",
32
+ ],
33
+ python_requires=">=3.8",
34
+ install_requires=[
35
+ "requests>=2.28.0",
36
+ ],
37
+ extras_require={
38
+ "dev": [
39
+ "pytest>=7.0.0",
40
+ "pytest-cov>=4.0.0",
41
+ "black>=22.0.0",
42
+ "mypy>=0.991",
43
+ ],
44
+ },
45
+ keywords="veilio tokenization data-protection cyber-resilience privacy security api-client",
46
+ project_urls={
47
+ "Documentation": "https://docs.veilio.com",
48
+ "Source": "https://github.com/veilio/veilio-sdk-python",
49
+ "Support": "https://veilio.com/support",
50
+ },
51
+ )
@@ -0,0 +1,24 @@
1
+ """
2
+ Veilio SDK - Official Python client for Veilio API
3
+
4
+ Data tokenization and cyber-resilience API client.
5
+ """
6
+
7
+ from .client import VeilioClient
8
+ from .exceptions import (
9
+ VeilioError,
10
+ PlanLimitError,
11
+ AuthenticationError,
12
+ RateLimitError,
13
+ TokenShreddedError,
14
+ )
15
+
16
+ __version__ = "1.1.0"
17
+ __all__ = [
18
+ "VeilioClient",
19
+ "VeilioError",
20
+ "PlanLimitError",
21
+ "AuthenticationError",
22
+ "RateLimitError",
23
+ "TokenShreddedError",
24
+ ]