How to make Chrome respond to the Service Changed Characteristic? - google-chrome

I have a small device implementing a Bluetooth server and a JS page which I open on Chrome that connects and manipulate some of the device characteristics.
Since I'm still playing with the server code, I'm constantly changing/adding services and characteristics and noticed that Chrome still shows my the old ones (actually, more like an unclear mix of old and new ones). Other devices like my phone show the new characteristics.
How can I order Chrome to rediscover services and delete its cache? I've tried to just define the Service Change Characteristic and it didn't help, then tried notify the client upon connection with the values 0x0000 and 0xFFFF (assuming that would invalidate the whole range of handles) but nothing happened..
Also - what does Chrome take as the device name? (in case there are multiple "names", I refer to what's displayed in the scan window). I've tried to set the name in the "aioble.advertise()" function, and also set it in the device name characteristic (0x2A00 under the generic access service) and both didn't change the value. It's still showed as "ESP32" which I believe is some kind of default..
I was hinted that the bluetooth spec is implemented differently between Chrome/Android/iPhone/etc.. So I was hoping to get an answer of how does Chrome implement the Service Changed feature? What should I do as the server to order the client to refetch services data?
Thanks!

I looked at the Web Bluetooth Draft Community Report, last updated on 9 June 2022. Section 6.6.5. Responding to Service Changes describes how Web Bluetooth might be supposed to handle a service changed event.
But according to the Implementation Status, the Service Changed Event is not implemented on any of the platforms as of now.
You could open an issue on their Github page to get more information.

Related

Is it possible to create a Google Chrome extension that can set my computer's network settings?

I have a device that uses Chrome browser for it's front end.
I would like to add a wizard to it, but I don't want to use up any more memory or storage space on the device, especially since the wizard will likely only be used once, during the initial device setup.
So, it is possible to create a Google Chrome extension that can access and change my computer's network settings, as long as I give it permission to do so, or is that completely out of scope for a Google Chrome extension?
Basically, I want the extension to walk the customer through the initial setup process, part of which includes configuring the computer's network settings to be compatible with the device's default network settings. At the end of the wizard, the extension would put the computer's network settings back to what they originally were.
Is it possible to create a Google Chrome extension that can access and change my computer's network settings, as long as I give it permission to do so [...]
No, no Chrome API provides this level of access. So an extension cannot do it on its own.
As wOxxOm mentions in a comment, it's possible to also provide a separate program (called Native Host) that an extension can start, then talk to it to do things outside of extension APIs. However, that complicates the deployment of such an extension: you can't add the host components to a Web Store app, you need a separate installer for it.
Presumably, you're targeting multiple OSes with the browser being an interface for your device; this further complicates your hypothetical "wizard" and its installer.
Perhaps the best you can do is clear documentation + an extension/webpage that can test connectivity and suggest troubleshooting steps.
Your requirement is not still clear.
But it is understood that you want to change the ip address settings through any app.which will store a basic setting saved.
it is possible for some specific area but I don't know what is your condition.

Architectures to access Smart Card from a generic browser? Or: How to bridge the gap from browser to PC/SC stack? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 13 days ago.
The community reviewed whether to reopen this question 13 days ago and left it closed:
Original close reason(s) were not resolved
Improve this question
What are the existing client-side architectures to access a local Smart Card thru a PC/SC Smart Card reader (ISO 7816-3, ISO 14443) from a generic browser (connected to a server through http(s)), preferably from Javascript, with the minimum installation hassle for the end user? The server needs to be able to at least issue APDUs of its choice to the card (or perhaps delegate some of that to client-side code that it generates). I am assuming availability on the client side of a working PC/SC stack, complete with Smart Card reader. That's a reasonable assumption at least on Windows since XP, modern OS X and Unixes.
I have so far identified the following options:
Some custom ActiveX. That's what my existing application uses (we developed it in-house), deployment is quite easy for clients with IE once they get the clearance to install the ActiveX, but it does not match the "generic browser" requirement.
Update: ActiveX is supported mostly by the deprecated IE, including IE11; but not by Edge.
Some PC/SC browser extension using the Netscape Plugin API, which seems like a smooth extension of the above. The only ready-made one I located is SConnect (webarchive). It's no longer promoted (Update: thought still actively maintained and used late 2020 in at least one application), it's API documentation (webarchive) is no longer officially available, and it has strong ties to a particular Smart Card and reader vendor. The principle may be nice, but making such a plugin for every platform would be a lot of work.
Update: NPAPI support is dropped by many browsers, including Chrome and Firefox.
A Java Applet, running on top of Oracle's JVM (1.)6 or better, which comes with javax.smartcardio. That's fine from a functional point of view, well documented, I can live with the few known bugs, but I'm afraid of an irresistible downwards spiral regarding acceptance of Java-as-a-browser-extension.
[update, Feb 2021]: This answer considered the WebUSB API as a promising solution solution in 2015, then reported in 2019 that can't work or is abandoned. I made a question about it there.
Any other idea?
Also: is there some way to prevent abuse of whatever PC/SC interface the browser has by a rogue server (e.g. presenting 3 wrong PINs to block a card, just for the nastiness of it; or making some even more evil things).
The fact is that browsers can't talk to (cryptographic) smart cards for other purposes than establishing SSL.
You shall need additional code, executed by the browser, to access smart cards.
There are tens of custom and proprietary plugins (using all three options you mentioned) for various purposes (signing being the most popular, I guess) built because there is no standard or universally accepted way, at least in Europe and I 'm sure elsewhere as well.
Creating, distributing and maintaining your own shall be a blast, because browsers release every month or so and every new release changes sanboxing ir UI tricks, so you may need to adjust your code quite often.
And you probably would want to have GUI capabilities, at least for asking the permission of the user to access a card or some functionality on it.
For creating a multiple-platform, multiple browser plugin, something like firebreath could be used.
Personally, I don't believe that exposing PC/SC to the web is any good. PC/SC is by nature qute a low level protocol that when exposing this, you could as well expose block level access to your disk and hope that "applications on the web are mine only and they behave well" (this should answer your "Also"). At the same time a thin shim like SConnect is the easiest to create, for providing a javscript plugin.sendAPDU()-style code (or just wrap all the PC/SC API and let the javascript caller take care of the same level of details as in native PC/SC API use case).
Creating a plugin for this purpose is usually driven by acute current deficiencies.
Addressing the future (mobile etc) is another story, where things like W3C webcrypto and OpenMobile API will probably finally somehow create something that exposes client-side key containers to web applications. If your target with smart cards is cryptography, my suggestion is to avoid PC/SC and use platform services (CryptoAPI on Windows, Keychain on OSX, PKCS#11 on Linux)
Any kind of design has requirements. This all applies if you're thinking of using keys rather than arbitrary APDU-s. If your requirement is to send arbitrary APDU-s, do create a plugin and just go with it.
Update (8/2016): A new API for the Web called WebUSB API is being discussed. You can already use it with Chrome v54+.
This standard will be implemented in all major browsers and will replace the need for third-party applications or extensions for Smard Cards :-)
So the new answer is YES!
And the OSI-like architecture stack is:
PC/SC
CCID v1.1
WebUSB API
USB driver, i.e. libusb.
2019 Update: As #vlp commented, it seems that it doesn't work any in Chrome because they decided to block WebUSB for smartcards for some specious reasons :-(
Note: Google annonced that they will abandon Chrome Apps in 2017.
Previous anwser:
Now (2015) you can create a Google Chrome App, using the chrome.usb API.
Then you access the smartcard reader via its CCID-compliant interface.
It's not cross-browser but JavaScript programmable & cross-platform.
Anyway Netscape Plugin API (NPAPI) is not supported any more by modern browsers. And Java applets are being dismissed by browser vendors.
I have just released a beta plugin addressing this problem.
This beta code is available here:
https://github.com/ubinity/webpcsc-firebreath
This plugin is based on the firebreath framework and has been beta-tested with Fireofx and Chrome under Linux/WinXP/Win7. Source code and extension pack are provided.
The basic idea is to provide a PCSLite API access and then develop a more friendly JS-api on top of this.
This plugin is under active development, so feel free to send any report and request.
For your first question I have little hope: either you are satisied with a very small subset of smart card functionality (like signing e-Mail or PDFs), then you may use some ready-made software (like PKCS), ideally maintained by the smart card company, or you want broader functionality and need to invest considerable effort on your own. Surely PCSC is the starting point to choose.
At least for your "also:" there is some hope.
1) Note, that some specifications (e.g. ICAO/German BSI TR-3110) request a method, where a PIN is not blocked, but uses a substantial amount of time as soon as the error counter hits 1 before replying. The final attempt must be enabled using a different command, otherwise no further comparison and error counter adjustment is done.
2) Simply protect the Verify command by requiring secure messaging. Sensitive applications use secure messaging for everything, so first step a session key is negtiated, which is second applied to all succeeding commands and responses. The effect would be, that the command is rejected due to incorrect MACs long before a comparison or modification of error counter is done.
There is another browser plugin similar to the one proposed by #cslashm available at http://github.com/cardid/WebCard. Is also open source and can be installed with "minimum installation hassle" as required in the original question. You can see an example of use visiting http://plugin.cardid.org
WebCard has been tested in IE 8 through 11, Chrome and Firefox in Windows and in Chrome and Safari in Mac OS X. Since is just a wrapper for PC/SC it requires in Mac OS X the installation of SmartCard Services from http://smartcardservices.macosforge.com
As chrome and firefox going to stop the support of NPAPI Plugin, there is no secure solution available to maintain the session for the smart card reading instead your certificate of the card have support for mutual ssl ,I answered for the similar question source,It might help
Its dirty, but if its acceptable / viable to install a bridge daemon/service on the client machine, then you can write a local bridge service (e.g. in python / pyscard) that exposes the smartcard via a REST interface, then have javascript in the browser that mediates between that local service (facade) and the remote server API.
Web Serial API (draft) can be used to communicate with a serial smart card reader from some browsers.
Buyer beware: This API is a draft and may be changed/abandoned at any time.
Speaking about Chrome, you can now use the Smart Card Connector app provided by Google which bundles the PC/SC-Lite port and the generic CCID driver.
The app itself works through the chrome.usb API, that was mentioned by the previous commenters.
So, instead of rewriting the whole stack (starting from the lowest level - raw USB), it's now possible for developers to code only the part that works on top of PC/SC API - which is exposed by the Connector app.
Clients,clients,clients...plugins,..JSApis..
Well..
For certain we know this : All browsers, when communicating to an Apache or IIS servers, are actually signing "something" when a https/SSL handshake process is needed.
For instance, a typical Apache configuration like this:
SSLVerifyClient require
SSLVerifyDepth 10
SSLOptions +FakeBasicAuth +StdEnvVars +ExportCertData +OptRenegotiate
Initiates a PIN pad pop up and the user must insert the smartcard pin to go on.
Well, my idea is : why not make the turn to the server, and tweak that behaviour, in order to upload a bytestream of stuff to sign something when a handshake is initiaded?
I have a setup where a smartcard reader is scanned to login a user. The PC/SC library work great on desktop. Somebody had mentioned to use
Emscripten (https://github.com/kripken/emscripten) compiler which compiles c++ into JavaScript code. But that didn't work well because some of the functions being used by PC/SC are only available server side.
After much research. I finally gave up on a client side solution, chrome web usb API also couldn't recognize the reader.
I then decided to give signalR a try and set up a hub on the PC connected to the smartcard reader and this approach worked out very well.

Enable network simulation doesn't work for query IsNetworkAvailable

I'm trying to find out in my app is there network available using Tools/Simulation Dashboard in Visual Studio 2012 for WP 8 app (of course, debug mode is on).
Whatever I do I got for DeviceNetworkInformation.IsNetworkAvailable always true although I set Control setting to No Network. But if I try some activity in app that need network access I can't do that (so it works but withoud detection which is my primary goal).
Are they any thing to do to get False to my query and to do i.e. Message Box that says "No Network available".
Also,
DeviceNetworkInformation.CellularMobileOperator
always return Fake GSM Network" with No Network setting set to. When I change setting I got "Simulation setting were applied succesfully" in VS status bar.
Thanks for the question. I will answer based on the fact that I designed this feature as a Program Manager in Microsoft.
Simulation Dashboard currently only throttles the Network Bandwidth (limited by your current network) and do not simulate "actual" network conditions. So APIs will still return the "actual" network type and/or name but the network speed/quality will be affected as per your choice when the Network Simulation is enabled. In case you want to validate the API calls, you might have to test your app on a Windows Phone device with data connection switched off.

Webrtc no video when users are on different network

So I have a website set up. With a clienta page and a clientb page.
This is basically a split version of this site:
https://webrtc-demos.appspot.com/html/pc2.html
I am using signalr (websockets) to exchange information between the clients.
When a user opens up both cleinta and b on the same computer it works fine.
When a user opens up clienta on one computer and on another computer opens up clientb BUT both computers are on the same network, it works fine.
When a user open up clienta on one computer and on another computer opens clientb BUT on different networks there is no video or audio.
When the ice messages are exchanged i pass back a number so i know the order its sent. On the opposite end they dont always arrive the same order, but audio #1 always gets there before audio#2. and the same with video.
In all cases im using chrome dev 24.
I realize sequence and timing are everything with webrtc. Im just not understanding how it can work on separate pcs on the same network but not different networks. I should point out that when i say same network ive test both at work with 2 pcs and at home with 2 pcs. so i dont think its a firewall thing.
Any ideas?
I did check out https://apprtc.appspot.com/ as its a slightly more relevant link. This lead me to adding a couple settimeouts though they didnt seem to help.
One last thing, i did mention about the ice messages. I should also note that both sides send and receive all the messages. an offer is created and an answer is created. Hence, it working on same network machines.
Update:
Im using jsep and all the latest syntax according to webrtc.org
Update 11/15/2012:
So is there a open source package for creating a media relay?
Specifically .net, but could be php. The current site is public facing, this is how I was able to test on multiple networks. So it seems like I just need another endpoint for the media relay.
Updated 11/16/2012:
In hopes that I'll get it working or get valuable input from other developers I'm putting my code out on github.
https://github.com/thorst/RTC
Updated 11/21/2012
The code now works for everything except different network connections. (as described in this post)
Updated 5/28/2013
This years google io was much better at explaining turn, stun, and ice.
http://www.youtube.com/watch?feature=player_embedded&v=p2HzZkd2A40
For reference here are the older helped me get started
http://www.youtube.com/watch?v=E8C8ouiXHHk
http://www.youtube.com/watch?v=dAhhniqwkp8
Chrome doesn't implement TURN yet. STUN will only help with some types of NATs but not with symmetric ones which are prevalent in home routers. You need a media relay with a public IP to connect two devices that are behind symmetric NATs and the standard for that is TURN https://www.rfc-editor.org/rfc/rfc5766 .

Programmatically change Chrome extension update frequency

I'm developing a Chrome App (as a packaged app/extension) which purpose is to act as the base platform for several fullscreen apps to be build on top of. Chrome will be running on Ubuntu Linux.
And no trouble so far. But then I was told, that an intended app it is to be the platform for requires the source code to be updated with very short notice, as it probably is to be deployed for large scale use before the system has been tested through (even though it's a bad idea to deploy software that's not completely stable, but we're on a tight schedule). The problem is, that the "a few hours" interval for the autoupdating mechanism just isn't good enough.
So I somehow need to have the updating interval changed. I know this can be done with the --extensions-update-frequency command line switch, but as apps cannot access the command line (for obvious security reasons), and I'd prefer that the intended background page was to handle all the "administration", I don't think that switch is possible to use.
Is it somehow possible to update at a higher frequency? Or at times when it's ordered to?
There is now a method chrome.runtime.requestUpdateCheck():
Requests an update check for this app/extension.
It will return a status, which can be either "no_update", "update_available" or "throttled".
Unfortunately, the docs do not specify the limits for frequency that will trigger "throttled".
Your best option will be to have the extension manually check with your servers for an updated version. If there is an updated version show the user a desktop notification to manually update.
Potentially you could write a NPAPI plugin to modify the update frequency.
This may cause issues with CSP but you can try to live load JavaScript from your server that executes in the extension. In this case to "update" your extension you would simply update the JS hosted on your servers and the extension would automatically start using it on next load.