2

I'm looking for a JavaScript source code (client side) to make communication between Fido U2F token and Google Chrome (Version 41.0.2272.89 m).

Please help me

Scott Stensland
  • 26,870
  • 12
  • 93
  • 104
Abdessamad Doughri
  • 1,324
  • 2
  • 16
  • 29
  • I don't think there is "a Javascript sourcecode". Because Javascript is implemented into web browsers using standards. Each web browser has its own way of implementing these standards. Are you looking for Javascript interpreter ? –  Mar 19 '15 at 16:19
  • I assume you want to authenticate with Fido U2F? So would you like browse to your distributed server application and authenticate with a USB hardware token, that e.g. reads the fingerprint? – peter_the_oak Mar 19 '15 at 16:27
  • I'm trying to run this JavaScript function :window.u2f.register(), then I'll show the token RegisterResponse data in an alert before I'll send it to my server. that's what I wanna do – Abdessamad Doughri Mar 19 '15 at 16:31
  • possible duplicate of [How do I use FIDO U2F to allow users to authenticate with my website?](http://stackoverflow.com/questions/26637660/how-do-i-use-fido-u2f-to-allow-users-to-authenticate-with-my-website) – mritz_p Jun 09 '15 at 10:11

2 Answers2

4

Here is an example to getting the Token response for registration using Yubico u2f-api file

var RegistrationData = {"challenge":"dG7vN-E440ZnJaKQ7Ynq8AemLHziJfKrBpIBi5OET_0",
                     "appId":"https://localhost:8443",
                     "version":"U2F_V2"};

window.u2f.register([RegistrationData], [],
  function(data) {if(data.errorCode) {
        alert("U2F failed with error: " + data.errorCode);
        return;
    }
    alert(JSON.stringify(data));
}); 

you've to include the u2f-api.js and use an Https server

Abdessamad Doughri
  • 1,324
  • 2
  • 16
  • 29
1

You can perform the registration, and even parse the registrationData using Javascript

let registerRequest = {
 challenge: 'RegisterChallenge',
 version: 'U2F_V2'
}
u2f.register('https://localhost', [registerRequest], [],
 (response) => {
 U2FRegistration.parse(response.registrationData);
 console.log(U2FRegistration);
 }
);

Here is a github repo demonstrating this: https://github.com/infiniteloopltd/U2FJS - and as mentioned, you need a HTTPS server, and include u2f-api.js

Fiach Reid
  • 6,149
  • 2
  • 30
  • 34