ews-javascript-api icon indicating copy to clipboard operation
ews-javascript-api copied to clipboard

Clarification on ews-js-api-browser

Open marcoancona opened this issue 3 years ago • 5 comments

Hello @gautamsi, I have been using ews-javascript-api for a while on Node. To port the code on a browser process, my understanding is that we need to use ews-js-api-browser instead. Is there a reason why this is a separate package instead of just a different XHR adapter? Connected to this, will ews-js-api-browser be updated with the latest changes/improvements from this repo?

Edit: when I say "port the code on a browser process", I mean the renderer process of Electron where we can disable CORS.

marcoancona avatar Jan 12 '21 13:01 marcoancona

if you are on electron, you can directly use it in renderer process

gautamsi avatar Jan 12 '21 14:01 gautamsi

Thanks for the quick reply. This is true, and it works, but it seems that the requests are still going through Node. We would like to use the networking capabilities of the browser instead because 1) we can see the request directly in the developer console and 2) because the browser process inherits proxy settings automatically from the os. We might also want to isolate the renderer process from Node too.

The fact that the request are not visible in the Chronium dev tools suggests that the library is detecting a Node environment and using the fetch library.

marcoancona avatar Jan 12 '21 14:01 marcoancona

in that case you want to use this browser lib. I can see if I can update that soon.

gautamsi avatar Jan 12 '21 15:01 gautamsi

Thanks @gautamsi. I would like to better understand what is the fundamental difference between the two libraries though. If we were to write our own IXHRApi, both for Basic and NTLM authentication, could we then just use ews-javascript-api by injecting the XHR adapter a bit as it happens with @ewsjs/xhr? I am asking this because we need NTLM and my understanding is that this only works on NodeJS.

marcoancona avatar Jan 13 '21 10:01 marcoancona

you can try that, problem may be with the fetch lib being used and loaded which gives trouble.

also I have added dns resolution using node modules which is going to trouble in browser.

gautamsi avatar Jan 13 '21 19:01 gautamsi