graaljs icon indicating copy to clipboard operation
graaljs copied to clipboard

Fetch implementation

Open KaindlJulian opened this issue 2 years ago • 3 comments

Implementation of https://fetch.spec.whatwg.org/

KaindlJulian avatar Jul 20 '22 10:07 KaindlJulian

Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA). The following contributors of this PR have not signed the OCA:

To sign the OCA, please create an Oracle account and sign the OCA in Oracle's Contributor Agreement Application.

When singing the OCA, please provide your GitHub username. After signing the OCA and getting an OCA approval from Oracle, this PR will be automatically updated.

You are missing to put the name "Response" into the global scope. Have a look at JSRealm.setupGlobals. This way, there are builtins for Response but JavaScript does not know what to do when you search for Response on the global object.

I am not sure this is the whole error, I would expect just a ReferenceError to emerge from that, but let's check.

wirthi avatar Jul 20 '22 12:07 wirthi

This is a great feature. Just some suggestions for security, in a SaaS or PaaS situation, Graal could be used to run JS code fron untrusted sources i.e. the SaaS clients. To help with this it would be great to be able to intercept the following from Java:

  • Domain Name / IP / DNS - This is to requests to internal IP/Domains can be blocked or logged
  • Before a request is sent - So requests can be validated or modified, For example, Being able to securely add credential headers or block a requests if it's malicious
  • After a response has been received but before passed to JS - So responses can be tracked, cached or modified before being passed to JS

Some examples of useful events can be found here: https://square.github.io/okhttp/4.x/okhttp/okhttp3/-event-listener/

This will allow platforms to better secure network access that comes from their platforms.

tuzzmaniandevil avatar May 25 '23 22:05 tuzzmaniandevil