tba-profile-workload-proof-wimse-wpt 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,11 @@
1
+ Metadata-Version: 2.4
2
+ Name: tba-profile-workload-proof-wimse-wpt
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
@@ -0,0 +1,10 @@
1
+ [project]
2
+ name="tba-profile-workload-proof-wimse-wpt"
3
+ version="0.4.0.dev2"
4
+ requires-python=">=3.10,<3.15"
5
+ dependencies=[]
6
+ [build-system]
7
+ requires=["poetry-core>=1.0.0"]
8
+ build-backend="poetry.core.masonry.api"
9
+ [tool.poetry]
10
+ packages=[{include="tba_profile_workload_proof_wimse_wpt",from="src"}]
@@ -0,0 +1,11 @@
1
+ from .validation import OPTIONAL_BINDING_CLAIMS, REQUIRED_WPT_CLAIMS, validate_wpt
2
+ from .versions import CURRENT_VERSION, VERSION_HISTORY, WptVersion
3
+
4
+ __all__ = [
5
+ "CURRENT_VERSION",
6
+ "OPTIONAL_BINDING_CLAIMS",
7
+ "REQUIRED_WPT_CLAIMS",
8
+ "VERSION_HISTORY",
9
+ "WptVersion",
10
+ "validate_wpt",
11
+ ]
@@ -0,0 +1,5 @@
1
+ """Capability bindings owned by the versioned protocol package."""
2
+
3
+ PROTOCOL_CAPABILITY_BINDINGS: tuple[str, ...] = ()
4
+
5
+ __all__ = ["PROTOCOL_CAPABILITY_BINDINGS"]
@@ -0,0 +1,5 @@
1
+ """Claim vocabulary selected by the versioned protocol package."""
2
+
3
+ PROTOCOL_CLAIM_NAMES: tuple[str, ...] = ()
4
+
5
+ __all__ = ["PROTOCOL_CLAIM_NAMES"]
@@ -0,0 +1,3 @@
1
+ def require_version(identifier: str) -> None:
2
+ if identifier != "draft-ietf-wimse-wpt-01":
3
+ raise ValueError(f"unsupported WPT draft: {identifier}")
@@ -0,0 +1,8 @@
1
+ """Errors raised by the versioned protocol package."""
2
+
3
+
4
+ class ProtocolProfileError(ValueError):
5
+ """The artifact or request does not satisfy the selected protocol profile."""
6
+
7
+
8
+ __all__ = ["ProtocolProfileError"]
@@ -0,0 +1,10 @@
1
+ FEATURES = frozenset(
2
+ {
3
+ "wpt-jwt",
4
+ "wit-hash",
5
+ "access-token-hash",
6
+ "transaction-token-hash",
7
+ "other-token-hashes",
8
+ "replay-jti",
9
+ }
10
+ )
@@ -0,0 +1,6 @@
1
+ def migration_path(
2
+ source: str, target: str = "draft-ietf-wimse-wpt-01"
3
+ ) -> tuple[str, ...]:
4
+ if source == target:
5
+ return ()
6
+ raise ValueError(f"manual WPT draft migration required: {source} to {target}")
@@ -0,0 +1,5 @@
1
+ """Wire-schema inventory owned by the versioned protocol package."""
2
+
3
+ PROTOCOL_WIRE_SCHEMA_NAMES: tuple[str, ...] = ()
4
+
5
+ __all__ = ["PROTOCOL_WIRE_SCHEMA_NAMES"]
@@ -0,0 +1,35 @@
1
+ from collections.abc import Mapping, Sequence
2
+
3
+ REQUIRED_WPT_CLAIMS = frozenset({"aud", "exp", "jti", "wth"})
4
+ OPTIONAL_BINDING_CLAIMS = frozenset({"ath", "tth", "oth"})
5
+
6
+
7
+ def validate_wpt(
8
+ headers: Mapping[str, object],
9
+ claims: Mapping[str, object],
10
+ *,
11
+ expected_audience: str,
12
+ expected_wit_hash: str,
13
+ ) -> None:
14
+ if headers.get("typ") != "wpt+jwt":
15
+ raise ValueError("WPT requires typ=wpt+jwt")
16
+ if headers.get("alg") in {None, "none"}:
17
+ raise ValueError("WPT must be signed with the WIT confirmation key")
18
+ missing = REQUIRED_WPT_CLAIMS.difference(claims)
19
+ if missing:
20
+ raise ValueError(f"missing WPT claims: {sorted(missing)}")
21
+ aud = claims["aud"]
22
+ audiences = (
23
+ (aud,)
24
+ if isinstance(aud, str)
25
+ else tuple(aud)
26
+ if isinstance(aud, Sequence)
27
+ else ()
28
+ )
29
+ if expected_audience not in audiences:
30
+ raise ValueError("WPT audience mismatch")
31
+ if claims["wth"] != expected_wit_hash:
32
+ raise ValueError("WPT does not bind the presented WIT")
33
+ oth = claims.get("oth", ())
34
+ if not isinstance(oth, (Mapping, Sequence)):
35
+ raise ValueError("WPT oth must contain token hashes")
@@ -0,0 +1,16 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass(frozen=True, slots=True)
5
+ class WptVersion:
6
+ identifier: str
7
+ status: str
8
+ specification_uri: str
9
+
10
+
11
+ CURRENT_VERSION = WptVersion(
12
+ "draft-ietf-wimse-wpt-01",
13
+ "IETF-draft",
14
+ "https://datatracker.ietf.org/doc/draft-ietf-wimse-wpt/01/",
15
+ )
16
+ VERSION_HISTORY = (CURRENT_VERSION,)