From 2cee1c06d0a63068dd2428401c8646ae69fd7a4b Mon Sep 17 00:00:00 2001 From: Nicolas Mattia Date: Tue, 5 Dec 2023 11:15:00 +0100 Subject: [PATCH] Ignore unknown test app messages (#2103) This updates the test app to ignore unknown window events. Some extensions, like metamask, send seemingly arbitrary messages to the window which confuses the test app. With these changes we try to figure out if a message was intended for us by 1. Ensuring a request was started 2. Checking the jsonrpc response ID --- demos/test-app/src/index.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/demos/test-app/src/index.tsx b/demos/test-app/src/index.tsx index ddd46842c7..d5a1f4bb51 100644 --- a/demos/test-app/src/index.tsx +++ b/demos/test-app/src/index.tsx @@ -415,6 +415,16 @@ function handleFlowReady(evnt: MessageEvent) { } function handleFlowFinished(evnt: MessageEvent) { + if (latestOpts === undefined) { + // no inflight requests, so we don't expect a response. + return; + } + + if (evnt.data?.id.toString() !== latestOpts.flowId.toString()) { + // If this is not a response to a flow we started, ignore it + return; + } + try { // Make the presentation presentable const verifiablePresentation = evnt.data?.result?.verifiablePresentation;