POP3/IMAP direct implementation in Javascript - javascript

Is there any way, how to communicate with POP3/IMAP server.
For example for build a pure-JavaScript e-mail notifier?
I've found this:
ftp://ftp.activexperts-labs.com/samples/aemail/HTML/POP3/index.htm
Unfortunately it uses the ActiveX objects, which really doesn't work in many modern browsers.
It would be nice to have ability to send a packet through any protocol (= not only HTTP/S) in HTML5.

It is not possible with purely browser-based Javascript: there are is no direct socket connection support in browser Javascript. You can use special extensions in things like Firefox's Extension environment to do pure socket connections, but not in a standard browser JS file.

My guess would be that the Same Origin Policy implemented in all recent browsers would slap you in the face for this. I'd simply add a server-side layer to mediate between JSON/AJAX and POP3/IMAP - roughly what gmail does.

Related

Sign XML using pure Javascript in the browser

Is it possible to use pure JavaScript to sign XML documents in the browser?
I believe there are hard security restrictions here, but maybe there is some way of doing that.
Here is a solution based on Web Crypto - https://github.com/PeculiarVentures/xadesjs
If you mean the XmlDSig which involves accessing the local cert store then I am afraid that currently there is no way to have a reliable Javascript code that could access the cert store at the client side and use the private key of the certificate.
Hundreds of developers would die for such technology, however, the Web Crypto API is still a draft and is not implemented by web browsers.
To sign documents at the client side you still need an OS bridge
a browser plugin - possibly a most difficult route as writing plugins for all possible browsers for all possible systems could be an overkill
a Java applet - considering Chrome has just dropped the support for NPAPI (plugin API), this seems to be obsolete. Mozzila will drop the support soon, too.
a ClickOnce application that is run by a client .NET platform - that still works, however is limited to OSes that support .NET/ClickOnce
If you need more references, Google for "javascript access certificate store". Example SO threads:
How to access windows certificate store in javascript?
Access browser certificate store using javascript
(these and other threads also support the argument that this is currently not possible)
I am looking for the same functionality.
As of now I found https://github.com/yaronn/xml-crypto
but did not tried yet.
For just signing (not XML) with x509 certificate I sucessfully used https://github.com/digitalbazaar/forge
If you need signature in a browser, maybe you need a specialized solution?
For example, this: https://www.cryptopro.ru/products/cades/plugin
(Use google translate).

Cross domain - temporary edit pages with javascript

I have an idea for a web application and I'm having some javascript trouble.
Suppose the application needs to get a client's website url, show it (in an iframe or something). And then it should be able to temporarily tweak its design with Javascript which I assume is called Javascript injection. (Something similar to what the Developer Tools of browsers can do.)
So the question is: Is this cross domain javascript and if so, what solutions could I use?
, and what's the easiest way?
On a related note: What if the user adds some of my application's javascript code to their website (like how some APIs work), Would that help in any way.
Thanks.
same origin policy does not apply when you are armed with the proper knowledge of how modern web browsers work (IE8+ and of course all the other ones are always ahead of IE)
I specifically tackled this problem by using postMessage and iframe for cross browser communication. This technique works in IE8+ and all modern browsers. Also, ensure you are setting your privacy policy in your headers for 3rd party cookie support in IE.
You can see this working live if you go to kitgui.com and try the demo. You can also use this for free.
If they are including your JS in their page, then the JS is running from their page and you can just use standard DOM.
If they aren't, then the same origin policy will prevent you from touching their site.
This is cross domain. So the solution: Server Side Languages
PHP, ASP.Net, Ruby on Rails, etc. Load their website via that and then you can touch it because it will be a copy on your site. I will warn you though, this can be very difficult when using libraries like CURL (at least in my experience with PHP's CURL).
You culd use bookmarklet to add your javascript code to client's webpage. Like firebug lite does.

How to change registry settings on a system through web browser

I am trying to develop a web page that will allow user to edit registry settings in windows system. Can i achieve it with client side scripting language.? If yes please suggest me language to do.
Can we do it with jQuery or any other type of library.
Due to obvious security concerns, this is only possible in Internet Explorer(!). This is not a jQuery library, but an activeX control; so it's quite unpleasant to use.
You have been warned, so here is the documentation :
http://technet.microsoft.com/en-us/library/ee156602.aspx
Fortunately is impossible to access the registry from a web app: the only way you have is through an ActiveX control but I would not go down this road.
have a look at the below
Access registry from a web aplication
Far from ideal but ...
If you serve up a ".hta" file (HTml Application) from your web server, Windows will run it as a program outside of IE and give it the privileges of the PC user. It will be in a separate window and there won't be any browser features (Back/Refresh/Address bar etc).
Even then, modern versions of Windows will prompt the user with security warnings if a HTA is launched from anywhere other than a local drive.
I know this thread is old, but I am not sure I like any answers for this problem. Instead of trying to access the Registry directly through Javascript, try writing a Java Applet and talk to the java applet using Javascript. Then in the JavaApplet you can write some JNI code to write a native dll to do what you need. It isn't a direct solution to your problem, but it will allow you to do what you need across multiple browsers. The downside is that you can't use it on browsers that do not support running a Java Applet, such as a mobile platform.
This method will also require you to sign your Java Applet. This is how you get around the security issues. The user will have to accept the applet the first time to give the security access.

Will Websockets allow a server to run in the browser?

Are there any plans for a Websockets listen function?
Allowing peer to peer applications in the browser could be revolutionary.
I found this answer: Will HTML5 allow web apps to make peer-to-peer HTTP connections? but it is rather old. I think the specification it refers to (the Connection api) has now been replaced with Websockets, which does not mention any listen facility.
The WebSockets API does not provide a way to listen for connections; it is client only.
You might be interested in Opera Unite.
Update:
Also check out pusherapp. It's a WebSockets service online. They charge for over 5 clients, but it's super simple to setup and use. Depending on what your p2p application requirements are, it might suffice.
Old question, but I was wondering the same thing, and came across peer-server, which might be worth having a look at. It uses WebRTC, and looks like it does what you're thinking:
https://github.com/PeerServer/peer-server
Tangentially related to your question, but you did say "p2p in the browser", so..
The Flash player has p2p APIs that allow direct connection with other peers (typically other browsers) over UDP.
The APIs are geared toward using those connections for voice/video streaming, but it seems possible to use them for generic message passing as well.
The tricky point of course is "how do peers find each others?". Currently, Adobe offers a free/beta service to do that, called Cirrus (formerly Stratus). It's also possible to buy Flash Media servers from Adobe to do the same (which also provide TCP server-based fallbacks for folks that are behind UDP-unfriendly firewalls.) Presumably, open-source alternatives like Red5 will have support for it too at some point.
If you are not looking for a generic browser solution, for non secure and limited connections you may use a Google Chrome extension to do the job:
Web Server for Chrome
https://chrome.google.com/webstore/detail/web-server-for-chrome/ofhbbkphhbklhfoeikjpcbhemlocgigb

Detecting the autoproxy details in Javascript

Is it possible to detect and get proxy server name and port in javascript?
No. The browser proxy settings are not available from JavaScript running in a web page.
Maybe. The browser proxy settings may be available (in some web browsers) from JavaScript running with elevated permissions (for example, a Firefox add-on).
For what it's worth: While you're asking about JavaScript, getting access to the browser proxy settings even from any kind of browser plug-in such as a Flash or Java applet is also not possible, or at the very least not in any reliable or compliant way.
I mention this only because sometimes such plug-ins provide viable workarounds when JavaScript can't do something ... but here I think you are S.O.L.
Perhaps you could tell us a little bit more about what you are trying to accomplish? Maybe there's another way to address your needs.

Categories