navigator.id.beginProvisioning(function(email, cert_duration) {
  $.get('/api/loggedin')
    .success(function(r) {
      navigator.id.genKeyPair(function(pubkey) {
        // TODO: find out whether or not this is needed
        if (typeof(pubkey) == "string") {
          pubkey = JSON.parse(pubkey);
        }

        $.ajax({
          url: '/api/cert_key',
          data: JSON.stringify({
            pubkey: pubkey,
            duration: cert_duration
          }),
          type: 'POST',
          headers: { "Content-Type": 'application/json' },
          dataType: 'json',
          success: function(r) {
            navigator.id.registerCertificate(r.cert);
          },
          error: function() {
            navigator.id.raiseProvisioningFailure("couldn't certify key");
          }
        });
      });
    })
    .error(function() {
      navigator.id.raiseProvisioningFailure('user is not authenticated');
    });
});

navigator.id.beginProvisioning(function(email, cert_duration) {
  $.get('/api/loggedin')
    .success(function(r) {
      navigator.id.genKeyPair(function(pubkey) {
        if (typeof(pubkey) == "string") {
          pubkey = JSON.parse(pubkey);
        }

        $.ajax({
          url: '/api/cert_key',
          data: JSON.stringify({
            pubkey: pubkey,
            duration: cert_duration
          }),
          type: 'POST',
          headers: { "Content-Type": 'application/json' },
          dataType: 'json',
          success: function(r) {
            navigator.id.registerCertificate(r.cert);
          },
          error: function() {
            navigator.id.raiseProvisioningFailure("couldn't certify key");
          }
        });
      });
    })
    .error(function() {
      navigator.id.raiseProvisioningFailure('user is not authenticated');
    });
});

Remove a TODO that's been taken care of
Remove a TODO that's been taken care of

This piece of code is needed on Firefox because the public key is
passed in as a string, not a JSON object.
