trufo 2.2.0__tar.gz → 2.2.2__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.
Files changed (52) hide show
  1. {trufo-2.2.0 → trufo-2.2.2}/PKG-INFO +4 -4
  2. {trufo-2.2.0 → trufo-2.2.2}/pyproject.toml +4 -4
  3. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/__init__.py +20 -5
  4. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/api/endpoints.py +5 -2
  5. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/api/session.py +11 -5
  6. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/api/tca/certs_c2pa.py +64 -4
  7. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/api/tca/certs_test.py +51 -31
  8. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/api/tps/recover.py +4 -1
  9. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/api/tps/sign_c2pa.py +6 -4
  10. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/api/tps/tasks.py +5 -2
  11. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/crypt/algorithms.py +8 -3
  12. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/crypt/tca_certs.py +16 -5
  13. {trufo-2.2.0 → trufo-2.2.2}/src/trufo.egg-info/PKG-INFO +4 -4
  14. {trufo-2.2.0 → trufo-2.2.2}/src/trufo.egg-info/requires.txt +3 -3
  15. {trufo-2.2.0 → trufo-2.2.2}/LICENSE +0 -0
  16. {trufo-2.2.0 → trufo-2.2.2}/README.md +0 -0
  17. {trufo-2.2.0 → trufo-2.2.2}/setup.cfg +0 -0
  18. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/api/__init__.py +0 -0
  19. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/api/auth.py +0 -0
  20. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/api/headers.py +0 -0
  21. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/api/loopback_auth.py +0 -0
  22. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/api/tca/__init__.py +0 -0
  23. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/api/tca/certs_cawg_interim.py +0 -0
  24. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/api/tps/__init__.py +0 -0
  25. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/api/tps/bind.py +0 -0
  26. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/api/tps/io.py +0 -0
  27. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/api/tps/records.py +0 -0
  28. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/c2pa/__init__.py +0 -0
  29. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/c2pa/actions.py +0 -0
  30. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/c2pa/ai_system.py +0 -0
  31. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/c2pa/assertions.py +0 -0
  32. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/c2pa/manifest.py +0 -0
  33. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/c2pa/redactions.py +0 -0
  34. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/c2pa/source_types.py +0 -0
  35. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/c2pa/thumbnails.py +0 -0
  36. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/c2pa/watermark.py +0 -0
  37. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/crypt/__init__.py +0 -0
  38. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/crypt/keygen.py +0 -0
  39. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/intf/__init__.py +0 -0
  40. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/intf/api_credentials.py +0 -0
  41. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/intf/c2pa_certificates.py +0 -0
  42. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/intf/cli.py +0 -0
  43. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/py.typed +0 -0
  44. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/util/__init__.py +0 -0
  45. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/util/credentials.py +0 -0
  46. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/util/deprecation.py +0 -0
  47. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/util/optional_imports.py +0 -0
  48. {trufo-2.2.0 → trufo-2.2.2}/src/trufo/util/warnings.py +0 -0
  49. {trufo-2.2.0 → trufo-2.2.2}/src/trufo.egg-info/SOURCES.txt +0 -0
  50. {trufo-2.2.0 → trufo-2.2.2}/src/trufo.egg-info/dependency_links.txt +0 -0
  51. {trufo-2.2.0 → trufo-2.2.2}/src/trufo.egg-info/entry_points.txt +0 -0
  52. {trufo-2.2.0 → trufo-2.2.2}/src/trufo.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: trufo
3
- Version: 2.2.0
3
+ Version: 2.2.2
4
4
  Summary: Trufo SDK for content provenance API services.
5
5
  License-Expression: Apache-2.0
6
6
  Project-URL: Homepage, https://trufo.ai
@@ -15,11 +15,11 @@ Requires-Dist: PyJWT>=2.6
15
15
  Requires-Dist: requests>=2.28
16
16
  Requires-Dist: uuid-utils>=0.6
17
17
  Provides-Extra: local-sign-only
18
- Requires-Dist: trufo-provenance[c2pa]<2.3.0,>=2.2.0; extra == "local-sign-only"
18
+ Requires-Dist: trufo-provenance[c2pa]<2.3.0,>=2.2.1; extra == "local-sign-only"
19
19
  Provides-Extra: local-full
20
- Requires-Dist: trufo-provenance[c2pa,pawprint]<2.3.0,>=2.2.0; extra == "local-full"
20
+ Requires-Dist: trufo-provenance[c2pa,pawprint]<2.3.0,>=2.2.1; extra == "local-full"
21
21
  Provides-Extra: provenance
22
- Requires-Dist: trufo-provenance[c2pa]<2.3.0,>=2.2.0; extra == "provenance"
22
+ Requires-Dist: trufo-provenance[c2pa]<2.3.0,>=2.2.1; extra == "provenance"
23
23
  Provides-Extra: test
24
24
  Requires-Dist: pytest>=7.0; extra == "test"
25
25
  Dynamic: license-file
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "trufo"
7
- version = "2.2.0"
7
+ version = "2.2.2"
8
8
  requires-python = ">=3.10"
9
9
  description = "Trufo SDK for content provenance API services."
