Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement message channel #56

Merged
merged 5 commits into from
Dec 20, 2024
Merged

implement message channel #56

merged 5 commits into from
Dec 20, 2024

Conversation

turnekybc
Copy link
Contributor

No description provided.

auth/index.html Show resolved Hide resolved
auth/index.html Outdated Show resolved Hide resolved
@turnekybc turnekybc marked this pull request as ready for review December 19, 2024 14:27
@turnekybc turnekybc requested a review from r-n-o December 19, 2024 17:52
import/index.template.html Outdated Show resolved Hide resolved
);
addDOMEventListeners();

TKHQ.sendMessageUp("PUBLIC_KEY_READY", targetPubHex);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm worried that if this sendMessageUp function is called before TURNKEY_INIT_MESSAGE_CHANNEL is received (and thus, the channel set up), then the message will fail to be received on the other end (parent frame) because new SDKs won't listen for raw messages coming from postMessage anymore.

So it seems there's a bit of a race condition, and we should wait to receive "TURNKEY_INIT_MESSAGE_CHANNEL" before broadcasting "PUBLIC_KEY_READY"?

Another way to handle this is to broadcast PUBLIC_KEY_READY twice:

  • leave this here the way you have it (for old SDKs)
  • add a call to sendMessageUp("PUBLIC_KEY_READY", targetPubHex) again right after TKHQ.setParentFrameMessageChannelPort is called (so that new SDKs receive it as well)

Now that I'm writing this I think that's probably the cleanest option?

@turnekybc turnekybc requested a review from r-n-o December 20, 2024 18:31
@turnekybc turnekybc merged commit d8a6e18 into main Dec 20, 2024
6 checks passed
@turnekybc turnekybc deleted the eng-1441 branch December 20, 2024 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants