From ea0c0774d4e856475ab9bbc884e25821494e9c1b Mon Sep 17 00:00:00 2001 From: Nicolas Mattia Date: Mon, 4 Dec 2023 17:23:25 +0100 Subject: [PATCH] Ignore unknown test app messages 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..d16f4de9cb 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 onlight requests, so we don't expect a response. + return; + } + + if (evnt.data?.id !== latestOpts.flowId) { + // 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;