otdf-python 0.3.1__py3-none-any.whl → 0.3.2__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.
- otdf_python/cli.py +3 -11
- otdf_python/sdk.py +8 -22
- {otdf_python-0.3.1.dist-info → otdf_python-0.3.2.dist-info}/METADATA +6 -80
- {otdf_python-0.3.1.dist-info → otdf_python-0.3.2.dist-info}/RECORD +6 -6
- {otdf_python-0.3.1.dist-info → otdf_python-0.3.2.dist-info}/WHEEL +0 -0
- {otdf_python-0.3.1.dist-info → otdf_python-0.3.2.dist-info}/licenses/LICENSE +0 -0
otdf_python/cli.py
CHANGED
|
@@ -20,7 +20,6 @@ from otdf_python.config import KASInfo, NanoTDFConfig, TDFConfig
|
|
|
20
20
|
from otdf_python.sdk import SDK
|
|
21
21
|
from otdf_python.sdk_builder import SDKBuilder
|
|
22
22
|
from otdf_python.sdk_exceptions import SDKException
|
|
23
|
-
from otdf_python.tdf import TDFReaderConfig
|
|
24
23
|
|
|
25
24
|
try:
|
|
26
25
|
__version__ = metadata.version("otdf-python")
|
|
@@ -310,10 +309,7 @@ def cmd_decrypt(args):
|
|
|
310
309
|
if encrypted_data.startswith(b"PK"):
|
|
311
310
|
# Regular TDF (ZIP format)
|
|
312
311
|
logger.debug("Decrypting TDF")
|
|
313
|
-
|
|
314
|
-
tdf_reader = sdk.load_tdf_with_config(
|
|
315
|
-
encrypted_data, reader_config
|
|
316
|
-
)
|
|
312
|
+
tdf_reader = sdk.load_tdf(encrypted_data)
|
|
317
313
|
# Access payload directly from TDFReader
|
|
318
314
|
payload_bytes = tdf_reader.payload
|
|
319
315
|
output_file.write(payload_bytes)
|
|
@@ -336,8 +332,7 @@ def cmd_decrypt(args):
|
|
|
336
332
|
if encrypted_data.startswith(b"PK"):
|
|
337
333
|
# Regular TDF (ZIP format)
|
|
338
334
|
logger.debug("Decrypting TDF")
|
|
339
|
-
|
|
340
|
-
tdf_reader = sdk.load_tdf_with_config(encrypted_data, reader_config)
|
|
335
|
+
tdf_reader = sdk.load_tdf(encrypted_data)
|
|
341
336
|
payload_bytes = tdf_reader.payload
|
|
342
337
|
output_file.write(payload_bytes)
|
|
343
338
|
logger.info("Successfully decrypted TDF")
|
|
@@ -370,10 +365,7 @@ def cmd_inspect(args):
|
|
|
370
365
|
if encrypted_data.startswith(b"PK"):
|
|
371
366
|
# Regular TDF
|
|
372
367
|
logger.debug("Inspecting TDF")
|
|
373
|
-
|
|
374
|
-
tdf_reader = sdk.load_tdf_with_config(
|
|
375
|
-
BytesIO(encrypted_data), reader_config
|
|
376
|
-
)
|
|
368
|
+
tdf_reader = sdk.load_tdf(BytesIO(encrypted_data))
|
|
377
369
|
manifest = tdf_reader.manifest
|
|
378
370
|
|
|
379
371
|
# Try to get data attributes
|
otdf_python/sdk.py
CHANGED
|
@@ -348,11 +348,13 @@ class SDK(AbstractContextManager):
|
|
|
348
348
|
"""Returns the platform URL if set"""
|
|
349
349
|
return self.platform_url
|
|
350
350
|
|
|
351
|
-
def
|
|
352
|
-
self,
|
|
351
|
+
def load_tdf(
|
|
352
|
+
self,
|
|
353
|
+
tdf_data: bytes | BinaryIO | BytesIO,
|
|
354
|
+
config: TDFReaderConfig | None = None,
|
|
353
355
|
) -> TDFReader:
|
|
354
356
|
"""
|
|
355
|
-
Loads a TDF from the provided data according to the config.
|
|
357
|
+
Loads a TDF from the provided data, optionally according to the config.
|
|
356
358
|
|
|
357
359
|
Args:
|
|
358
360
|
tdf_data: The TDF data as bytes, file object, or BytesIO
|
|
@@ -365,26 +367,10 @@ class SDK(AbstractContextManager):
|
|
|
365
367
|
SDKException: If there's an error loading the TDF
|
|
366
368
|
"""
|
|
367
369
|
tdf = TDF(self.services)
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
def load_tdf_without_config(
|
|
371
|
-
self, tdf_data: bytes | BinaryIO | BytesIO
|
|
372
|
-
) -> TDFReader:
|
|
373
|
-
"""
|
|
374
|
-
Loads a TDF from the provided data.
|
|
375
|
-
|
|
376
|
-
Args:
|
|
377
|
-
tdf_data: The TDF data as bytes, file object, or BytesIO
|
|
370
|
+
if config is None:
|
|
371
|
+
config = TDFReaderConfig()
|
|
378
372
|
|
|
379
|
-
|
|
380
|
-
TDFReader: Contains payload and manifest
|
|
381
|
-
|
|
382
|
-
Raises:
|
|
383
|
-
SDKException: If there's an error loading the TDF
|
|
384
|
-
"""
|
|
385
|
-
tdf = TDF(self.services)
|
|
386
|
-
default = TDFReaderConfig()
|
|
387
|
-
return tdf.load_tdf(tdf_data, default)
|
|
373
|
+
return tdf.load_tdf(tdf_data, config)
|
|
388
374
|
|
|
389
375
|
def create_tdf(
|
|
390
376
|
self,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: otdf-python
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: Unofficial OpenTDF SDK for Python
|
|
5
5
|
Author-email: b-long <b-long@users.noreply.github.com>
|
|
6
6
|
License-File: LICENSE
|
|
@@ -32,65 +32,6 @@ Unofficial OpenTDF SDK for Python
|
|
|
32
32
|
|
|
33
33
|
A legacy version (0.2.x) of this project is available for users who need the previous implementation. For more information, see [LEGACY_VERSION.md](docs/LEGACY_VERSION.md) or visit the [legacy branch on GitHub](https://github.com/b-long/opentdf-python-sdk/tree/0.2.x).
|
|
34
34
|
|
|
35
|
-
## Prerequisites
|
|
36
|
-
|
|
37
|
-
This project uses [uv](https://docs.astral.sh/uv/) for dependency management and task running.
|
|
38
|
-
|
|
39
|
-
### Installing uv
|
|
40
|
-
|
|
41
|
-
Install `uv` using one of the following methods:
|
|
42
|
-
|
|
43
|
-
**macOS/Linux:**
|
|
44
|
-
```bash
|
|
45
|
-
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
**Windows:**
|
|
49
|
-
```powershell
|
|
50
|
-
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
**Using Homebrew (macOS):**
|
|
54
|
-
```bash
|
|
55
|
-
brew install uv
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
For more installation options, see the [uv installation guide](https://docs.astral.sh/uv/getting-started/installation/).
|
|
59
|
-
|
|
60
|
-
## Development Setup
|
|
61
|
-
|
|
62
|
-
1. Clone the repository:
|
|
63
|
-
```bash
|
|
64
|
-
git clone <repository-url>
|
|
65
|
-
cd opentdf-python-sdk
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
2. Install dependencies:
|
|
69
|
-
```bash
|
|
70
|
-
uv sync
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## Running Tests
|
|
74
|
-
|
|
75
|
-
Run the full test suite:
|
|
76
|
-
```bash
|
|
77
|
-
uv run pytest tests/
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
Run specific test files:
|
|
81
|
-
```bash
|
|
82
|
-
uv run pytest tests/test_sdk.py
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
Run tests with verbose output:
|
|
86
|
-
```bash
|
|
87
|
-
uv run pytest tests/ -v
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
Run integration tests only:
|
|
91
|
-
```bash
|
|
92
|
-
uv run pytest tests/ -m integration
|
|
93
|
-
```
|
|
94
35
|
|
|
95
36
|
## Installation
|
|
96
37
|
|
|
@@ -99,21 +40,6 @@ Install from PyPI:
|
|
|
99
40
|
pip install otdf-python
|
|
100
41
|
```
|
|
101
42
|
|
|
102
|
-
|
|
103
|
-
## Protobuf & Connect RPC Generation
|
|
104
|
-
|
|
105
|
-
This project uses a dedicated submodule, `otdf-python-proto/`, for generating Python protobuf files and Connect RPC clients from OpenTDF platform proto definitions.
|
|
106
|
-
|
|
107
|
-
### Regenerating Protobuf & Connect RPC Files
|
|
108
|
-
|
|
109
|
-
From the submodule:
|
|
110
|
-
```bash
|
|
111
|
-
cd otdf-python-proto
|
|
112
|
-
uv run python scripts/generate_connect_proto.py
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
See [`otdf-python-proto/README.md`](otdf-python-proto/README.md) and [`PROTOBUF_SETUP.md`](PROTOBUF_SETUP.md) for details.
|
|
116
|
-
|
|
117
43
|
## Quick Start
|
|
118
44
|
|
|
119
45
|
### Basic Configuration
|
|
@@ -160,7 +86,7 @@ sdk = builder.build()
|
|
|
160
86
|
from io import BytesIO
|
|
161
87
|
|
|
162
88
|
# Create TDF configuration with attributes
|
|
163
|
-
config = sdk.new_tdf_config(attributes=["https://example.
|
|
89
|
+
config = sdk.new_tdf_config(attributes=["https://example.net/attr/attr1/value/value1"])
|
|
164
90
|
|
|
165
91
|
# Encrypt data to TDF format
|
|
166
92
|
input_data = b"Hello, World!"
|
|
@@ -183,8 +109,7 @@ with open("encrypted.tdf", "rb") as f:
|
|
|
183
109
|
encrypted_data = f.read()
|
|
184
110
|
|
|
185
111
|
# Decrypt TDF
|
|
186
|
-
|
|
187
|
-
tdf_reader = sdk.load_tdf(encrypted_data, reader_config)
|
|
112
|
+
tdf_reader = sdk.load_tdf(encrypted_data)
|
|
188
113
|
decrypted_data = tdf_reader.payload
|
|
189
114
|
|
|
190
115
|
# Save decrypted data
|
|
@@ -208,6 +133,7 @@ src/otdf_python/
|
|
|
208
133
|
└── ... # Additional modules
|
|
209
134
|
tests/
|
|
210
135
|
└── ... # Various tests
|
|
136
|
+
```
|
|
211
137
|
|
|
212
138
|
## Contributing
|
|
213
139
|
|
|
@@ -215,14 +141,14 @@ tests/
|
|
|
215
141
|
2. Create a feature branch: `git checkout -b feature-name`
|
|
216
142
|
3. Make your changes
|
|
217
143
|
4. Run tests: `uv run pytest tests/`
|
|
218
|
-
5. Commit your changes: `git commit -am '
|
|
144
|
+
5. Commit your changes: `git commit -am 'feat: add feature'`
|
|
219
145
|
6. Push to the branch: `git push origin feature-name`
|
|
220
146
|
7. Submit a pull request
|
|
221
147
|
|
|
222
148
|
### Release Process
|
|
223
149
|
|
|
224
150
|
For maintainers and contributors working on releases:
|
|
225
|
-
- See [RELEASES.md](RELEASES.md) for comprehensive release documentation
|
|
151
|
+
- See [RELEASES.md](docs/RELEASES.md) for comprehensive release documentation
|
|
226
152
|
- Feature branch alpha releases available for testing changes before merge
|
|
227
153
|
- Automated releases via Release Please on the main branch
|
|
228
154
|
|
|
@@ -8,7 +8,7 @@ otdf_python/asym_decryption.py,sha256=eVfgfzFHMK4ni3g-u8fBe3sdF02eo_msZouo19UBlh
|
|
|
8
8
|
otdf_python/asym_encryption.py,sha256=ex-S_PvBnWKSSvbocTjJ_p5VQjjeiThcc9bMRZqvifw,2932
|
|
9
9
|
otdf_python/auth_headers.py,sha256=LFjfWiobNo9DNaPgcm-aJANzHZh7_u9oHTxnEzEq-Ro,562
|
|
10
10
|
otdf_python/autoconfigure_utils.py,sha256=NiNtbapBoIO-6kM59HRvX3Kj_Z0IRMrTkFlXjwuNfPc,3236
|
|
11
|
-
otdf_python/cli.py,sha256=
|
|
11
|
+
otdf_python/cli.py,sha256=oRPn002DB7Xvc0y4oPzIFt97OmvMOYHwR6pZXrdwvAo,19463
|
|
12
12
|
otdf_python/collection_store.py,sha256=MH1RxlevRVFj5lBS_6DN3zz5ZgOhBjD0P7AYBLBqS0o,1004
|
|
13
13
|
otdf_python/collection_store_impl.py,sha256=g3YeSwMeXr1BNmwmFr75fv9ptPjieC36Bhct-Jf1trw,613
|
|
14
14
|
otdf_python/config.py,sha256=uGYVByTWl7pWcKRER41ef-ay5VevIbOyUAEd6BIArVg,2185
|
|
@@ -35,7 +35,7 @@ otdf_python/policy_info.py,sha256=n9hgdQrTRqPO7O1R90EUtIyoWNlaABAF7mRfbjIzaX8,28
|
|
|
35
35
|
otdf_python/policy_object.py,sha256=zzwHk6jhZwpiX2BWxTJ1kDl3cgFijQfQrKJP3OqI35Q,380
|
|
36
36
|
otdf_python/policy_stub.py,sha256=BQn06Ye5MwCu9feJZFPmO_UTfhugtiQa539iBkSQwhQ,117
|
|
37
37
|
otdf_python/resource_locator.py,sha256=zYN5yd9cGwN9SRQO2tUD1UXj2zkPl2apd-X4E1MrnDg,1879
|
|
38
|
-
otdf_python/sdk.py,sha256
|
|
38
|
+
otdf_python/sdk.py,sha256=-JNrbk7Nr3IKsTX9BZp2OxPlCilaSbA8FmP7Zn_GWsU,17082
|
|
39
39
|
otdf_python/sdk_builder.py,sha256=QEu9y5I8xLPBuR8O2AG7AWInqO7g4Q5-WGW0sIVsOmQ,15803
|
|
40
40
|
otdf_python/sdk_exceptions.py,sha256=L_bYkkyF-hnEBFXfjT5C41i5lM-t8OJB5mU_1zYvfP8,479
|
|
41
41
|
otdf_python/symmetric_and_payload_config.py,sha256=D_LArhk1gA5-tpUiaUZTTM90ZKdc3DCq1a6X8etCir8,992
|
|
@@ -131,7 +131,7 @@ otdf_python_proto/wellknownconfiguration/__init__.py,sha256=X3GeZJ1mG_N1MViryjkq
|
|
|
131
131
|
otdf_python_proto/wellknownconfiguration/wellknown_configuration_pb2.py,sha256=g9xSm9TxX0IPMqiFCaridJvI2TrL8PrXVFPgu8tX9VM,3863
|
|
132
132
|
otdf_python_proto/wellknownconfiguration/wellknown_configuration_pb2.pyi,sha256=Zw4vROvTgomnFqsalJrYda632ojXH0FVXSzTXxerybw,1490
|
|
133
133
|
otdf_python_proto/wellknownconfiguration/wellknown_configuration_pb2_connect.py,sha256=i9rGG2mgQZfk6xGCp1ywu4QqKWSiwpuLoNKGUwl43t8,5346
|
|
134
|
-
otdf_python-0.3.
|
|
135
|
-
otdf_python-0.3.
|
|
136
|
-
otdf_python-0.3.
|
|
137
|
-
otdf_python-0.3.
|
|
134
|
+
otdf_python-0.3.2.dist-info/METADATA,sha256=tzbPz8K7n2FnKzMSIkz-6KP8-gw-ZkVYt72tYWemsp8,4324
|
|
135
|
+
otdf_python-0.3.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
136
|
+
otdf_python-0.3.2.dist-info/licenses/LICENSE,sha256=DPrPHdI6tfZcqk9kzQ37vh1Ftk7LJYdMrUtwKl7L3Pw,1074
|
|
137
|
+
otdf_python-0.3.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|