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

Update to use latest credential exchange api #220

Merged
merged 2 commits into from
Mar 3, 2020
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
33 changes: 25 additions & 8 deletions bcreg-aca/src/issuer.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ def run(self):
app_config["schemas"][
"SCHEMA_" + schema_name + "_" + schema_version
] = schema_id["schema_id"]
print("Registered schema: ", schema_id)

if schema_key not in existing_schemas or "cred_def" not in existing_schemas[schema_key]:
cred_def_request = {"schema_id": schema_id["schema_id"]}
Expand All @@ -204,7 +203,6 @@ def run(self):
app_config["schemas"][
"CRED_DEF_" + schema_name + "_" + schema_version
] = credential_definition_id["credential_definition_id"]
print("Registered credential definition: ", credential_definition_id)

# what is the TOB connection name?
tob_connection_params = config_services["verifiers"]["bctob"]
Expand Down Expand Up @@ -496,7 +494,7 @@ def get_credential_response(cred_exch_id):

TOPIC_CONNECTIONS = "connections"
TOPIC_CONNECTIONS_ACTIVITY = "connections_actvity"
TOPIC_CREDENTIALS = "credentials"
TOPIC_CREDENTIALS = "issue_credential"
TOPIC_PRESENTATIONS = "presentations"
TOPIC_GET_ACTIVE_MENU = "get-active-menu"
TOPIC_PERFORM_MENU_ACTION = "perform-menu-action"
Expand All @@ -522,7 +520,7 @@ def handle_credentials(state, message):
else:
#print(datetime.now(), ">>> handle_credentials()", state, message["credential_exchange_id"])
pass
if state == "stored":
if state == "credential_acked":
response = {"success": True, "result": message["credential_exchange_id"]}
add_credential_response(message["credential_exchange_id"], response)
#if "thread_id" in message:
Expand Down Expand Up @@ -703,15 +701,34 @@ def handle_send_credential(cred_input):
for credential in cred_input:
cred_def_key = "CRED_DEF_" + credential["schema"] + "_" + credential["version"]
credential_definition_id = app_config["schemas"][cred_def_key]

credential_attributes = []
for attribute in credential["attributes"]:
credential_attributes.append({
"name": attribute,
"mime-type": "text/plain",
"value": credential["attributes"][attribute]
})
cred_offer = {
"connection_id": app_config["TOB_CONNECTION"],
"credential_definition_id": credential_definition_id,
"credential_values": credential["attributes"],
"schema_id": app_config["schemas"][
"SCHEMA_" + credential["schema"] + "_" + credential["version"]
],
"schema_name": credential["schema"],
"issuer_did": app_config["DID"],
"schema_version": credential["version"],
"credential_proposal": {
"@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/issue-credential/1.0/credential-preview",
"attributes": credential_attributes
},
"schema_issuer_did": app_config["DID"],
"cred_def_id": credential_definition_id,
"comment": "",
"connection_id": app_config["TOB_CONNECTION"]
}
thread = SendCredentialThread(
credential_definition_id,
cred_offer,
agent_admin_url + "/credential_exchange/send",
agent_admin_url + "/issue-credential/send",
ADMIN_REQUEST_HEADERS,
)
thread.start()
Expand Down