tba-concrete-claim-confirmation 0.4.0.dev2__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,13 @@
1
+ Metadata-Version: 2.4
2
+ Name: tba-concrete-claim-confirmation
3
+ Version: 0.4.0.dev2
4
+ Summary:
5
+ Requires-Python: >=3.10,<3.15
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: Programming Language :: Python :: 3.10
8
+ Classifier: Programming Language :: Python :: 3.11
9
+ Classifier: Programming Language :: Python :: 3.12
10
+ Classifier: Programming Language :: Python :: 3.13
11
+ Classifier: Programming Language :: Python :: 3.14
12
+ Requires-Dist: tba-bases-claim (==0.4.0.dev2)
13
+ Requires-Dist: tba-primitives-identity (==0.4.0.dev2)
@@ -0,0 +1,10 @@
1
+ [project]
2
+ name="tba-concrete-claim-confirmation"
3
+ version="0.4.0.dev2"
4
+ requires-python=">=3.10,<3.15"
5
+ dependencies=["tba-primitives-identity==0.4.0.dev2","tba-bases-claim==0.4.0.dev2"]
6
+ [build-system]
7
+ requires=["poetry-core>=1.0.0"]
8
+ build-backend="poetry.core.masonry.api"
9
+ [tool.poetry]
10
+ packages=[{include="tba_concrete_claim_confirmation",from="src"}]
@@ -0,0 +1,32 @@
1
+ """Standalone JOSE confirmation claim."""
2
+
3
+ from tba_bases_claim import ClaimBase
4
+ from tba_primitives_identity import ClaimType, ClaimValueType
5
+
6
+
7
+ class ConfirmationClaim(ClaimBase):
8
+ claim_name = "cnf"
9
+ default_claim_type = ClaimType.AUTHORIZATION
10
+ default_value_type = ClaimValueType.JSON_OBJECT
11
+ default_standards = ("RFC7800", "RFC8705", "RFC9449")
12
+
13
+ @classmethod
14
+ def validate_value(cls, value):
15
+ if not isinstance(value, dict) or len(value) != 1:
16
+ raise ValueError("cnf requires exactly one confirmation member")
17
+
18
+ method, confirmation = next(iter(value.items()))
19
+ if method == "jwk":
20
+ if not isinstance(confirmation, dict) or not confirmation.get("kty"):
21
+ raise ValueError("cnf.jwk requires a public JWK object")
22
+ if "d" in confirmation:
23
+ raise ValueError("cnf.jwk must not contain private key material")
24
+ return
25
+ if method in {"jkt", "x5t#S256"}:
26
+ if not isinstance(confirmation, str) or not confirmation:
27
+ raise ValueError(f"cnf.{method} requires a non-empty thumbprint")
28
+ return
29
+ raise ValueError("unsupported JWT confirmation method")
30
+
31
+
32
+ __all__ = ["ConfirmationClaim"]