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

Add window.postMessage communication from web view to web view provider/controller #1305

Open
tjcouch-sil opened this issue Nov 13, 2024 · 2 comments

Comments

@tjcouch-sil
Copy link
Member

tjcouch-sil commented Nov 13, 2024

User Story
As an extension developer, I want to be able to use built-in browser APIs to communicate from my web view to my backend so I can embed normal websites and further sandbox my web view to protect it from other web views.

Description

As of #1185, we have a way for web view provider/controllers to postMessage to web views. However, web views cannot do the same to communicate back to the backend. They can communicate on the papi, but they can't use built-in browser APIs. As such, URL web views and web views not on same origin are unable to talk to their backend.

This could be useful for syncing scripture reference with external sites embedded into P.B, keeping track of which url a website has navigated to, and much more. It depends on how the website creator implements postMessage.

Implementation ideas: Web view postMessage calls receiveMessageFromWebView on web view provider? Or on web view controller? Or WebViewFactory works with call on web view provider to make it easier for web view controllers? Or something along these lines. Probably use the web view nonce to make sure the web view provider receives messages only from the web view.

@tjcouch-sil tjcouch-sil changed the title Web view postMessage calls receiveMessageFromWebView on web view provider? - spit off? Add window.postMessage communication between web view and web view provider/controller Nov 13, 2024
@tjcouch-sil
Copy link
Member Author

tjcouch-sil commented Nov 13, 2024

#1185 and this implement #616.

@tjcouch-sil tjcouch-sil changed the title Add window.postMessage communication between web view and web view provider/controller Add window.postMessage communication from web view to web view provider/controller Nov 13, 2024
@Sebastian-ubs
Copy link
Contributor

Sebastian-ubs commented Nov 21, 2024

I have heard interest in this for an easy start of existing scripture reference based web apps. Compared to putting the app itself into Platform, this would work with just the following

  • create a new url webview - with watching on bcv changes (might be made simpler with my upcoming changes) - or using this platform post message api
  • in the web app add calls to this platform post massage api on bcv changes

@tjcouch-sil tjcouch-sil moved this to 📥 For Consideration in Paranext Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📥 For Consideration
Development

No branches or pull requests

2 participants