Rudimentarily working with getting and setting the profile in the Keychain on iOS.

This commit is contained in:
Brendon Duncan 2018-05-30 16:28:32 +12:00
commit cc2f5f6a14
2 changed files with 49 additions and 3 deletions

View file

@ -72,6 +72,7 @@
<plugin name="cordova-plugin-queries-schemes" spec="~0.1.5" />
<plugin name="cordova-plugin-firebase" spec="https://github.com/arnesson/cordova-plugin-firebase.git" />
<plugin name="cordova-plugin-wkwebview-inputfocusfix" spec="https://github.com/onderceylan/cordova-plugin-wkwebview-inputfocusfix.git" />
<plugin name="cordova-plugin-secure-storage" spec="../SecureStorage" />
<!-- Supported Platforms -->
<engine name="ios" spec="~4.5.3" />
<engine name="android" spec="~6.3.0" />

View file

@ -116,19 +116,60 @@ angular.module('copayApp.services')
};
root.storeNewProfile = function(profile, cb) {
storage.create('profile', profile.toObj(), cb);
console.log('storeNewProfile() 6');
SecureStorage.set('profile', profile.toObj(), function success(){ cb(); }, function error(err){ cb(err); });
//storage.create('profile', profile.toObj(), cb);
};
root.storeProfile = function(profile, cb) {
storage.set('profile', profile.toObj(), cb);
console.log('storeProfile() 6');
SecureStorage.set('profile', profile.toObj(), function success(){ cb(); }, function error(err){ cb(err); });
//storage.set('profile', profile.toObj(), cb);
};
root.getProfile = function(cb) {
storage.get('profile', function(err, str) {
if (err || !str)
return cb(err);
console.log("getProfile() 6");
SecureStorage.get(
'profile',
function success(str) {
$log.debug('get profile returned success.');
decryptOnMobile(str, function(err, str) {
if (err) return cb(err);
var p, err;
try {
p = Profile.fromString(str);
} catch (e) {
$log.debug('Could not read profile:', e);
err = new Error('Could not read profile:' + p);
}
return cb(err, p);
});
},
function error(err) {
$log.debug('get profile returned error.');
$log.debug('returning error.');
// Callback requires no error and no profile for creation of new profiles
return cb();
}
);
/*
storage.get('profile', function(err, str) {
$log.debug('get profile returned.');
if (err || !str) {
$log.debug('get profile returned error: ' + err + ' with string: ' + str);
return cb(err);
}
$log.debug('calling decrypt');
decryptOnMobile(str, function(err, str) {
$log.debug('decrypt returned.');
if (err) return cb(err);
var p, err;
try {
@ -140,8 +181,12 @@ angular.module('copayApp.services')
return cb(err, p);
});
});
*/
};
// Is this ever used?
root.deleteProfile = function(cb) {
storage.remove('profile', cb);
};