You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@milagro.apache.org by ni...@apache.org on 2016/07/14 18:02:21 UTC
[1/6] incubator-milagro-mfa-js-lib git commit: Add getQrUrl method to
extend the mobile flow (#3)
Repository: incubator-milagro-mfa-js-lib
Updated Branches:
refs/heads/master 1914a9616 -> ee2107a6d
Add getQrUrl method to extend the mobile flow (#3)
Project: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/commit/688b88e7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/tree/688b88e7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/diff/688b88e7
Branch: refs/heads/master
Commit: 688b88e7f8322bdf41b5f050cf9453581dff60a5
Parents: 1914a96
Author: bbvox <bb...@users.noreply.github.com>
Authored: Mon May 30 11:26:46 2016 +0300
Committer: bbvox <bb...@users.noreply.github.com>
Committed: Mon May 30 11:26:46 2016 +0300
----------------------------------------------------------------------
lib/mpin.js | 31 ++++++++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/blob/688b88e7/lib/mpin.js
----------------------------------------------------------------------
diff --git a/lib/mpin.js b/lib/mpin.js
index 70cb32c..bbbed18 100644
--- a/lib/mpin.js
+++ b/lib/mpin.js
@@ -579,7 +579,7 @@ var mpinjs = (function () {
}
self.webOTT = data.webOTT;
- returnData = {
+ var returnData = {
accessNumber: data.accessNumber,
ttlSeconds: data.ttlSeconds,
localTimeStart: data.localTimeStart / 1000,
@@ -590,6 +590,32 @@ var mpinjs = (function () {
});
};
+ Mpin.prototype.getQrUrl = function (userId, cb) {
+ var self = this, _reqData = {};
+
+ _reqData.url = this.generateUrl("getqrurl");
+ _reqData.type = "POST";
+ _reqData.data = {
+ prerollid: userId || ""
+ };
+
+ this.request(_reqData, function (err, data) {
+ if (err) {
+ return cb(err, null);
+ }
+ self.webOTT = data.webOTT;
+
+ var returnData = {
+ qrUrl: data.qrUrl,
+ ttlSeconds: data.ttlSeconds,
+ localTimeStart: data.localTimeStart / 1000,
+ localTimeEnd: data.localTimeEnd / 1000
+ };
+
+ cb && cb(null, returnData);
+ });
+ };
+
Mpin.prototype.waitForMobileAuth = function (timeoutSeconds, requestSeconds, cb) {
var self = this, _reqData = {};
if (!this.webOTT) {
@@ -685,6 +711,9 @@ var mpinjs = (function () {
case "getnumber":
url = this.settings.getAccessNumberURL;
break;
+ case "getqrurl":
+ url = this.settings.getQrUrl;
+ break;
case "getaccess":
url = this.settings.accessNumberURL;
break;
[2/6] incubator-milagro-mfa-js-lib git commit: Update reference to
milagro-crypto & remove bower version
Posted by ni...@apache.org.
Update reference to milagro-crypto & remove bower version
Project: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/commit/f33c5a1f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/tree/f33c5a1f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/diff/f33c5a1f
Branch: refs/heads/master
Commit: f33c5a1f28c11b7d52409db9209f9bc349dcaa3b
Parents: 688b88e
Author: Boyan Bakov <bo...@certivox.com>
Authored: Mon May 30 13:22:33 2016 +0300
Committer: Boyan Bakov <bo...@certivox.com>
Committed: Mon May 30 13:22:33 2016 +0300
----------------------------------------------------------------------
Gruntfile.js | 2 +-
bower.json | 3 +--
2 files changed, 2 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/blob/f33c5a1f/Gruntfile.js
----------------------------------------------------------------------
diff --git a/Gruntfile.js b/Gruntfile.js
index 8562817..eae8924 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -6,7 +6,7 @@ module.exports = function(grunt) {
separator: ';'
},
mergeJs: {
- src: ['bower_components/amcl/js/DBIG.js','bower_components/amcl/js/BIG.js', 'bower_components/amcl/js/FP.js', 'bower_components/amcl/js/ROM.js', 'bower_components/amcl/js/HASH.js', 'bower_components/amcl/js/RAND.js', 'bower_components/amcl/js/AES.js', 'bower_components/amcl/js/GPM.js', 'bower_components/amcl/js/ECP.js', 'bower_components/amcl/js/FP2.js', 'bower_components/amcl/js/ECP2.js', 'bower_components/amcl/js/FP4.js', 'bower_components/amcl/js/FP12.js', 'bower_components/amcl/js/PAIR.js', 'bower_components/amcl/js/MPIN.js', 'bower_components/amcl/js/MPINAuth.js', 'lib/mpin.js'],
+ src: ['bower_components/milagro-crypto/js/DBIG.js','bower_components/milagro-crypto/js/BIG.js', 'bower_components/milagro-crypto/js/FP.js', 'bower_components/milagro-crypto/js/ROM.js', 'bower_components/milagro-crypto/js/HASH.js', 'bower_components/milagro-crypto/js/RAND.js', 'bower_components/milagro-crypto/js/AES.js', 'bower_components/milagro-crypto/js/GPM.js', 'bower_components/milagro-crypto/js/ECP.js', 'bower_components/milagro-crypto/js/FP2.js', 'bower_components/milagro-crypto/js/ECP2.js', 'bower_components/milagro-crypto/js/FP4.js', 'bower_components/milagro-crypto/js/FP12.js', 'bower_components/milagro-crypto/js/PAIR.js', 'bower_components/milagro-crypto/js/MPIN.js', 'bower_components/milagro-crypto/js/MPINAuth.js', 'lib/mpin.js'],
dest: './dist/mpinjs.js'
}
},
http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/blob/f33c5a1f/bower.json
----------------------------------------------------------------------
diff --git a/bower.json b/bower.json
index 57b92b0..c1b8137 100644
--- a/bower.json
+++ b/bower.json
@@ -1,12 +1,11 @@
{
"name": "mpinjs",
- "version": "1.0.0",
"description": "Mpin lib front-end project",
"authors": [
"MIRACL"
],
"dependencies": {
- "amcl": "https://github.com/miracl/mpin-crypto.git"
+ "milagro-crypto": "https://github.com/miracl/milagro-crypto.git#1.0.0"
},
"ignore": [
"**/*",
[6/6] incubator-milagro-mfa-js-lib git commit: Merge pull request #6
from miracl/multiProtocols
Posted by ni...@apache.org.
Merge pull request #6 from miracl/multiProtocols
Preparation for support multi authentication protocols
Project: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/commit/ee2107a6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/tree/ee2107a6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/diff/ee2107a6
Branch: refs/heads/master
Commit: ee2107a6d74a3fc23fdc8972f1bea77091a57665
Parents: c8b7bae 5590da8
Author: bbvox <bb...@users.noreply.github.com>
Authored: Thu Jul 7 14:01:01 2016 +0300
Committer: GitHub <no...@github.com>
Committed: Thu Jul 7 14:01:01 2016 +0300
----------------------------------------------------------------------
lib/mpin.js | 109 ++++++++++++++++++++++++++++++++++++++++---------------
1 file changed, 80 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
[5/6] incubator-milagro-mfa-js-lib git commit: Merge pull request #4
from miracl/updateCrypto
Posted by ni...@apache.org.
Merge pull request #4 from miracl/updateCrypto
Update reference to milagro-crypto & remove bower version
Project: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/commit/c8b7bae1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/tree/c8b7bae1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/diff/c8b7bae1
Branch: refs/heads/master
Commit: c8b7bae1a911d340637f449af571f3201cd7bb17
Parents: f105200 f33c5a1
Author: bbvox <bb...@users.noreply.github.com>
Authored: Thu Jul 7 14:00:33 2016 +0300
Committer: GitHub <no...@github.com>
Committed: Thu Jul 7 14:00:33 2016 +0300
----------------------------------------------------------------------
Gruntfile.js | 2 +-
bower.json | 3 +--
2 files changed, 2 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
[3/6] incubator-milagro-mfa-js-lib git commit: Make the js-lib to
work with maas mobile flow (#5)
Posted by ni...@apache.org.
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
Project: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/commit/f1052009
Tree: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/tree/f1052009
Diff: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/diff/f1052009
Branch: refs/heads/master
Commit: f1052009e4d92fee5e23ed1759c64bd1f4972c24
Parents: 688b88e
Author: Pavlin Angelov <si...@users.noreply.github.com>
Authored: Mon Jul 4 11:39:00 2016 +0300
Committer: bbvox <bb...@users.noreply.github.com>
Committed: Mon Jul 4 11:39:00 2016 +0300
----------------------------------------------------------------------
lib/mpin.js | 43 ++++++++++++++++++++++++++++---------------
1 file changed, 28 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/blob/f1052009/lib/mpin.js
----------------------------------------------------------------------
diff --git a/lib/mpin.js b/lib/mpin.js
index bbbed18..1ee8159 100644
--- a/lib/mpin.js
+++ b/lib/mpin.js
@@ -616,7 +616,7 @@ var mpinjs = (function () {
});
};
- Mpin.prototype.waitForMobileAuth = function (timeoutSeconds, requestSeconds, cb) {
+ Mpin.prototype.waitForMobileAuth = function (timeoutSeconds, requestSeconds, cb, cbStatus) {
var self = this, _reqData = {};
if (!this.webOTT) {
return cb({code: Errors.wrongFlow.code, type: Errors.wrongFlow.type, message: "Need to call getAccessNumber method before this."}, null);
@@ -624,6 +624,7 @@ var mpinjs = (function () {
return cb({code: Errors.missingParams.code, type: Errors.missingParams.type, message: "Missing timeout/expiration period(in seconds)."}, null);
}
+ self.mobileStatus = self.mobileStatus || '';
if (typeof this.timeoutPeriod === "undefined") {
this.timeoutPeriod = timeoutSeconds * 1000;
@@ -635,22 +636,34 @@ var mpinjs = (function () {
this.request(_reqData, function (err, data) {
var _requestPeriod;
+
if (err) {
- if (err.status === 401 && self.timeoutPeriod > 0) {
- _requestPeriod = requestSeconds ? requestSeconds * 1000 : 3000;
- self.timeoutPeriod -= _requestPeriod;
-
- self.intervalID2 = setTimeout(function () {
- self.waitForMobileAuth.call(self, timeoutSeconds, requestSeconds, cb);
- }, _requestPeriod);
- return;
- } else if (self.timeoutPeriod <= 0) {
- delete self.timeoutPeriod;
- cb && cb(Errors.timeoutFinish, null);
- return;
- }
+ cb && cb(err, null);
} else {
- self._authenticate({mpinResponse: data}, cb);
+ authOTT = data.authOTT
+ delete data.authOTT
+
+ if(data.status === 'authenticate') {
+ cbStatus && cbStatus(data);
+ self._authenticate({mpinResponse: {authOTT: authOTT}}, cb);
+ } else {
+ if (self.timeoutPeriod > 0) {
+ _requestPeriod = requestSeconds ? requestSeconds * 1000 : 3000;
+ self.timeoutPeriod -= _requestPeriod;
+ if (data.status !== self.mobileStatus) {
+ self.mobileStatus = data.status;
+ cbStatus && cbStatus(data);
+ }
+ self.intervalID2 = setTimeout(function () {
+ self.waitForMobileAuth.call(self, timeoutSeconds, requestSeconds, cb, cbStatus);
+ }, _requestPeriod);
+ return;
+ } else if (self.timeoutPeriod <= 0) {
+ delete self.timeoutPeriod;
+ cb && cb(Errors.timeoutFinish, null);
+ return;
+ }
+ }
}
});
};
[4/6] incubator-milagro-mfa-js-lib git commit: Preparation for
support multi authentication protocols
Posted by ni...@apache.org.
Preparation for support multi authentication protocols
Project: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/commit/5590da89
Tree: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/tree/5590da89
Diff: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/diff/5590da89
Branch: refs/heads/master
Commit: 5590da89ca9137658713793315281b3347877f09
Parents: f105200
Author: boyan.bakov <bo...@miracl.com>
Authored: Wed Jul 6 11:06:58 2016 +0300
Committer: boyan.bakov <bo...@miracl.com>
Committed: Thu Jul 7 11:43:11 2016 +0300
----------------------------------------------------------------------
lib/mpin.js | 109 ++++++++++++++++++++++++++++++++++++++++---------------
1 file changed, 80 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/blob/5590da89/lib/mpin.js
----------------------------------------------------------------------
diff --git a/lib/mpin.js b/lib/mpin.js
index 1ee8159..12901c3 100644
--- a/lib/mpin.js
+++ b/lib/mpin.js
@@ -51,6 +51,16 @@ var mpinjs = (function () {
Mpin.prototype.storageKey = "mpinjs";
+ //supportedProtocols
+ // temporary until extend with other portocols
+ // then supported should be object of objects
+ Mpin.prototype.cfg = {
+ protocols: {
+ supported: ["2pass"],
+ default: "2pass"
+ }
+ };
+
Mpin.prototype.init = function (cb) {
var self = this, _initUrl;
@@ -71,6 +81,7 @@ var mpinjs = (function () {
self.ready = true;
self.settings = data;
+ self.chooseAuthProtocol();
cb && cb(null, true);
});
};
@@ -333,6 +344,36 @@ var mpinjs = (function () {
});
};
+ Mpin.prototype.chooseAuthProtocol = function () {
+ var self = this;
+ this.authProtocol = this.cfg.protocols.default;
+
+ // We have 3 arrays:
+ // 1. Ordered list of protocols sent from the server - this.settings.supportedProtocols
+ // 2. List of protocols supported by the library - self.cfg.protocols.supported
+ // 3. List of protocols that the library user would like to support - this.opts.authProtocols
+ // The goal is to select the first protocol from the server's list (1) that is supported by the library (2) and selected by the lib user (3).
+ // If the lib user didn't provide any preferences, then we select the first one from the server's list that is supported by the lib.
+ if (this.settings.supportedProtocols && this.settings.supportedProtocols instanceof Array) {
+ if (this.opts.authProtocols && this.opts.authProtocols instanceof Array) {
+
+ this.settings.supportedProtocols.some(function (value) {
+ if (self.opts.authProtocols.indexOf(value) !== -1 && self.cfg.protocols.supported.indexOf(value) !== -1) {
+ self.authProtocol = value;
+ return true;
+ }
+ });
+ } else {
+ this.settings.supportedProtocols.some(function (value) {
+ if (self.cfg.protocols.supported.indexOf(value) !== -1) {
+ self.authProtocol = value;
+ return true;
+ }
+ });
+ }
+ }
+ };
+
Mpin.prototype.finishAuthentication = function (userId, pin, cb) {
var _userState;
@@ -345,7 +386,11 @@ var mpinjs = (function () {
return cb({code: Errors.wrongFlow.code, type: Errors.wrongFlow.type, message: "Need to call startAuthentication method before this."}, null);
}
- this._passRequests({userId: userId, pin: pin}, cb);
+ // The following checks that the authentication protocol is 2pass.
+ // This is temporary until the lib supports other protocols
+ if (this.authProtocol === this.cfg.protocols.default) {
+ this._pass2Requests({userId: userId, pin: pin}, cb);
+ }
};
Mpin.prototype.finishAuthenticationOtp = function (userId, pin, cb) {
@@ -359,21 +404,24 @@ var mpinjs = (function () {
return cb({code: Errors.wrongFlow.code, type: Errors.wrongFlow.type, message: "Need to call startAuthentication method before this."}, null);
}
- this._passRequests({userId: userId, pin: pin, otp: true}, function (err, data) {
- if (err) {
- return cb(err, null);
- }
-
- if (!data.expireTime || !data.ttlSeconds || !data.nowTime) {
- return cb(null, null);
- }
+ // The following checks that the authentication protocol is 2pass.
+ // This is temporary until the lib supports other protocols
+ if (this.authProtocol === this.cfg.protocols.default) {
+ this._pass2Requests({userId: userId, pin: pin, otp: true}, function (err, data) {
+ if (err) {
+ return cb(err, null);
+ }
- data.expireTime = data.expireTime / 1000;
- data.nowTime = data.nowTime / 1000;
+ if (!data.expireTime || !data.ttlSeconds || !data.nowTime) {
+ return cb(null, null);
+ }
- cb(null, data);
- });
+ data.expireTime = data.expireTime / 1000;
+ data.nowTime = data.nowTime / 1000;
+ cb(null, data);
+ });
+ }
};
Mpin.prototype.finishAuthenticationAN = function (userId, pin, accessNumber, cb) {
@@ -387,24 +435,27 @@ var mpinjs = (function () {
return cb({code: Errors.wrongFlow.code, type: Errors.wrongFlow.type, message: "Need to call startAuthentication method before this."}, null);
}
- this._passRequests({userId: userId, pin: pin, accessNumber: accessNumber.toString()}, function (err, data) {
- if (err) {
- return cb(err, null);
- }
+ // The following checks that the authentication protocol is 2pass.
+ // This is temporary until the lib supports other protocols
+ if (this.authProtocol === this.cfg.protocols.default) {
+ this._pass2Requests({userId: userId, pin: pin, accessNumber: accessNumber.toString()}, function (err, data) {
+ if (err) {
+ return cb(err, null);
+ }
- if (!data.expireTime || !data.ttlSeconds || !data.nowTime) {
- return cb(null, null);
- }
+ if (!data.expireTime || !data.ttlSeconds || !data.nowTime) {
+ return cb(null, null);
+ }
- data.expireTime = data.expireTime / 1000;
- data.nowTime = data.nowTime / 1000;
-
- cb(null, data);
- });
+ data.expireTime = data.expireTime / 1000;
+ data.nowTime = data.nowTime / 1000;
+ cb(null, data);
+ });
+ }
};
- Mpin.prototype._passRequests = function (opts, cb) {
+ Mpin.prototype._pass2Requests = function (opts, cb) {
var userId, pin, otp, accessNumber, self = this, _reqData = {};
userId = opts.userId;
pin = isNaN(opts.pin) ? this.toHash(opts.pin) : opts.pin;
@@ -643,7 +694,7 @@ var mpinjs = (function () {
authOTT = data.authOTT
delete data.authOTT
- if(data.status === 'authenticate') {
+ if (data.status === 'authenticate') {
cbStatus && cbStatus(data);
self._authenticate({mpinResponse: {authOTT: authOTT}}, cb);
} else {
@@ -651,8 +702,8 @@ var mpinjs = (function () {
_requestPeriod = requestSeconds ? requestSeconds * 1000 : 3000;
self.timeoutPeriod -= _requestPeriod;
if (data.status !== self.mobileStatus) {
- self.mobileStatus = data.status;
- cbStatus && cbStatus(data);
+ self.mobileStatus = data.status;
+ cbStatus && cbStatus(data);
}
self.intervalID2 = setTimeout(function () {
self.waitForMobileAuth.call(self, timeoutSeconds, requestSeconds, cb, cbStatus);