U2F API.com

Hardware Two Factor Authentication for Javascript / C#

Register Sign

Demo code

To use U2F Two Factor Authentication you will need a U2F compatible hardware key such as HyperFIDO
Your website must be served via HTTPS, and you will also need to include a script tag to U2F.js as follows;

<script src="https://www.u2fapi.com/u2f.js"></script>

You can use the web service to register, or call "https://www.u2fapi.com/api.aspx" with the following post data:

{
  "action" : "REGISTER",
  "data" : Registration Data from U2F callback
}           

Example:
let registerRequest = {
	challenge: 'RegisterChallenge',
	version: 'U2F_V2'
}
u2f.register("https://" + window.location.host, [registerRequest], [],
(response) => {				
        fetch('https://www.u2fapi.com/api.aspx', {
            method: 'post',
            body: JSON.stringify{
                action : "REGISTER",
                data : response.registrationData
            })
            }).then(function(response) {
                return response.json();
            }).then(function(data) {
                alert(data.WebSafeKeyHandle);
        });
	}
);

Download Documentation

You can use the web service to validate a pin, or call "https://www.u2fapi.com/api.aspx" with the following post data:

{
  "action" : "SIGN",
  "data" : Registration Data from U2F callback
}           

Example:
let registeredKey = {
  keyHandle:  keyHandle,
  version: 'U2F_V2'
}
u2f.sign("https://" + window.location.host, 'SigningChallenge', [registeredKey], 
  (response) => {
    	 fetch('https://www.u2fapi.com/api.aspx', {
            method: 'post',
            body: JSON.stringify({
                action : "SIGN",
                data : response.signatureData
            })
            }).then(function(response) {
                return response.json();
            }).then(function(data) {
                alert(data.userCounter);
        });
  }
);