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

Support multiple callbacks to Snow #71

Merged
merged 5 commits into from
Mar 5, 2023
Merged

Support multiple callbacks to Snow #71

merged 5 commits into from
Mar 5, 2023

Conversation

weizman
Copy link
Member

@weizman weizman commented Mar 2, 2023

Background

In sake of simplicity and security, up until this point Snow only accepted one single callback (first one to register wins).
We now need Snow to be able to accept more than just one without breaking its security principles.

Solution

  • Snow will now accept an unlimited amount of callbacks.
  • To prevent anyone in the page from using Snow, former callbacks can decide whether to allow the chain of calls to continue or not by simply returning a boolean (true=stop;false[default]=continue).
  • This mechanism only applies to non-top realms - every callback passed to Snow will immediately be called on the top realm, regardless of the mentioned above chain of calls.

Example

SNOW( w => false ) // will be called on top and all future same origin realms (false continues the chain)
SNOW( w => true  ) // will be called on top and all future same origin realms (true breaks the chain)
SNOW( w => false ) // will be called on top and top only! (true broke the chain)
SNOW( w => false ) // will be called on top and top only! (true broke the chain)

@weizman weizman changed the title try multiple cbs Support multiple callbacks to Snow Mar 5, 2023
@weizman weizman mentioned this pull request Mar 5, 2023
@weizman weizman marked this pull request as ready for review March 5, 2023 11:05
@weizman weizman merged commit 1e04737 into main Mar 5, 2023
@weizman weizman deleted the try-multiple-cbs branch March 5, 2023 11:05
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.

1 participant