mirror of https://github.com/BTCPrivate/copay.git
fingerprint for Android 6.0+
This commit is contained in:
parent
43194559d2
commit
da0f9cb4a7
|
@ -158,6 +158,9 @@ if [ ! -d $PROJECT ]; then
|
||||||
cordova plugin add cordova-plugin-disable-bitcode
|
cordova plugin add cordova-plugin-disable-bitcode
|
||||||
checkOK
|
checkOK
|
||||||
|
|
||||||
|
cordova plugin add cordova-plugin-android-fingerprint-auth
|
||||||
|
checkOK
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if $DBGJS
|
if $DBGJS
|
||||||
|
|
|
@ -31,15 +31,6 @@ angular.element(document).ready(function() {
|
||||||
window.plugins.webintent.onNewIntent(handleBitcoinURI);
|
window.plugins.webintent.onNewIntent(handleBitcoinURI);
|
||||||
window.handleOpenURL = handleBitcoinURI;
|
window.handleOpenURL = handleBitcoinURI;
|
||||||
|
|
||||||
window.plugins.touchid.isAvailable(
|
|
||||||
function(msg) {
|
|
||||||
window.touchidAvailable = true;
|
|
||||||
}, // success handler: TouchID available
|
|
||||||
function(msg) {
|
|
||||||
window.touchidAvailable = false;
|
|
||||||
} // error handler: no TouchID available
|
|
||||||
);
|
|
||||||
|
|
||||||
startAngular();
|
startAngular();
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,53 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.services').factory('fingerprintService', function($log, gettextCatalog, configService) {
|
angular.module('copayApp.services').factory('fingerprintService', function($log, gettextCatalog, configService, platformInfo) {
|
||||||
var root = {};
|
var root = {};
|
||||||
|
|
||||||
|
var _isAvailable = false;
|
||||||
|
|
||||||
|
if (platformInfo.isMobile) {
|
||||||
|
window.plugins.touchid = window.plugins.touchid || {};
|
||||||
|
window.plugins.touchid.isAvailable(
|
||||||
|
function(msg) {
|
||||||
|
_isAvailable = 'IOS';
|
||||||
|
},
|
||||||
|
function(msg) {
|
||||||
|
FingerprintAuth.isAvailable(function() {
|
||||||
|
_isAvailable = 'ANDROID';
|
||||||
|
}, function() {
|
||||||
|
_isAvailable = false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var requestFinger = function(cb) {
|
||||||
|
console.log('[fingerprintService.js.26:requestFinger:]'); //TODO
|
||||||
|
try {
|
||||||
|
FingerprintAuth.show({
|
||||||
|
clientId: 'Copay',
|
||||||
|
clientSecret: 'hVu1NvCZOyUuGgr46bFL',
|
||||||
|
},
|
||||||
|
function(result) {
|
||||||
|
if (result.withFingerprint) {
|
||||||
|
$log.debug('Finger OK');
|
||||||
|
return cb();
|
||||||
|
} else if (result.withPassword) {
|
||||||
|
$log.debug("Finger: Authenticated with backup password");
|
||||||
|
return cb();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
function(msg) {
|
||||||
|
$log.debug('Finger Failed:' + JSON.stringify(msg));
|
||||||
|
return cb(gettextCatalog.getString('Finger Scan Failed') + ': ' + msg.localizedDescription);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
$log.warn('Finger Scan Failed:' + JSON.stringify(e));
|
||||||
|
return cb(gettextCatalog.getString('Finger Scan Failed'));
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
var requestTouchId = function(cb) {
|
var requestTouchId = function(cb) {
|
||||||
try {
|
try {
|
||||||
window.plugins.touchid.verifyFingerprint(
|
window.plugins.touchid.verifyFingerprint(
|
||||||
|
@ -22,15 +67,26 @@ angular.module('copayApp.services').factory('fingerprintService', function($log,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
root.isAvailable = function(client) {
|
var isNeeded = function(client) {
|
||||||
|
if (!_isAvailable) return false;
|
||||||
|
|
||||||
var config = configService.getSync();
|
var config = configService.getSync();
|
||||||
config.touchIdFor = config.touchIdFor || {};
|
config.touchIdFor = config.touchIdFor || {};
|
||||||
return (window.touchidAvailable && config.touchIdFor[client.credentials.walletId]);
|
|
||||||
|
return config.touchIdFor[client.credentials.walletId];
|
||||||
|
};
|
||||||
|
|
||||||
|
root.isAvailable = function(client) {
|
||||||
|
return _isAvailable;
|
||||||
};
|
};
|
||||||
|
|
||||||
root.check = function(client, cb) {
|
root.check = function(client, cb) {
|
||||||
if (root.isAvailable(client)) {
|
if (isNeeded(client)) {
|
||||||
requestTouchId(cb);
|
console.log('[fingerprintService.js.82:_isAvailable:]', _isAvailable); //TODO
|
||||||
|
if (_isAvailable == 'IOS')
|
||||||
|
return requestTouchId(cb);
|
||||||
|
else
|
||||||
|
return requestFinger(cb);
|
||||||
} else {
|
} else {
|
||||||
return cb();
|
return cb();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue