(function() { navigator.id.beginProvisioning(function(eml, dur) { navigator.id.genKeyPair(function(pub) { var xhr = new XMLHttpRequest(); xhr.open('POST', #{toJSON $ support ^. provisioning}); xhr.onreadystatechange = function () { var DONE = this.DONE || 4; if (this.readyState === DONE) { navigator.id.registerCertificate(this.responseText); } }; xhr.send(JSON.stringify({eml: eml, pub: JSON.parse(pub), dur: dur})); }); }); })();