Coder Social home page Coder Social logo

u2f-client's Introduction

U2F-Client: Access U2F/USB keys directly, without browser

For a general description, please see Universal Second Factor authentication. This module provides FIDO client functionality: it provides access to available USB/HID hardware keys (role that usually filled by a web browser).

Using this module, you can build a hardware security system with U2F keys authentication, or provide U2F interface in browser emulation.

To create and check register/sign requests, please see other module: u2f.

Features

  • Straightforward, node.js style API: callbacks & events.
  • Supports all OS-es via excellent node-hid module.
  • Supports standard U2F Javascript API for browsers, checking facetId etc.

Usage

var u2fc = require('u2f-client');

// High-level API 
// registerRequest and signRequest, as well as returned values are specified in U2F documentation
u2fc.register(registerRequest, cb)   // Register U2F device, requires user presence
u2fc.sign(signRequest, cb)           // Signs with U2F device, requires user presence
u2fc.check(signRequest, cb)          // Check if signRequest is acceptable, doesn't require user presence. Returns true or false.
u2fc.devices()                       // Returns array of connected deviceInfo-s.

// Events
u2fc.on 'waiting-for-device'     // Request user to insert a U2F device, as there's no devices found
u2fc.on 'user-presence-required' // Request user to touch the U2F device (issued after register or sign requests)



// U2F Javascript API for Web Browsers 
// Careful, the callback convention is different - both error and result come as first and only argument.
// Origin of the requesting party must be provided and will be checked according to the spec rules.
browserU2F = u2fc.browserApi(origin)
browserU2F.register(registerRequests, signRequests, callback, opt_timeout)
browserU2F.sign(signRequests, callback, opt_timeout)


// Options
u2fc.waitForDevicesTimeout = 10000 // How much time should we wait if no device present.
u2fc.userPresenceTimeout = 10000   // How much time to wait for pressing the button on device.

Examples

TODO

  • it seems linux doesn't provide usage & usagePage information -> use hardcoded vendorId/productId table?
  • provide more consistency with respect to concurrent usage at the driver level (login+insert key fails), + don't close device every time.
  • provide 'disconnected' event on client.
  • test U2FClient, browser api.
  • comprehensive timeouts: low-level and BrowserAPI
  • command-line interface? (u2f sign, u2f register) maybe another module?

License: MIT

u2f-client's People

Contributors

ashtuchkin avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.