Skip to content

Massive errorcount when having another application using postMessage #17

@Mai-Lapyst

Description

@Mai-Lapyst

The core library relies on the message event to (it seems) exchange the token from the worker to the application.

But when having another application/library running (i.e. Angular dev tools) that uses the postMessage/message ecessivly, this leads to many errors in the log.

The related code seems to be this:

handle = (e: MessageEvent) => {
console.log(`message received from ${e.origin} with data: ${e.data.token}`);
if (new URL(e.origin).host != this.widgetLink.host) {
console.error(
`expected message from ${this.widgetLink.host} but received message from ${e.origin}. Aborting.`
);
return;
}
this.updateState(e.data.token);
};

Maybe the library should send some sort of identification in the message? I.e: { type: 'mcaptcha', token: xxx }, so the code can check for the type and ignore any other messages?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions