WiX Custom Action in Javascript - How to make web requests? - javascript

I have a Custom Action in WiX (windows installer toolset) that is written in Javascript. What are my options to make web requests? As far as I know, fetch is a web api which is not accessible in the runtime provided by the windows installer. Is there a way to import third-party libraries?

Microsoft JScript (which is what is run in WiX custom actions) provides native web requests like this:
// Instantiate a WinHttpRequest object.
var WinHttpReq = new ActiveXObject("WinHttp.WinHttpRequest.5.1");
WinHttpRequest can then be used similar to XMLHttpRequest.
see documentation here

Related

How to use js bridge in chrome custom tab

Google oAuth is not supported in android webView. Google recommends to use chrome custom tab for proceeding oAuth. I have also requirements of js call from my web app to native. How to configure to call native methods from web app using chrome custom tab in android similarly like js interface in webView?
Update 1
This mod Chang marked the post as duplicate but the post is different. I don't want to run any JS in my web app from native. I want to invoke method from web app to my native code via JS interface. Is there any way for CCT?
Based on Can I Inject Javascript Code into Chrome Custom Tabs the answer appears to be no.
Chrome Custom Tab is based on Chrome itself and has the same security model. The web content is only allowed access to the Web APIs (camera, device orientation, etc.) and has no access to the native app. At best the native app can capture a URI.
Even the Chrome Custom Tab documentation state that the way for a native app to handle content:
Some URLs can be handled by native applications. If the user has the Twitter app installed and clicks on a link to a tweet. She expects that the Twitter application will handle it.
Before opening an url from your application, check if a native alternative is available and use it.
Implies that either a native app handles a URL or not. My interpretation of Chrome Custom Tab is a skinnable Chrome component adjacent to the native app rather than internal to a native app like a WebView where a Javascript bridge exists.
Your desire for a Javascript bridge from a web app would mean that there would be a arbitrary way for any website code to interact outside of the web container. The rational as to why that is not allowed is given as the responses in the first link.

Headless browser in Azure functions JavaScript?

I tried using phantomjs but apparently it's unsupported, is there any way to scrape websites using azure functions in javascript?
There are many restrictions on Azure App Service (includes WebApps, Function Apps), such as Win32k.sys (User32/GDI32) Restrictions. So some packages are not supported on Azure App Service, which like PhantomJS/puppteer be required to start a headless browser which needs GDI support to communicate with javascript/nodejs to get DOM node.
You can scrape a static web page or only HTML via Node http.ClientRequest or Request package in Function App. If to scrape a DOM node of a web page dynamically, the only way is using PhantomJS/puppteer on Azure VM, not Function Apps.

Confused about Web share API and Cordova share plugin

I'm trying to implement a share feature in my Cordova app to let users share their pictures
According to the Chrome dev team they introduced a Web share API directly into Google Chrome. To share something just call:
navigator.share({title: 'Example Page', url: 'https://example.com'});
but as far as I know Cordova also has a plugin, namely cordova-share-plugin
To use this plugin, simply call:
navigator.share(text,title,mimetype)
This is where I get confused. Both the built-in share API and the Cordova plugin have the same method navigator.share(). The expected parameters are different.
If I have installed the cordova share plugin and I call navigator.share() which code get executed? the plugin or the native share API?
It looks like one of my user is unable to share pictures because the call to navigator.share() fails silently. He has Android 8.1.0. All the other users seem to trigger the Cordova plugin when my app calls navigator.share()
That's a pretty old plugin, created when navigator.share was not available in the browser.
The plugin clobbers navigator.share, so it will use the plugin implementation instead of the browser implementation.

OpenSession with WebExtension (pkcs11)

I am trying to do Web-extension to Mozilla, which will use pkcs11 to sign, encrypt or verify document, mail.
I am using this api to comunicate with my eid cards and get slots from them.
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/pkcs11
Is it somehow possible to OpenSession with this slots in WebExtension plugin?
Because this pkcs11 seems like have not supported it yet.
I would like to call some function like C_OpenSession and then C_Login.
Thanks for help
The only purpose of PKCS#11 javascript API in Mozilla nowadays is to register and unregister PKCS#11 libraries available to Firefox. It's even stated in the documentation:
The pkcs11 API enables an extension to enumerate PKCS #11 security modules, and to make them accessible to the browser as sources of keys and certificates.
Firefox uses registered PKCS#11 libraries to access client SSL certificates. AFAIK there is no public javascript API that would allow you to call other PKCS#11 functions (such as C_OpenSession or C_Login) provided by these modules.
There used to be window.crypto.signText API available for easy signature creation but Mozilla killed it in Firefox 33. They didn't see it as a big deal because PKCS#11 signing could be implemented with extension and they provided signTextJS extension as a proof. Sadly Mozilla killed it in Firefox 57 when they migrated to WebExtensions and removed support for XPCOM-based add-ons.
If you want to use PKCS#11 API from Firefox nowadays then you need to use/create extension which will spawn local process and communicate with it via native messaging or you'll need to use/create application which will spawn local web server and communicate with it via web requests or web sockets.

How to send a string from a chrome extension to C++ WIndows socket

I have tried looking for methods to communicate . For instance, Mozilla provides XPconnect for bindings between Javascript to XPCOM. Does Chrome have any such APIs?
As Gael mentions, Native Messaging is your nearly only way.
You need to write (and distribute separately) a Native Host module for the extension - that Chrome can launch and pass your data to. It will serve as a proxy between your extension and COM.
You could also make a service that exposes a local web or WebSockets interface that the extension can call. This way, you don't need Native Messaging, but it makes for some security concerns.
In either case, you need an external "proxy" (or "glue", if you prefer that metaphor) software.

Categories

Resources