To build, simply call
npm start. All files will be output by default to the dist directory, but you can
modify build settings by tinkering with the webpack configuration, webpack.config.js, and the typescript
compiler configuration, tsconfig.json (not recommended).
Before you run tests for the browser implementation you must start up the local test server:
In another terminal, call
npm test and open the IP listed by Karma in the browser you wish to test.
To test the Node implementation, simply open another terminal and call
// 1. Create virtual U2F devicevar device = createSoftU2FDevice();// 2. Get a registration challenge from the servervar regReq = getRegistrationRequestFromServer();// 3. Register the device to the account you just got a challenge fromvar regRes = device.register(regReq.appID, regReq.challenge, yourServerDomain, regReq.userID);var keyID = regRes.keyID; // you can use this to export the keypair you just generatedsendRegistrationResponseToServer(regRes.response);// 4. Now the user needs to save their U2F credentialvar extKeyPair = device.export(keyID, aUint8ArrayPasswordWhichWillBeDisposedOf);saveEncryptedKeyPairToJSONFile(extKeyPair);// 4. Alternatively, or as an additional measure, have the user write down the raw private in case something happens to the key filevar extPrivate = device.exportRaw(keyID);window.alert('Write this on a sticky: ' + extPrivate);