Make the js-lib to work with maas mobile flow (#5)

* Make the js-lib to work with maas mobile flow

The library now react on received data from the server ( based on status) and propagete when status
changes to the client, so appropriate message can be shown to the user

* Fix some namings

Rename cb2 to cbStatus to better represent what is used for
Fix variable name to meet naming convention
1 file changed
tree: b9db346d474b7bc2557332b6a5d21bf3a7bb49db
  1. example/
  2. lib/
  3. test/
  4. .gitignore
  5. bower.json
  6. Gruntfile.js
  7. index.js
  8. LICENSE
  9. NOTICE
  10. package.json
  11. README.md
README.md

Headless M-Pin Client Library

Requirement for build & testing

  1. Nodejs
  2. Grunt
  3. Mocha
  4. Bower

Installation

$ git clone
$ cd project_folder
$ npm install
$ grunt build

Simple usage example

  • Registration
var mpin = mpinjs({server: <serverIP-and-port>});

mpin.init(<callback>);

mpin.makeNewUser(<userId>);

mpin.startRegistration(<userId>, <callback>);

/* Wait for end-user to confirm identity */

mpin.confirmRegistration(<userId>, <callback>);

/* If successful, read desired user secret (PIN or password) */

mpin.finishRegistration(<userId>, <user-secret>);

  • Authentication
mpin.startAuthentication(<userId>, <callback>);

/* If successful, read user secret (PIN or password) */

mpin.finishAuthentication(<userId>, <user-secret>, <callback>);
  • Authentication with a mobile device
mpin.getAccessNumber(<callback>);

/* Display Access number to end user */

mpin.waitForMobileAuth(<timeout-sec>, <retry-period-sec>, <callback>);

/*
   If successfull - Authentication completed
   If exits with timeout, then no successfull authentication from mobile device was completed
   If one needs to cancel the waiting for authentication from the mobile device, call cancelMobileAuth()
*/

Running Tests

Install development dependencies:

$ npm install

Then:

$ npm test

Actively tested with node:

  • 0.10.4