tba-contracts-digital-credential 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.
- tba_contracts_digital_credential-0.4.0.dev2/PKG-INFO +18 -0
- tba_contracts_digital_credential-0.4.0.dev2/README.md +3 -0
- tba_contracts_digital_credential-0.4.0.dev2/pyproject.toml +15 -0
- tba_contracts_digital_credential-0.4.0.dev2/src/tba_contracts_digital_credential/__init__.py +50 -0
- tba_contracts_digital_credential-0.4.0.dev2/src/tba_contracts_digital_credential/artifacts.py +20 -0
- tba_contracts_digital_credential-0.4.0.dev2/src/tba_contracts_digital_credential/formats.py +18 -0
- tba_contracts_digital_credential-0.4.0.dev2/src/tba_contracts_digital_credential/issuance.py +52 -0
- tba_contracts_digital_credential-0.4.0.dev2/src/tba_contracts_digital_credential/presentations.py +60 -0
- tba_contracts_digital_credential-0.4.0.dev2/src/tba_contracts_digital_credential/py.typed +1 -0
- tba_contracts_digital_credential-0.4.0.dev2/src/tba_contracts_digital_credential/status.py +18 -0
- tba_contracts_digital_credential-0.4.0.dev2/src/tba_contracts_digital_credential/verification.py +35 -0
- tba_contracts_digital_credential-0.4.0.dev2/src/tba_contracts_digital_credential/wallets.py +14 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tba-contracts-digital-credential
|
|
3
|
+
Version: 0.4.0.dev2
|
|
4
|
+
Summary: Representation-neutral digital credential contracts.
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Requires-Python: >=3.10,<3.15
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
# tba-contracts-digital-credential
|
|
16
|
+
|
|
17
|
+
Owns digital credential, issuance, presentation, status, verification, and wallet semantics.
|
|
18
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "tba-contracts-digital-credential"
|
|
3
|
+
version = "0.4.0.dev2"
|
|
4
|
+
description = "Representation-neutral digital credential contracts."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.10,<3.15"
|
|
7
|
+
license = "Apache-2.0"
|
|
8
|
+
dependencies = []
|
|
9
|
+
|
|
10
|
+
[build-system]
|
|
11
|
+
requires = ["poetry-core>=1.0.0"]
|
|
12
|
+
build-backend = "poetry.core.masonry.api"
|
|
13
|
+
|
|
14
|
+
[tool.poetry]
|
|
15
|
+
packages = [{ include = "tba_contracts_digital_credential", from = "src" }]
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""Canonical representation-neutral digital credential contracts."""
|
|
2
|
+
|
|
3
|
+
from .artifacts import DigitalCredential
|
|
4
|
+
from .formats import CredentialFormat, CredentialType
|
|
5
|
+
from .issuance import (
|
|
6
|
+
CredentialConfiguration,
|
|
7
|
+
CredentialIssuanceRequest,
|
|
8
|
+
CredentialIssuanceResult,
|
|
9
|
+
CredentialIssuerPort,
|
|
10
|
+
CredentialOffer,
|
|
11
|
+
)
|
|
12
|
+
from .presentations import (
|
|
13
|
+
DisclosureSelection,
|
|
14
|
+
HolderBinding,
|
|
15
|
+
PresentationRequest,
|
|
16
|
+
PresentationResult,
|
|
17
|
+
PresentationVerifierPort,
|
|
18
|
+
TransactionBinding,
|
|
19
|
+
)
|
|
20
|
+
from .status import CredentialStatusReference, CredentialStatusResolverPort
|
|
21
|
+
from .verification import (
|
|
22
|
+
CredentialFormatVerifierPort,
|
|
23
|
+
CredentialVerificationRequest,
|
|
24
|
+
CredentialVerificationResult,
|
|
25
|
+
)
|
|
26
|
+
from .wallets import KeyAttestationVerifierPort, WalletAttestationVerifierPort
|
|
27
|
+
|
|
28
|
+
__all__ = [
|
|
29
|
+
"CredentialConfiguration",
|
|
30
|
+
"CredentialFormat",
|
|
31
|
+
"CredentialFormatVerifierPort",
|
|
32
|
+
"CredentialIssuanceRequest",
|
|
33
|
+
"CredentialIssuanceResult",
|
|
34
|
+
"CredentialIssuerPort",
|
|
35
|
+
"CredentialOffer",
|
|
36
|
+
"CredentialStatusReference",
|
|
37
|
+
"CredentialStatusResolverPort",
|
|
38
|
+
"CredentialType",
|
|
39
|
+
"CredentialVerificationRequest",
|
|
40
|
+
"CredentialVerificationResult",
|
|
41
|
+
"DigitalCredential",
|
|
42
|
+
"DisclosureSelection",
|
|
43
|
+
"HolderBinding",
|
|
44
|
+
"KeyAttestationVerifierPort",
|
|
45
|
+
"PresentationRequest",
|
|
46
|
+
"PresentationResult",
|
|
47
|
+
"PresentationVerifierPort",
|
|
48
|
+
"TransactionBinding",
|
|
49
|
+
"WalletAttestationVerifierPort",
|
|
50
|
+
]
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""Canonical digital credential artifact contracts."""
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass, field
|
|
4
|
+
from datetime import datetime
|
|
5
|
+
from typing import Mapping
|
|
6
|
+
|
|
7
|
+
from .formats import CredentialFormat
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclass(frozen=True, slots=True)
|
|
11
|
+
class DigitalCredential:
|
|
12
|
+
format: CredentialFormat
|
|
13
|
+
payload: bytes | str
|
|
14
|
+
issuer: str | None = None
|
|
15
|
+
subject: str | None = None
|
|
16
|
+
issued_at: datetime | None = None
|
|
17
|
+
metadata: Mapping[str, str] = field(default_factory=dict)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
__all__ = ["DigitalCredential"]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""Canonical digital credential format descriptors."""
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@dataclass(frozen=True, slots=True)
|
|
7
|
+
class CredentialFormat:
|
|
8
|
+
identifier: str
|
|
9
|
+
media_type: str | None = None
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@dataclass(frozen=True, slots=True)
|
|
13
|
+
class CredentialType:
|
|
14
|
+
identifier: str
|
|
15
|
+
format: CredentialFormat
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
__all__ = ["CredentialFormat", "CredentialType"]
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""Canonical digital credential issuance contracts."""
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass, field
|
|
4
|
+
from typing import Mapping, Protocol, Sequence
|
|
5
|
+
|
|
6
|
+
from .artifacts import DigitalCredential
|
|
7
|
+
from .formats import CredentialFormat, CredentialType
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclass(frozen=True, slots=True)
|
|
11
|
+
class CredentialConfiguration:
|
|
12
|
+
identifier: str
|
|
13
|
+
credential_type: CredentialType
|
|
14
|
+
supported_formats: Sequence[CredentialFormat]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@dataclass(frozen=True, slots=True)
|
|
18
|
+
class CredentialOffer:
|
|
19
|
+
issuer: str
|
|
20
|
+
configuration_ids: Sequence[str]
|
|
21
|
+
transaction_code_required: bool = False
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@dataclass(frozen=True, slots=True)
|
|
25
|
+
class CredentialIssuanceRequest:
|
|
26
|
+
configuration_id: str
|
|
27
|
+
format: CredentialFormat
|
|
28
|
+
subject: str | None = None
|
|
29
|
+
proof: bytes | str | None = None
|
|
30
|
+
attributes: Mapping[str, object] = field(default_factory=dict)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@dataclass(frozen=True, slots=True)
|
|
34
|
+
class CredentialIssuanceResult:
|
|
35
|
+
credential: DigitalCredential | None = None
|
|
36
|
+
transaction_id: str | None = None
|
|
37
|
+
notification_id: str | None = None
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class CredentialIssuerPort(Protocol):
|
|
41
|
+
def issue(
|
|
42
|
+
self, request: CredentialIssuanceRequest, /
|
|
43
|
+
) -> CredentialIssuanceResult: ...
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
__all__ = [
|
|
47
|
+
"CredentialConfiguration",
|
|
48
|
+
"CredentialIssuanceRequest",
|
|
49
|
+
"CredentialIssuanceResult",
|
|
50
|
+
"CredentialIssuerPort",
|
|
51
|
+
"CredentialOffer",
|
|
52
|
+
]
|
tba_contracts_digital_credential-0.4.0.dev2/src/tba_contracts_digital_credential/presentations.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"""Canonical digital presentation contracts."""
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass, field
|
|
4
|
+
from typing import Mapping, Protocol, Sequence
|
|
5
|
+
|
|
6
|
+
from .artifacts import DigitalCredential
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass(frozen=True, slots=True)
|
|
10
|
+
class DisclosureSelection:
|
|
11
|
+
claim_paths: Sequence[str]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dataclass(frozen=True, slots=True)
|
|
15
|
+
class HolderBinding:
|
|
16
|
+
method: str
|
|
17
|
+
key_reference: str | None = None
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@dataclass(frozen=True, slots=True)
|
|
21
|
+
class TransactionBinding:
|
|
22
|
+
nonce: str
|
|
23
|
+
audience: str
|
|
24
|
+
transaction_id: str | None = None
|
|
25
|
+
|
|
26
|
+
@property
|
|
27
|
+
def replay_value(self) -> str:
|
|
28
|
+
"""Normalized replay value independent of the originating wire name."""
|
|
29
|
+
return self.transaction_id or self.nonce
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@dataclass(frozen=True, slots=True)
|
|
33
|
+
class PresentationRequest:
|
|
34
|
+
accepted_formats: Sequence[str]
|
|
35
|
+
binding: TransactionBinding
|
|
36
|
+
requested_claims: Sequence[str] = ()
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@dataclass(frozen=True, slots=True)
|
|
40
|
+
class PresentationResult:
|
|
41
|
+
valid: bool
|
|
42
|
+
credentials: Sequence[DigitalCredential] = ()
|
|
43
|
+
disclosed_claims: Mapping[str, object] = field(default_factory=dict)
|
|
44
|
+
errors: Sequence[str] = ()
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class PresentationVerifierPort(Protocol):
|
|
48
|
+
def verify(
|
|
49
|
+
self, presentation: bytes | str, request: PresentationRequest, /
|
|
50
|
+
) -> PresentationResult: ...
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
__all__ = [
|
|
54
|
+
"DisclosureSelection",
|
|
55
|
+
"HolderBinding",
|
|
56
|
+
"PresentationRequest",
|
|
57
|
+
"PresentationResult",
|
|
58
|
+
"PresentationVerifierPort",
|
|
59
|
+
"TransactionBinding",
|
|
60
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""Canonical digital credential status contracts."""
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from typing import Protocol
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass(frozen=True, slots=True)
|
|
8
|
+
class CredentialStatusReference:
|
|
9
|
+
method: str
|
|
10
|
+
uri: str
|
|
11
|
+
index: str | int | None = None
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class CredentialStatusResolverPort(Protocol):
|
|
15
|
+
def resolve(self, reference: CredentialStatusReference, /) -> str: ...
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
__all__ = ["CredentialStatusReference", "CredentialStatusResolverPort"]
|
tba_contracts_digital_credential-0.4.0.dev2/src/tba_contracts_digital_credential/verification.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""Canonical digital credential verification contracts."""
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass, field
|
|
4
|
+
from typing import Mapping, Protocol, Sequence
|
|
5
|
+
|
|
6
|
+
from .artifacts import DigitalCredential
|
|
7
|
+
from .formats import CredentialFormat
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclass(frozen=True, slots=True)
|
|
11
|
+
class CredentialVerificationRequest:
|
|
12
|
+
credential: DigitalCredential
|
|
13
|
+
expected_format: CredentialFormat
|
|
14
|
+
expected_issuer: str | None = None
|
|
15
|
+
expected_audience: str | None = None
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@dataclass(frozen=True, slots=True)
|
|
19
|
+
class CredentialVerificationResult:
|
|
20
|
+
valid: bool
|
|
21
|
+
claims: Mapping[str, object] = field(default_factory=dict)
|
|
22
|
+
errors: Sequence[str] = ()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class CredentialFormatVerifierPort(Protocol):
|
|
26
|
+
def verify(
|
|
27
|
+
self, request: CredentialVerificationRequest, /
|
|
28
|
+
) -> CredentialVerificationResult: ...
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
__all__ = [
|
|
32
|
+
"CredentialFormatVerifierPort",
|
|
33
|
+
"CredentialVerificationRequest",
|
|
34
|
+
"CredentialVerificationResult",
|
|
35
|
+
]
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""Canonical wallet attestation ports."""
|
|
2
|
+
|
|
3
|
+
from typing import Protocol
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class WalletAttestationVerifierPort(Protocol):
|
|
7
|
+
def verify_wallet_attestation(self, attestation: bytes | str, /) -> bool: ...
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class KeyAttestationVerifierPort(Protocol):
|
|
11
|
+
def verify_key_attestation(self, attestation: bytes | str, /) -> bool: ...
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
__all__ = ["KeyAttestationVerifierPort", "WalletAttestationVerifierPort"]
|