From f4ccfeb789deaeaa5c550c11fdc1b799bc0ea772 Mon Sep 17 00:00:00 2001 From: Ian Costanzo Date: Wed, 3 Jul 2024 10:15:53 -0700 Subject: [PATCH 1/2] Add by_format to terse webhook for presentations Signed-off-by: Ian Costanzo --- .../present_proof/v2_0/messages/pres_webhook.py | 1 + .../present_proof/v2_0/models/pres_exchange.py | 10 +++++----- demo/run_demo | 3 +++ demo/runners/support/agent.py | 4 +++- docker/Dockerfile.demo | 1 - 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_webhook.py b/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_webhook.py index e5d3cc3228..66d9024b53 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_webhook.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_webhook.py @@ -15,6 +15,7 @@ class V20PresExRecordWebhook: "thread_id", "state", "trace", + "by_format", "verified", "verified_msgs", "created_at", diff --git a/aries_cloudagent/protocols/present_proof/v2_0/models/pres_exchange.py b/aries_cloudagent/protocols/present_proof/v2_0/models/pres_exchange.py index 06f43036ea..d78059ee77 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/models/pres_exchange.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/models/pres_exchange.py @@ -197,11 +197,11 @@ async def emit_event(self, session: ProfileSession, payload: Any = None): else: topic = f"{self.EVENT_NAMESPACE}::{self.RECORD_TOPIC}" - if session.profile.settings.get("debug.webhooks"): - if not payload: - payload = self.serialize() - else: - payload = V20PresExRecordWebhook(**self.__dict__) + # serialize payload before checking for webhook contents + if not payload: + payload = self.serialize() + if not session.profile.settings.get("debug.webhooks"): + payload = V20PresExRecordWebhook(**payload) payload = payload.__dict__ await session.profile.notify(topic, payload) diff --git a/demo/run_demo b/demo/run_demo index dfde90ca13..b8b87029b6 100755 --- a/demo/run_demo +++ b/demo/run_demo @@ -271,6 +271,9 @@ fi if ! [ -z "$WEBHOOK_TARGET" ]; then DOCKER_ENV="${DOCKER_ENV} -e WEBHOOK_TARGET=${WEBHOOK_TARGET}" fi +if ! [ -z "$ACAPY_DEBUG_WEBHOOKS" ]; then + DOCKER_ENV="${DOCKER_ENV} -e ACAPY_DEBUG_WEBHOOKS=${ACAPY_DEBUG_WEBHOOKS}" +fi # if $TAILS_NETWORK is specified it will override any previously specified $DOCKER_NET if ! [ -z "$TAILS_NETWORK" ]; then DOCKER_NET="${TAILS_NETWORK}" diff --git a/demo/runners/support/agent.py b/demo/runners/support/agent.py index e71c0fcaf0..67dab96db8 100644 --- a/demo/runners/support/agent.py +++ b/demo/runners/support/agent.py @@ -39,6 +39,7 @@ TRACE_ENABLED = os.getenv("TRACE_ENABLED") WEBHOOK_TARGET = os.getenv("WEBHOOK_TARGET") +ACAPY_DEBUG_WEBHOOKS = os.getenv("ACAPY_DEBUG_WEBHOOKS") AGENT_ENDPOINT = os.getenv("AGENT_ENDPOINT") @@ -584,7 +585,8 @@ def get_agent_args(self): # turn on notifications if revocation is enabled result.append("--notify-revocation") # enable extended webhooks - result.append("--debug-webhooks") + if ACAPY_DEBUG_WEBHOOKS: + result.append("--debug-webhooks") # always enable notification webhooks result.append("--monitor-revocation-notification") diff --git a/docker/Dockerfile.demo b/docker/Dockerfile.demo index 837dfb221e..a518150a9d 100644 --- a/docker/Dockerfile.demo +++ b/docker/Dockerfile.demo @@ -4,7 +4,6 @@ FROM ${from_image} ENV ENABLE_PTVSD 0 ENV ENABLE_PYDEVD_PYCHARM 0 ENV PYDEVD_PYCHARM_HOST "host.docker.internal" -ENV ACAPY_DEBUG_WEBHOOKS 1 RUN mkdir -p bin && curl -L -o bin/jq \ https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 && \ From b10fec33c196030715d8cae378a39a60b03f1f54 Mon Sep 17 00:00:00 2001 From: Ian Costanzo Date: Thu, 4 Jul 2024 13:24:57 -0700 Subject: [PATCH 2/2] Add by_format to terse wehook for isse cred Signed-off-by: Ian Costanzo --- .../v2_0/messages/cred_ex_record_webhook.py | 1 + .../issue_credential/v2_0/models/cred_ex_record.py | 8 ++++---- demo/run_bdd | 3 +++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_ex_record_webhook.py b/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_ex_record_webhook.py index ef71eded68..aca1a4c39c 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_ex_record_webhook.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_ex_record_webhook.py @@ -23,6 +23,7 @@ class V20CredExRecordWebhook: "credential_definition_id", "schema_id", "credential_id", + "by_format", "trace", "public_did", "cred_id_stored", diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/models/cred_ex_record.py b/aries_cloudagent/protocols/issue_credential/v2_0/models/cred_ex_record.py index 1eece14bac..b6a68d8419 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/models/cred_ex_record.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/models/cred_ex_record.py @@ -197,11 +197,11 @@ async def emit_event(self, session: ProfileSession, payload: Any = None): else: topic = f"{self.EVENT_NAMESPACE}::{self.RECORD_TOPIC}" - if session.profile.settings.get("debug.webhooks"): - if not payload: - payload = self.serialize() + # serialize payload before checking for webhook contents + if not payload: + payload = self.serialize() else: - payload = V20CredExRecordWebhook(**self.__dict__) + payload = V20CredExRecordWebhook(**payload) payload = payload.__dict__ await session.profile.notify(topic, payload) diff --git a/demo/run_bdd b/demo/run_bdd index 8b4c602818..01b3314d52 100755 --- a/demo/run_bdd +++ b/demo/run_bdd @@ -210,6 +210,9 @@ fi if ! [ -z "$WEBHOOK_TARGET" ]; then DOCKER_ENV="${DOCKER_ENV} -e WEBHOOK_TARGET=${WEBHOOK_TARGET}" fi +if ! [ -z "$ACAPY_DEBUG_WEBHOOKS" ]; then + DOCKER_ENV="${DOCKER_ENV} -e ACAPY_DEBUG_WEBHOOKS=${ACAPY_DEBUG_WEBHOOKS}" +fi # if $TAILS_NETWORK is specified it will override any previously specified $DOCKER_NET if ! [ -z "$TAILS_NETWORK" ]; then DOCKER_NET="${TAILS_NETWORK}"