Wallet/src/js/services/fingerprintService.js
Gustavo Maximiliano Cortez 98471e952a
Bug/select wallet incomplete / Refactor wallet Services (#4159)
* Addressbook: display error if select an incomplete wallet

* Check if wallet is complete/needs_backup for Glidera and Coinbase

* Ref/create a walletService

* Ref. walletService

* Fix Glidera and Coinbase

* Removes txService

* Fix glidera connection for mobile. Fix bitcode for xcode

* Fix duplicated entry

* Revert "Bump bwc version 2.3.1"

* adds karma-mocha

* Refactor

* Refactor lock function

* Refactor reject, remove and broadcast tx

* add walletService tests WIP

* add walletService tests WIP 2

* merge

* update tests to mocha

* fix tests. Angular 1.5?

* Fix test

* Generate angular-bwc before testing

* Rever gitignore

* Wording
2016-05-13 13:00:54 -03:00

40 lines
1.1 KiB
JavaScript

'use strict';
angular.module('copayApp.services').factory('fingerprintService', function(gettextCatalog, configService) {
var root = {};
var requestTouchId = function(cb) {
try {
window.plugins.touchid.verifyFingerprint(
gettextCatalog.getString('Scan your fingerprint please'),
function(msg) {
$log.debug('Touch ID OK');
return cb();
},
function(msg) {
$log.debug('Touch ID Failed:' + JSON.stringify(msg));
return cb(gettextCatalog.getString('Touch ID Failed') + ': ' + msg.localizedDescription);
}
);
} catch (e) {
$log.debug('Touch ID Failed:' + JSON.stringify(e));
return cb(gettextCatalog.getString('Touch ID Failed'));
};
};
root.isAvailable = function(client) {
var config = configService.getSync();
config.touchIdFor = config.touchIdFor || {};
return (window.touchidAvailable && config.touchIdFor[client.credentials.walletId]);
};
root.check = function(client, cb) {
if (root.isAvailable()) {
requestTouchId(cb);
} else {
return cb();
}
};
return root;
});