src.credentials.credential_service

Credential service for requesting credentials.

 1"""Credential service for requesting credentials."""
 2
 3from src.credentials.credential import CredentialResponse
 4from src.issuer_agent.issuer_agent_port import IssuerAgentPort
 5
 6
 7class CredentialService:
 8    """Service that orchestrates credential requests."""
 9
10    _issuer_agent: IssuerAgentPort
11
12    def __init__(self, issuer_agent: IssuerAgentPort) -> None:
13        """Initialise the service with its dependencies.
14
15        Args:
16            issuer_agent: Adapter for the SSI agent that handles credential requests.
17        """
18        self._issuer_agent = issuer_agent
19
20    def request_credential(
21        self,
22        format: str,
23        credential_configuration_id: str,
24        proof: dict[str, object],
25        issuer_state: str,
26        access_token: str,
27    ) -> CredentialResponse:
28        """Request a credential from the issuer agent.
29
30        Args:
31            format: The credential format.
32            credential_configuration_id: The credential configuration identifier.
33            proof: The proof object containing proof_type and jwt.
34            issuer_state: The issuer state from the offer.
35            access_token: The access token for authorization.
36
37        Returns:
38            CredentialResponse containing the issued credential(s).
39        """
40        return self._issuer_agent.credential_request(
41            format=format,
42            credential_configuration_id=credential_configuration_id,
43            proof=proof,
44            issuer_state=issuer_state,
45            access_token=access_token,
46        )
47
48    def request_nonce(self) -> dict[str, str]:
49        """Request a nonce from the issuer agent.
50
51        Returns:
52            A dictionary containing the c_nonce.
53        """
54        return self._issuer_agent.request_nonce()
class CredentialService:
 8class CredentialService:
 9    """Service that orchestrates credential requests."""
10
11    _issuer_agent: IssuerAgentPort
12
13    def __init__(self, issuer_agent: IssuerAgentPort) -> None:
14        """Initialise the service with its dependencies.
15
16        Args:
17            issuer_agent: Adapter for the SSI agent that handles credential requests.
18        """
19        self._issuer_agent = issuer_agent
20
21    def request_credential(
22        self,
23        format: str,
24        credential_configuration_id: str,
25        proof: dict[str, object],
26        issuer_state: str,
27        access_token: str,
28    ) -> CredentialResponse:
29        """Request a credential from the issuer agent.
30
31        Args:
32            format: The credential format.
33            credential_configuration_id: The credential configuration identifier.
34            proof: The proof object containing proof_type and jwt.
35            issuer_state: The issuer state from the offer.
36            access_token: The access token for authorization.
37
38        Returns:
39            CredentialResponse containing the issued credential(s).
40        """
41        return self._issuer_agent.credential_request(
42            format=format,
43            credential_configuration_id=credential_configuration_id,
44            proof=proof,
45            issuer_state=issuer_state,
46            access_token=access_token,
47        )
48
49    def request_nonce(self) -> dict[str, str]:
50        """Request a nonce from the issuer agent.
51
52        Returns:
53            A dictionary containing the c_nonce.
54        """
55        return self._issuer_agent.request_nonce()

Service that orchestrates credential requests.

CredentialService(issuer_agent: src.issuer_agent.issuer_agent_port.IssuerAgentPort)
13    def __init__(self, issuer_agent: IssuerAgentPort) -> None:
14        """Initialise the service with its dependencies.
15
16        Args:
17            issuer_agent: Adapter for the SSI agent that handles credential requests.
18        """
19        self._issuer_agent = issuer_agent

Initialise the service with its dependencies.

Args: issuer_agent: Adapter for the SSI agent that handles credential requests.

def request_credential( self, format: str, credential_configuration_id: str, proof: dict[str, object], issuer_state: str, access_token: str) -> src.credentials.credential.CredentialResponse:
21    def request_credential(
22        self,
23        format: str,
24        credential_configuration_id: str,
25        proof: dict[str, object],
26        issuer_state: str,
27        access_token: str,
28    ) -> CredentialResponse:
29        """Request a credential from the issuer agent.
30
31        Args:
32            format: The credential format.
33            credential_configuration_id: The credential configuration identifier.
34            proof: The proof object containing proof_type and jwt.
35            issuer_state: The issuer state from the offer.
36            access_token: The access token for authorization.
37
38        Returns:
39            CredentialResponse containing the issued credential(s).
40        """
41        return self._issuer_agent.credential_request(
42            format=format,
43            credential_configuration_id=credential_configuration_id,
44            proof=proof,
45            issuer_state=issuer_state,
46            access_token=access_token,
47        )

Request a credential from the issuer agent.

Args: format: The credential format. credential_configuration_id: The credential configuration identifier. proof: The proof object containing proof_type and jwt. issuer_state: The issuer state from the offer. access_token: The access token for authorization.

Returns: CredentialResponse containing the issued credential(s).

def request_nonce(self) -> dict[str, str]:
49    def request_nonce(self) -> dict[str, str]:
50        """Request a nonce from the issuer agent.
51
52        Returns:
53            A dictionary containing the c_nonce.
54        """
55        return self._issuer_agent.request_nonce()

Request a nonce from the issuer agent.

Returns: A dictionary containing the c_nonce.