Skip to content

Commit

Permalink
Ignore unknown test app messages
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 committed Dec 4, 2023
1 parent 90e5580 commit ea0c077
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 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;
Expand Down

0 comments on commit ea0c077

Please sign in to comment.