From 3e83dd027e77fddd9be0d00f08ecf153d69d2956 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 cd247f070c..1f3f550def 100755 --- a/demo/run_demo +++ b/demo/run_demo @@ -224,6 +224,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 aae52165f9..f503cabd91 100644 --- a/demo/runners/support/agent.py +++ b/demo/runners/support/agent.py @@ -40,6 +40,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") @@ -417,7 +418,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 fae85cc937..be361847df 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 c804f75f6e6962834bb1ab9e8786fbae0b308690 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 55ec5595fa..18c64a6411 100755 --- a/demo/run_bdd +++ b/demo/run_bdd @@ -203,6 +203,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}"