10
10
  readme = "README.md"
@@ -21,9 +21,9 @@ dependencies = [
21
21
  # local-sign-only: distributed C2PA signing without the watermark engine
22
22
  # (no torch); local-full adds trufo-pawprint for local watermark embedding.
23
23
  # provenance is the legacy alias of local-sign-only.
24
- local-sign-only = ["trufo-provenance[c2pa]>=2.2.0,<2.3.0"]
25
- local-full = ["trufo-provenance[c2pa,pawprint]>=2.2.0,<2.3.0"]
26
- provenance = ["trufo-provenance[c2pa]>=2.2.0,<2.3.0"]
24
+ local-sign-only = ["trufo-provenance[c2pa]>=2.2.1,<2.3.0"]
25
+ local-full = ["trufo-provenance[c2pa,pawprint]>=2.2.1,<2.3.0"]
26
+ provenance = ["trufo-provenance[c2pa]>=2.2.1,<2.3.0"]
27
27
  test = ["pytest>=7.0"]
28
28
 
29
29
  [project.urls]
@@ -1,9 +1,14 @@
1
1
  # Copyright 2025-2026 Trufo, Inc. All rights reserved.
2
2
  # SPDX-License-Identifier: Apache-2.0
3
3
 
4
- from trufo.api.tca.certs_c2pa import create_instance, register_credential, request_c2pa_cert
4
+ from trufo.api.tca.certs_c2pa import (
5
+ create_instance,
6
+ register_credential,
7
+ request_c2pa_cert,
8
+ request_c2pa_cert_test,
9
+ )
5
10
  from trufo.api.tca.certs_cawg_interim import request_cawg_interim_cert
6
- from trufo.api.tca.certs_test import request_c2pa_test_cert, request_cawg_test_cert
11
+ from trufo.api.tca.certs_test import request_c2pa_dummy_cert, request_cawg_dummy_cert
7
12
  from trufo.api.tps.bind import (
8
13
  BindWatermarkResult,
9
14
  BindReserveResult,
@@ -37,9 +42,10 @@ from trufo.api.tps.sign_c2pa import (
37
42
  )
38
43
  from trufo.crypt.keygen import generate_keypair
39
44
  from trufo.util.credentials import load_api_key, save_api_key
45
+ from trufo.util.deprecation import deprecated_aliases
40
46
  from trufo.util.warnings import TrufoServerWarning
41
47
 
42
- __version__ = "2.2.0"
48
+ __version__ = "2.2.2"
43
49
 
44
50
  __all__ = [
45
51
  "ExecutionMode", "TaskType", "TaskStatus", "TaskReceipt", "TaskInfo",
@@ -63,9 +69,10 @@ __all__ = [
63
69
  "recover_content",
64
70
  "register_credential",
65
71
  "request_c2pa_cert",
66
- "request_c2pa_test_cert",
72
+ "request_c2pa_cert_test",
73
+ "request_c2pa_dummy_cert",
74
+ "request_cawg_dummy_cert",
67
75
  "request_cawg_interim_cert",
68
- "request_cawg_test_cert",
69
76
  "save_api_key",
70
77
  "set_content_status",
71
78
  "sign_c2pa",
@@ -77,3 +84,11 @@ __all__ = [
77
84
  "TrufoServerWarning",
78
85
  "watermark_media",
79
86
  ]
87
+
88
+ __getattr__ = deprecated_aliases(
89
+ globals(),
90
+ {
91
+ "request_c2pa_test_cert": "request_c2pa_dummy_cert",
92
+ "request_cawg_test_cert": "request_cawg_dummy_cert",
93
+ },
94
+ )
@@ -11,12 +11,15 @@ from trufo.util.deprecation import deprecated_aliases
11
11
 
12
12
  TRUFO_API_URL = "https://api.trufo.ai"
13
13
  TRUFO_API_URL_EUROPE = "https://eu.api.trufo.ai"
14
- # test signing runs on its own host, which serves the content routes (signing,
15
- # recovery, binding) for test keys
14
+ # test host: serves test-key requests (signing, recovery, binding) and test
15
+ # certificate enrollment; sign-in and token refresh stay on TRUFO_API_URL
16
16
  TRUFO_API_URL_TEST = "https://test.api.trufo.ai"
17
17
  TRUFO_CA_URL = "https://ca.trufo.ai"
18
+ TRUFO_CA_URL_TEST = "https://test.ca.trufo.ai"
18
19
  TRUFO_TSA_URL = "https://tsa.trufo.ai"
20
+ TRUFO_TSA_URL_TEST = "https://test.tsa.trufo.ai"
19
21
  TRUFO_OCSP_URL = "https://ocsp.trufo.ai"
22
+ TRUFO_OCSP_URL_TEST = "https://test.ocsp.trufo.ai"
20
23
 
21
24
  # webapp origin — where the browser is sent during loopback sign-in.
22
25
  # Overridable so the flow can be exercised against a non-production webapp; the
@@ -22,7 +22,7 @@ from trufo.api.auth import (
22
22
  poll_for_tokens,
23
23
  refresh_tokens,
24
24
  )
25
- from trufo.api.endpoints import TRUFO_API_URL
25
+ from trufo.api.endpoints import TRUFO_API_URL, TRUFO_API_URL_TEST
26
26
  from trufo.api.loopback_auth import BrowserUnavailableError, run_loopback_login
27
27
 
28
28
  logger = logging.getLogger(__name__)
@@ -55,6 +55,12 @@ class TrufoSession:
55
55
  self.refresh_token = refresh_token
56
56
  self.base_api_url = base_api_url
57
57
 
58
+ @property
59
+ def _auth_api_url(self) -> str:
60
+ """Base URL for sign-in and token refresh."""
61
+ # the test host has no sign-in or refresh routes; it accepts tokens issued by TRUFO_API_URL
62
+ return TRUFO_API_URL if self.base_api_url == TRUFO_API_URL_TEST else self.base_api_url
63
+
58
64
  def init_session(self, api_key: str, use_device: bool = False) -> None:
59
65
  """Sign in and obtain tokens.
60
66
 
@@ -72,7 +78,7 @@ class TrufoSession:
72
78
  """
73
79
  if not use_device:
74
80
  try:
75
- tokens = run_loopback_login(api_key, base_url=self.base_api_url)
81
+ tokens = run_loopback_login(api_key, base_url=self._auth_api_url)
76
82
  self.access_token = tokens.access_token
77
83
  self.refresh_token = tokens.refresh_token
78
84
  return
@@ -88,7 +94,7 @@ class TrufoSession:
88
94
  Prints the verification URL for the user, then polls until
89
95
  the user approves (or the code expires).
90
96
  """
91
- auth_resp = initiate_device_auth(api_key, base_url=self.base_api_url)
97
+ auth_resp = initiate_device_auth(api_key, base_url=self._auth_api_url)
92
98
 
93
99
  # keep the pre-filled URL: the /device page has no code-entry field yet,
94
100
  # so the bare verification_uri would land the user on "Invalid link"
@@ -98,7 +104,7 @@ class TrufoSession:
98
104
  tokens = poll_for_tokens(
99
105
  api_key,
100
106
  auth_resp.device_code,
101
- base_url=self.base_api_url,
107
+ base_url=self._auth_api_url,
102
108
  interval=auth_resp.interval,
103
109
  timeout=auth_resp.expires_in,
104
110
  )
@@ -141,7 +147,7 @@ class TrufoSession:
141
147
  if not self.refresh_token:
142
148
  raise AuthError("No refresh token available.")
143
149
  try:
144
- tokens = refresh_tokens(self.refresh_token, base_url=self.base_api_url)
150
+ tokens = refresh_tokens(self.refresh_token, base_url=self._auth_api_url)
145
151
  except RuntimeError as exc:
146
152
  raise AuthError("Session expired. Please log in again.") from exc
147
153
  self.access_token = tokens.access_token
@@ -18,6 +18,9 @@ from trufo.api.endpoints import (
18
18
  GP_INSTANCE_CREATE_PATH,
19
19
  RA_CSR_JWT_PATH,
20
20
  TRUFO_API_URL,
21
+ TRUFO_API_URL_TEST,
22
+ TRUFO_CA_URL,
23
+ TRUFO_CA_URL_TEST,
21
24
  )
22
25
  from trufo.api.session import TrufoSession
23
26
  from trufo.api.headers import sdk_headers
@@ -34,7 +37,8 @@ def create_instance(client: TrufoSession, gp_id: str, name: str) -> str:
34
37
  """Create a generator product instance.
35
38
 
36
39
  Corresponds to: POST /gproduct/instance/create
37
- Requires: authenticated session (Bearer JWT), product must have PV approved.
40
+ Requires: authenticated session (Bearer JWT), product must have PV approved
41
+ (a test product's PV is approved when it is created).
38
42
 
39
43
  Args:
40
44
  client: Authenticated TrufoSession.
@@ -128,6 +132,8 @@ def _request_c2pa_csr_jwt(
128
132
  gpic_assertion: str,
129
133
  leaf_type: LeafType,
130
134
  validity_days: int | None = None,
135
+ *,
136
+ trufo_api_url: str,
131
137
  ) -> str:
132
138
  """Request a CSR JWT from the Registration Authority.
133
139
 
@@ -138,6 +144,7 @@ def _request_c2pa_csr_jwt(
138
144
  leaf_type: Certificate type to request.
139
145
  validity_days: Requested validity in days. If ``None``, the
140
146
  server uses its default for the leaf type.
147
+ trufo_api_url: Trufo API base URL.
141
148
 
142
149
  Returns:
143
150
  The CSR JWT string.
@@ -154,7 +161,7 @@ def _request_c2pa_csr_jwt(
154
161
 
155
162
  # RA authenticates via client_assertion in the body, not Bearer JWT
156
163
  resp = requests.post(
157
- f"{TRUFO_API_URL}{RA_CSR_JWT_PATH}",
164
+ f"{trufo_api_url}{RA_CSR_JWT_PATH}",
158
165
  headers=sdk_headers(**{"Content-Type": "application/json"}),
159
166
  json=body,
160
167
  timeout=30,
@@ -173,6 +180,9 @@ def request_c2pa_cert(
173
180
  private_key_signer: str | Path | bytes | ec.EllipticCurvePrivateKey,
174
181
  leaf_type: LeafType = LeafType.C2PA_L1,
175
182
  validity_days: int | None = None,
183
+ *,
184
+ trufo_api_url: str = TRUFO_API_URL,
185
+ trufo_ca_url: str = TRUFO_CA_URL,
176
186
  ) -> bytes:
177
187
  """Run the full C2PA certificate enrollment pipeline.
178
188
 
@@ -190,6 +200,8 @@ def request_c2pa_cert(
190
200
  leaf_type: Certificate type (default: ``C2PA_L1``).
191
201
  validity_days: Requested validity in days. ``None`` lets the
192
202
  server decide.
203
+ trufo_api_url: Trufo API base URL. Defaults to production.
204
+ trufo_ca_url: Trufo CA base URL. Defaults to production.
193
205
 
194
206
  Returns:
195
207
  PEM bytes for the certificate chain (leaf + intermediates,
@@ -207,14 +219,62 @@ def request_c2pa_cert(
207
219
 
208
220
  # 2. build GPIC assertion, request CSR JWT
209
221
  assertion = _build_gpic_assertion(gpi_id, gpic_id, instance_key_pem, instance_alg.alg_name)
210
- csr_jwt = _request_c2pa_csr_jwt(assertion, leaf_type, validity_days)
222
+ csr_jwt = _request_c2pa_csr_jwt(
223
+ assertion, leaf_type, validity_days, trufo_api_url=trufo_api_url
224
+ )
211
225
 
212
226
  # 3. build CSR with leaf signing key
213
227
  csr_der = build_csr(private_key_signer)
214
228
 
215
229
  # 4. EST enrollment
216
- pkcs7_b64 = est_enroll(csr_jwt, csr_der, leaf_type.value)
230
+ pkcs7_b64 = est_enroll(csr_jwt, csr_der, leaf_type.value, trufo_ca_url=trufo_ca_url)
217
231
 
218
232
  # 5. extract certs
219
233
  cert_chain_pem = extract_cert_chain(pkcs7_b64)
220
234
  return cert_chain_pem
235
+
236
+
237
+ def request_c2pa_cert_test(
238
+ gpi_id: str,
239
+ gpic_id: str,
240
+ instance_key_pem: str,
241
+ private_key_signer: str | Path | bytes | ec.EllipticCurvePrivateKey,
242
+ validity_days: int | None = None,
243
+ *,
244
+ trufo_api_url: str = TRUFO_API_URL_TEST,
245
+ trufo_ca_url: str = TRUFO_CA_URL_TEST,
246
+ ) -> bytes:
247
+ """Request a C2PA certificate from the Trufo test CA.
248
+
249
+ Same enrollment as :func:`request_c2pa_cert`, against the Trufo test hosts.
250
+ Create the instance and credential with
251
+ ``TrufoSession(base_api_url=TRUFO_API_URL_TEST)``. The leaf type is always
252
+ ``C2PA_L1``. Unlike :func:`request_c2pa_dummy_cert`, this needs a Trufo account.
253
+
254
+ Args:
255
+ gpi_id: Instance ID (e.g. ``"gpi_..."``)
256
+ gpic_id: Credential ID (e.g. ``"gpic_..."``)
257
+ instance_key_pem: Instance private key PEM (signs the GPIC
258
+ assertion).
259
+ private_key_signer: Leaf private key — PEM ``bytes``, a
260
+ filesystem path (``str`` / ``Path``), or an
261
+ ``ec.EllipticCurvePrivateKey`` (e.g. AWS KMS adapter).
262
+ validity_days: Requested validity in days. ``None`` lets the
263
+ server decide.
264
+ trufo_api_url: Trufo API base URL. Defaults to the Trufo test host (test.api.trufo.ai).
265
+ trufo_ca_url: Trufo CA base URL. Defaults to the Trufo test CA (test.ca.trufo.ai).
266
+
267
+ Returns:
268
+ PEM bytes for the certificate chain (leaf + intermediates,
269
+ self-signed root excluded).
270
+ """
271
+ return request_c2pa_cert(
272
+ gpi_id,
273
+ gpic_id,
274
+ instance_key_pem,
275
+ private_key_signer,
276
+ LeafType.C2PA_L1,
277
+ validity_days,
278
+ trufo_api_url=trufo_api_url,
279
+ trufo_ca_url=trufo_ca_url,
280
+ )
@@ -2,9 +2,9 @@
2
2
  # SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  """
5
- Test certificate enrollment helpers for Trufo TCA.
5
+ Dummy certificate enrollment helpers for Trufo TCA.
6
6
 
7
- Provides test-only enrollment for C2PA and CAWG interim profiles.
7
+ Provides dummy certificate enrollment for C2PA and CAWG interim profiles.
8
8
  """
9
9
 
10
10
  import time
@@ -15,15 +15,16 @@ from cryptography.hazmat.primitives.asymmetric import ec
15
15
  from uuid_utils import uuid7
16
16
 
17
17
  from trufo.crypt.tca_certs import (
18
- TEST_HMAC_SECRET,
18
+ DUMMY_HMAC_SECRET,
19
19
  LeafType,
20
20
  build_csr,
21
21
  est_enroll,
22
22
  extract_cert_chain,
23
23
  )
24
+ from trufo.util.deprecation import deprecated_aliases
24
25
 
25
26
 
26
- def _build_test_c2pa_csr_jwt(
27
+ def _build_dummy_c2pa_csr_jwt(
27
28
  leaf_type: LeafType,
28
29
  org_name: str,
29
30
  common_name: str,
@@ -31,13 +32,13 @@ def _build_test_c2pa_csr_jwt(
31
32
  country: str | None = None,
32
33
  record_id: str | None = None,
33
34
  ) -> str:
34
- """Build a C2PA test CSR JWT signed with the public test HMAC secret.
35
+ """Build a C2PA dummy CSR JWT signed with the public dummy HMAC secret.
35
36
 
36
37
  Args:
37
- leaf_type: Must be ``C2PA_L1_TEST`` or ``C2PA_L2_TEST``.
38
+ leaf_type: Must be ``C2PA_L1_DUMMY`` or ``C2PA_L2_DUMMY``.
38
39
  org_name: Organization name for the certificate subject (O).
39
40
  common_name: Common name for the certificate subject (CN).
40
- country: Optional country for the certificate subject (C).
41
+ country: Two-letter country code for the certificate subject (C).
41
42
  record_id: Optional product record UUID to embed; a UUIDv7 is
42
43
  generated when omitted.
43
44
 
@@ -45,10 +46,10 @@ def _build_test_c2pa_csr_jwt(
45
46
  Compact-serialized HS256 JWT string.
46
47
 
47
48
  Raises:
48
- ValueError: If *leaf_type* is not a C2PA test type.
49
+ ValueError: If *leaf_type* is not a C2PA dummy type.
49
50
  """
50
- if leaf_type not in (LeafType.C2PA_L1_TEST, LeafType.C2PA_L2_TEST):
51
- raise ValueError(f"leaf_type must be a C2PA test type, got {leaf_type.value}")
51
+ if leaf_type not in (LeafType.C2PA_L1_DUMMY, LeafType.C2PA_L2_DUMMY):
52
+ raise ValueError(f"leaf_type must be a C2PA dummy type, got {leaf_type.value}")
52
53
 
53
54
  distinguished_name = {"O": org_name, "CN": common_name}
54
55
  if country is not None:
@@ -67,37 +68,38 @@ def _build_test_c2pa_csr_jwt(
67
68
  "record_id": record_id if record_id is not None else str(uuid7()),
68
69
  "instance_id": f"gpi_{uuid7()}",
69
70
  }
70
- return pyjwt.encode(payload, TEST_HMAC_SECRET, algorithm="HS256")
71
+ return pyjwt.encode(payload, DUMMY_HMAC_SECRET, algorithm="HS256")
71
72
 
72
73
 
73
- def request_c2pa_test_cert(
74
+ def request_c2pa_dummy_cert(
74
75
  org_name: str,
75
76
  common_name: str,
76
77
  private_key_signer: str | Path | bytes | ec.EllipticCurvePrivateKey,
77
- leaf_type: LeafType = LeafType.C2PA_L1_TEST,
78
+ leaf_type: LeafType = LeafType.C2PA_L1_DUMMY,
78
79
  *,
79
80
  country: str | None = None,
80
81
  record_id: str | None = None,
81
82
  ) -> bytes:
82
- """Obtain a test C2PA certificate via the test EST flow.
83
+ """Obtain a dummy C2PA certificate via the dummy EST flow.
83
84
 
84
85
  No account authentication is required — the CSR JWT is signed with
85
- the publicly known test HMAC secret.
86
+ the publicly known dummy HMAC secret.
86
87
 
87
88
  Args:
88
89
  org_name: Organization name for the certificate subject.
89
90
  common_name: Common name for the certificate subject.
90
91
  private_key_signer: Leaf private key (PEM bytes, path, or
91
92
  ``ec.EllipticCurvePrivateKey``).
92
- leaf_type: Test leaf type (default: ``C2PA_L1_TEST``).
93
- country: Optional country for the certificate subject (C).
93
+ leaf_type: Dummy leaf type (default: ``C2PA_L1_DUMMY``).
94
+ country: Two-letter country code for the certificate subject (C).
95
+ The CA refuses an enrollment without one.
94
96
  record_id: Optional product record UUID to embed; a UUIDv7 is
95
97
  generated when omitted.
96
98
 
97
99
  Returns:
98
100
  PEM certificate chain bytes.
99
101
  """
100
- csr_jwt = _build_test_c2pa_csr_jwt(
102
+ csr_jwt = _build_dummy_c2pa_csr_jwt(
101
103
  leaf_type, org_name, common_name, country=country, record_id=record_id
102
104
  )
103
105
  csr_der = build_csr(private_key_signer)
@@ -106,19 +108,26 @@ def request_c2pa_test_cert(
106
108
  return cert_chain_pem
107
109
 
108
110
 
109
- def _build_test_cawg_csr_jwt(
111
+ def _build_dummy_cawg_csr_jwt(
110
112
  org_name: str,
111
113
  common_name: str,
114
+ *,
115
+ country: str | None = None,
112
116
  ) -> str:
113
- """Build a CAWG interim test CSR JWT signed with the public test HMAC secret.
117
+ """Build a CAWG interim dummy CSR JWT signed with the public dummy HMAC secret.
114
118
 
115
119
  Args:
116
120
  org_name: Organization name for the certificate subject (O).
117
121
  common_name: Common name for the certificate subject (CN).
122
+ country: Two-letter country code for the certificate subject (C).
118
123
 
119
124
  Returns:
120
125
  Compact-serialized HS256 JWT string.
121
126
  """
127
+ distinguished_name = {"O": org_name, "CN": common_name}
128
+ if country is not None:
129
+ distinguished_name["C"] = country
130
+
122
131
  now = int(time.time())
123
132
  payload = {
124
133
  "iss": "trufo",
@@ -127,38 +136,49 @@ def _build_test_cawg_csr_jwt(
127
136
  "jti": str(uuid7()),
128
137
  "iat": now,
129
138
  "exp": now + 300,
130
- "leaf_type": LeafType.CAWG_INTERIM_TEST.value,
131
- "distinguished_name": {
132
- "O": org_name,
133
- "CN": common_name,
134
- },
139
+ "leaf_type": LeafType.CAWG_INTERIM_DUMMY.value,
140
+ "distinguished_name": distinguished_name,
135
141
  "record_id": "",
136
142
  "instance_id": "",
137
143
  }
138
- return pyjwt.encode(payload, TEST_HMAC_SECRET, algorithm="HS256")
144
+ return pyjwt.encode(payload, DUMMY_HMAC_SECRET, algorithm="HS256")
139
145
 
140
146
 
141
- def request_cawg_test_cert(
147
+ def request_cawg_dummy_cert(
142
148
  org_name: str,
143
149
  common_name: str,
144
150
  private_key_signer: str | Path | bytes | ec.EllipticCurvePrivateKey,
151
+ *,
152
+ country: str | None = None,
145
153
  ) -> bytes:
146
- """Obtain a test CAWG interim certificate via the test EST flow.
154
+ """Obtain a dummy CAWG interim certificate via the dummy EST flow.
147
155
 
148
156
  No account authentication is required — the CSR JWT is signed with
149
- the publicly known test HMAC secret.
157
+ the publicly known dummy HMAC secret.
150
158
 
151
159
  Args:
152
160
  org_name: Organization name for the certificate subject.
153
161
  common_name: Common name for the certificate subject.
154
162
  private_key_signer: Leaf private key (PEM bytes, path, or
155
163
  ``ec.EllipticCurvePrivateKey``).
164
+ country: Two-letter country code for the certificate subject (C).
165
+ The CA refuses an enrollment without one.
156
166
 
157
167
  Returns:
158
168
  PEM certificate chain bytes.
159
169
  """
160
- csr_jwt = _build_test_cawg_csr_jwt(org_name, common_name)
170
+ csr_jwt = _build_dummy_cawg_csr_jwt(org_name, common_name, country=country)
161
171
  csr_der = build_csr(private_key_signer)
162
- pkcs7_b64 = est_enroll(csr_jwt, csr_der, LeafType.CAWG_INTERIM_TEST.value)
172
+ pkcs7_b64 = est_enroll(csr_jwt, csr_der, LeafType.CAWG_INTERIM_DUMMY.value)
163
173
  cert_chain_pem = extract_cert_chain(pkcs7_b64)
164
174
  return cert_chain_pem
175
+
176
+
177
+ __getattr__ = deprecated_aliases(
178
+ globals(),
179
+ {
180
+ "request_c2pa_test_cert": "request_c2pa_dummy_cert",
181
+ "request_cawg_test_cert": "request_cawg_dummy_cert",
182
+ "TEST_HMAC_SECRET": "DUMMY_HMAC_SECRET",
183
+ },
184
+ )
@@ -24,7 +24,8 @@ class RecoverContentResult:
24
24
  AI system's public information (``ai_system``) and the type of AI
25
25
  involvement (``ai_involvement``), not a manifest.
26
26
  ``oid`` is set only when the mark belongs to your own
27
- organization. Unknown future fields are ignored.
27
+ organization; so is a per-embed record's ``status`` (``"active"`` or
28
+ ``"inactive"``). Unknown future fields are ignored.
28
29
  """
29
30
 
30
31
  detected: bool
@@ -36,6 +37,7 @@ class RecoverContentResult:
36
37
  wid_allocation_mode: str | None = None
37
38
  ai_involvement: str | None = None
38
39
  ai_system: dict | None = None
40
+ status: str | None = None
39
41
 
40
42
 
41
43
  def recover_content(
@@ -94,6 +96,7 @@ def recover_content(
94
96
  wid_allocation_mode=payload.get("wid_allocation_mode"),
95
97
  ai_involvement=payload.get("ai_involvement"),
96
98
  ai_system=payload.get("ai_system"),
99
+ status=payload.get("status"),
97
100
  )
98
101
 
99
102
 
@@ -700,8 +700,9 @@ def sign_c2pa_test(
700
700
  see the module docstring for when to set this explicitly.
701
701
  manifest_settings: Optional structured C2PA manifest settings.
702
702
  branded_gp_id: ID (``gp_...``) of one of your organization's branded
703
- generator products; the content is signed as that product. Omit to
704
- sign with Trufo's own C2PA signer.
703
+ generator products; the content is signed as that product. ``test``
704
+ may be used in place of a product ID. Omit to sign with Trufo's own
705
+ C2PA signer.
705
706
  signed_input_policy: What to do when the input is already C2PA-signed; omit for ``auto``.
706
707
  signed_ingredient_policy: What to do when an ingredient's media is already
707
708
  C2PA-signed; omit for ``auto``.
@@ -779,8 +780,9 @@ def sign_c2pa_distributed_test(
779
780
  see the module docstring for when to set this explicitly.
780
781
  manifest_settings: Optional structured C2PA manifest settings.
781
782
  branded_gp_id: ID (``gp_...``) of one of your organization's branded
782
- generator products; the content is signed as that product. Omit to
783
- sign with Trufo's own C2PA signer.
783
+ generator products; the content is signed as that product. ``test``
784
+ may be used in place of a product ID. Omit to sign with Trufo's own
785
+ C2PA signer.
784
786
  signed_input_policy: What to do when the input is already C2PA-signed; omit for ``auto``.
785
787
  signed_ingredient_policy: What to do when an ingredient's media is already
786
788
  C2PA-signed; omit for ``auto``.
@@ -80,7 +80,7 @@ class BindWatermarkTaskResult:
80
80
 
81
81
  @dataclass(frozen=True)
82
82
  class TaskInfo(TaskReceipt):
83
- """Task status, progress, result, and optional failure code/status.
83
+ """Task status, progress, result, and optional failure code/status/message.
84
84
 
85
85
  error_http_status describes the task failure, not the status-query response.
86
86
  """
@@ -96,6 +96,7 @@ class TaskInfo(TaskReceipt):
96
96
  error_code: str | None = None
97
97
  error_http_status: int | None = None
98
98
  result: SignC2PATaskResult | BindWatermarkTaskResult | None = None
99
+ error_message: str | None = None
99
100
 
100
101
 
101
102
  class TaskFailedError(RuntimeError):
@@ -105,7 +106,8 @@ class TaskFailedError(RuntimeError):
105
106
  self.task = task
106
107
  self.task_id = task.task_id
107
108
  code = task.error_code if task.error_code is not None else task.status.value
108
- super().__init__(f"Task {task.task_id} failed: {code}.")
109
+ detail = f" {task.error_message}" if task.error_message else ""
110
+ super().__init__(f"Task {task.task_id} failed: {code}.{detail}")
109
111
 
110
112
 
111
113
  class TaskWaitTimeoutError(TimeoutError):
@@ -123,6 +125,7 @@ def _parse_task_response(payload: dict, response_type):
123
125
  if response_type is TaskInfo and payload.get("error"):
124
126
  values["error_code"] = payload["error"]["code"]
125
127
  values["error_http_status"] = payload["error"]["http_status"]
128
+ values["error_message"] = payload["error"].get("message")
126
129
  if values.get("result"):
127
130
  result_type = SignC2PATaskResult if values["task_type"] == TaskType.C2PA_SIGN else BindWatermarkTaskResult
128
131
  result = values["result"]
@@ -30,12 +30,17 @@ class LeafType(str, Enum):
30
30
 
31
31
  C2PA_L1 = "c2pa-l1"
32
32
  C2PA_L2 = "c2pa-l2"
33
- C2PA_L1_TEST = "c2pa-l1-test"
34
- C2PA_L2_TEST = "c2pa-l2-test"
33
+ C2PA_L1_DUMMY = "c2pa-l1-test"
34
+ C2PA_L2_DUMMY = "c2pa-l2-test"
35
35
  CTSA = "ctsa"
36
36
  CTSA_TEST = "ctsa-test"
37
37
  CAWG_INTERIM = "cawg-interim"
38
- CAWG_INTERIM_TEST = "cawg-interim-test"
38
+ CAWG_INTERIM_DUMMY = "cawg-interim-test"
39
+
40
+ # deprecated aliases: enum members cannot warn the way module names do
41
+ C2PA_L1_TEST = C2PA_L1_DUMMY
42
+ C2PA_L2_TEST = C2PA_L2_DUMMY
43
+ CAWG_INTERIM_TEST = CAWG_INTERIM_DUMMY
39
44
 
40
45
 
41
46
  ALG_TO_CURVE = {
@@ -24,12 +24,13 @@ from cryptography.x509.oid import NameOID
24
24
 
25
25
  from trufo.api.endpoints import TRUFO_CA_URL
26
26
  from trufo.crypt.algorithms import ALG_TO_CURVE, ALG_TO_HASH, LeafType
27
+ from trufo.util.deprecation import deprecated_aliases
27
28
 
28
- TEST_HMAC_SECRET = "hello-trufo"
29
+ DUMMY_HMAC_SECRET = "hello-trufo"
29
30
 
30
31
  __all__ = [
32
+ "DUMMY_HMAC_SECRET",
31
33
  "LeafType",
32
- "TEST_HMAC_SECRET",
33
34
  "build_csr",
34
35
  "est_enroll",
35
36
  "extract_cert_chain",
@@ -99,16 +100,23 @@ def build_csr(
99
100
  return csr.public_bytes(serialization.Encoding.DER)
100
101
 
101
102
 
102
- def est_enroll(csr_jwt: str, csr_der: bytes, leaf_type_value: str) -> bytes:
103
+ def est_enroll(
104
+ csr_jwt: str,
105
+ csr_der: bytes,
106
+ leaf_type_value: str,
107
+ *,
108
+ trufo_ca_url: str = TRUFO_CA_URL,
109
+ ) -> bytes:
103
110
  """Submit a CSR to the CA via EST simpleenroll (RFC 7030).
104
111
 
105
112
  The CSR JWT is sent as the HTTP Basic auth password (username is
106
113
  empty).
107
114
 
108
115
  Args:
109
- csr_jwt: Signed CSR JWT (from RA or test HMAC).
116
+ csr_jwt: Signed CSR JWT (from RA or dummy HMAC).
110
117
  csr_der: DER-encoded PKCS#10 CSR.
111
118
  leaf_type_value: Leaf type string (e.g. ``"c2pa-l1"``).
119
+ trufo_ca_url: Trufo CA base URL. Defaults to production.
112
120
 
113
121
  Returns:
114
122
  Raw response body (base64-encoded PKCS#7).
@@ -120,7 +128,7 @@ def est_enroll(csr_jwt: str, csr_der: bytes, leaf_type_value: str) -> bytes:
120
128
  csr_b64 = base64.b64encode(csr_der).decode()
121
129
 
122
130
  resp = requests.post(
123
- f"{TRUFO_CA_URL}/.well-known/est/{leaf_type_value}/simpleenroll",
131
+ f"{trufo_ca_url}/.well-known/est/{leaf_type_value}/simpleenroll",
124
132
  headers={
125
133
  "Content-Type": "application/pkcs10",
126
134
  "Authorization": f"Basic {auth_value}",
@@ -221,3 +229,6 @@ def _order_ca_chain(
221
229
  # append any unreachable certs (shouldn't happen with well-formed PKCS#7)
222
230
  ordered.extend(by_subject.values())
223
231
  return ordered
232
+
233
+
234
+ __getattr__ = deprecated_aliases(globals(), {"TEST_HMAC_SECRET": "DUMMY_HMAC_SECRET"})
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: trufo
3
- Version: 2.2.0
3
+ Version: 2.2.2
4
4
  Summary: Trufo SDK for content provenance API services.
5
5
  License-Expression: Apache-2.0
6
6
  Project-URL: Homepage, https://trufo.ai
@@ -15,11 +15,11 @@ Requires-Dist: PyJWT>=2.6
15
15
  Requires-Dist: requests>=2.28
16
16
  Requires-Dist: uuid-utils>=0.6
17
17
  Provides-Extra: local-sign-only
18
- Requires-Dist: trufo-provenance[c2pa]<2.3.0,>=2.2.0; extra == "local-sign-only"
18
+ Requires-Dist: trufo-provenance[c2pa]<2.3.0,>=2.2.1; extra == "local-sign-only"
19
19
  Provides-Extra: local-full
20
- Requires-Dist: trufo-provenance[c2pa,pawprint]<2.3.0,>=2.2.0; extra == "local-full"
20
+ Requires-Dist: trufo-provenance[c2pa,pawprint]<2.3.0,>=2.2.1; extra == "local-full"
21
21
  Provides-Extra: provenance
22
- Requires-Dist: trufo-provenance[c2pa]<2.3.0,>=2.2.0; extra == "provenance"
22
+ Requires-Dist: trufo-provenance[c2pa]<2.3.0,>=2.2.1; extra == "provenance"
23
23
  Provides-Extra: test
24
24
  Requires-Dist: pytest>=7.0; extra == "test"
25
25
  Dynamic: license-file
@@ -4,13 +4,13 @@ requests>=2.28
4
4
  uuid-utils>=0.6
5
5
 
6
6
  [local-full]
7
- trufo-provenance[c2pa,pawprint]<2.3.0,>=2.2.0
7
+ trufo-provenance[c2pa,pawprint]<2.3.0,>=2.2.1
8
8
 
9
9
  [local-sign-only]
10
- trufo-provenance[c2pa]<2.3.0,>=2.2.0
10
+ trufo-provenance[c2pa]<2.3.0,>=2.2.1
11
11
 
12
12
  [provenance]
13
- trufo-provenance[c2pa]<2.3.0,>=2.2.0
13
+ trufo-provenance[c2pa]<2.3.0,>=2.2.1
14
14
 
15
15
  [test]
16
16
  pytest>=7.0
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes