Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add outofband credential-offer #1216

Merged
merged 1 commit into from
Jul 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 50 additions & 1 deletion aries_cloudagent/protocols/out_of_band/v1_0/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
from ...didcomm_prefix import DIDCommPrefix
from ...didexchange.v1_0.manager import DIDXManager
from ...issue_credential.v1_0.models.credential_exchange import V10CredentialExchange
from ...issue_credential.v1_0.message_types import CREDENTIAL_OFFER
from ...issue_credential.v1_0.manager import CredentialManager
from ...issue_credential.v1_0.manager import CredentialOffer
from ...issue_credential.v2_0.models.cred_ex_record import V20CredExRecord
from ...present_proof.v1_0.manager import PresentationManager
from ...present_proof.v1_0.message_types import PRESENTATION_REQUEST
Expand Down Expand Up @@ -570,12 +573,17 @@ async def receive_invitation(
conn_rec=conn_rec,
trace=(invi_msg._trace is not None),
)
elif unq_req_attach_type == CREDENTIAL_OFFER:
await self._process_cred_offer_v1(
req_attach=req_attach,
conn_rec=conn_rec,
)
else:
raise OutOfBandManagerError(
(
"Unsupported requests~attach type "
f"{req_attach.content['@type']}: must unqualify to"
f"{PRESENTATION_REQUEST} or {PRES_20_REQUEST}"
f"{PRESENTATION_REQUEST} or {PRES_20_REQUEST} or{CREDENTIAL_OFFER}"
)
)
else:
Expand Down Expand Up @@ -744,6 +752,47 @@ async def _process_pres_request_v2(
)
)

async def _process_cred_offer_v1(
self,
req_attach: AttachDecorator,
conn_rec: ConnRecord,
):
"""
Create exchange for v1 cred offer attachment, auto-offer if configured.
Args:
req_attach: request attachment on invitation
service: service message from invitation
conn_rec: connection record
"""
cred_mgr = CredentialManager(self._session.profile)
cred_offer_dict = req_attach.content

cred_offer_msg = CredentialOffer.deserialize(cred_offer_dict)

# receive credential offer
cred_ex_record = await cred_mgr.receive_offer(message=cred_offer_msg, connection_id=conn_rec.connection_id)
if self._session.context.settings.get("debug.auto_respond_credential_offer"):
cred_request_message = None
(_, cred_request_message) = await cred_mgr.create_request(
cred_ex_record= cred_ex_record,
holder_did=conn_rec.my_did,
)
responder = self._session.inject(BaseResponder, required=False)
if responder:
await responder.send(
message=cred_request_message,
target_list=await self.fetch_connection_targets(
connection=conn_rec
),
)
else:
raise OutOfBandManagerError(
(
"Configuration sets auto_offer false: cannot "
"respond automatically to credential offers"
)
)

async def find_existing_connection(
self,
tag_filter: dict,
Expand Down