Edge Extension: Need to share credentials with a WPF - javascript

I have a WPF app that stores credentials in a local file. I need to be able to access this file from an Edge extension or to somehow communicate the credentials from the WPF to the Edge extension. Can an Edge extension use the File API or is there something similar to Native Messaging for WPF that would allow me to communicate with the Edge extension?

As of builds 15002 and above (only available to Windows Insiders currently), Microsoft Edge supports native messaging to UWAs: https://learn.microsoft.com/en-us/microsoft-edge/extensions/guides/native-messaging
If you want to communicate with a WPFapp, you'll need to use the Desktop Bridge to convert it to a UWA before continuing.
If you need to sign up for the Windows Insider Program, you can do so here: https://insider.windows.com. Native messaging will also be available in the Windows 10 Creators Update once it's released publicly!

Related

access web serial api in android chrome browser

using web serial API in windows, mac os, and Linux chrome browser I can receive and send data. but in the android chrome browser, I am not able to send or receive data from a serial device.
so which API is used to read and write data to serial devices in the android chrome browser.
also, there is a polyfill serial API for android chrome but is showing an error shown in the image.
The team that built the implementation of the Web Serial API in Chromium also wrote a polyfill library which uses WebUSB to support platforms which don't provide built-in serial drivers: https://github.com/google/web-serial-polyfill
It looks like you are already trying to use this library. Can you file an issue on the library's GitHub project so the team can look at the error you're seeing?
Note, it seems like there are some Android devices which have USB serial drivers that end up blocking WebUSB from claiming interfaces even though the platform doesn't let apps actually use them. https://crbug.com/1099521 is tracking a workaround for that.

Share data between Edge Extension and WPF

I am developing an Edge extension, I need to send data from it to WPF application. In Chrome extension, i use $.post to send data like this:
var listener = "http://localhost:60024/";
$.post(listener, postData);
And in WPF application receive this data with HTTPListener:
_listener = new HttpListener();
_listener.Prefixes.Add("http://localhost:60024/");
_listener.Start();
But in Edge this does not work, because $.post dont do anything. I have seen that Native Messaging can be used, but I do not know if it works with WPF applications.
Could anybody help?
But in Edge this does not work, because $.post dont do anything
In this issue, The MS Edge Team says that accessing localhost in Edge extensions is blocked by design:
"We are working on Native Messaging for the next release and using native messaging is the right way to solve this scenario. Localhost access is not enabled from extension background page is by design."
So, you could try to use an external API to transfer data. Please refer to this similar thread.
I have seen that Native Messaging can be used, but I do not know if it
works with WPF applications.
Microsoft Edge extensions are able to use native messaging to communicate with a companion Universal Windows Platform (UWP) app. More details, please refer to Native messaging in Microsoft Edge.

IOS safari or Chrome read / write file via USB

Does IOS Safari / Chrome browser allows accessing file from USB device / Stick connected via USB (Lighting to USB adapter)? I did a quick google and seems like uploading (write) is not possible but maybe read is possible?
According to this https://caniuse.com/#feat=filesystem
Seems like IOS Safari does not support file system / file writer api
But it supports File api
https://caniuse.com/#search=file%20api
Any comments would be highly appreciated.
In iOS, File API connected to 'Files' application which provides connection to several cloud services and access permission to internal shared storage.
Currently, 'Files' application doesn't support file access to external devices.
If you want to access to external devices with File API, you must use 3rd party application which supports 'Files' application as a pipe.

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 sign the document with a certificate's private key from the browser (CAPICOM alternative)?

So, till Windows 7 there was a Microsoft ActiveX component: CAPICOM, which one could call from Javascript and then show the contents of the certificate storage on the client's machine. The client then could choose the appropriate certificate and sign some document with the certificate's private key.
That's how the access to the certificate storage looked in Javascript:
var MyStore = new ActiveXObject("CAPICOM.Store");
var oCertificates = new ActiveXObject("CAPICOM.Certificates");
// attempt to open the personal certificate store
MyStore.Open(CAPICOM_CURRENT_USER_STORE, "My", CAPICOM_STORE_OPEN_READ_ONLY);
What’s the alternative to using CAPICOM nowadays? I want the client to be able to sign some piece of text with his private key in the browser and then send the signed text with the public key to the server. Is it still possible?
Maybe I could use Java or Silverlight instead of pure JavaScript? What about PKI.js and similar?
In general, currently is not possible due to lack of support of browsers to Java or silverlight.
Chrome has dropped support to NPAPI plugins. Firefox has announced it will discontinue it in 2017, Edge has no support. Microsoft has deprecated Silverlight and Oracle has also announced the deprecation of the Java browser plug-in. Only old versions of IE could be used.
Javascript cryptographic libraries such as PKI.js, forge or the built-in WebCryptographyApi can be used to perform digital signatures, but they do not have access to the Operative System KeyStore, so you can not access to the installed certificates
Alternatives (Not very encouraging):
Use WebCryptographyApi loading certificates in browser (not for smartcards)
Launch a local application installed on your device and invoke via protocol, using an embedded http server or with chrome messaging api
Wait patiently to Key Discovery Api which will provide with access to the OS keystore to WebCrypto
In fact I've created a .NET ActiveX object and used X509Certificate2UI class and others from the same namespace to show information about the certificates and to sign some data.
Pros: no need to use CAPICOM.
Cons: it's still an ActiveX component and so it's available in Internet Explorer only.
But that was ok for my client so I took this path.

Categories

Resources