Skip to content

Commit

Permalink
Ignore unknown test app messages (#2103)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nmattia authored Dec 5, 2023
1 parent 636d1ad commit 2cee1c0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions demos/test-app/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2cee1c0

Please sign in to comment.