Rudimentarily working with getting and setting the profile in the Keychain on iOS.
This commit is contained in:
parent
63c76fe13e
commit
cc2f5f6a14
2 changed files with 49 additions and 3 deletions
|
|
@ -72,6 +72,7 @@
|
||||||
<plugin name="cordova-plugin-queries-schemes" spec="~0.1.5" />
|
<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-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-wkwebview-inputfocusfix" spec="https://github.com/onderceylan/cordova-plugin-wkwebview-inputfocusfix.git" />
|
||||||
|
<plugin name="cordova-plugin-secure-storage" spec="../SecureStorage" />
|
||||||
<!-- Supported Platforms -->
|
<!-- Supported Platforms -->
|
||||||
<engine name="ios" spec="~4.5.3" />
|
<engine name="ios" spec="~4.5.3" />
|
||||||
<engine name="android" spec="~6.3.0" />
|
<engine name="android" spec="~6.3.0" />
|
||||||
|
|
|
||||||
|
|
@ -116,19 +116,60 @@ angular.module('copayApp.services')
|
||||||
};
|
};
|
||||||
|
|
||||||
root.storeNewProfile = function(profile, cb) {
|
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) {
|
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) {
|
root.getProfile = function(cb) {
|
||||||
storage.get('profile', function(err, str) {
|
console.log("getProfile() 6");
|
||||||
if (err || !str)
|
|
||||||
return cb(err);
|
|
||||||
|
|
||||||
|
|
||||||
|
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) {
|
decryptOnMobile(str, function(err, str) {
|
||||||
|
$log.debug('decrypt returned.');
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
var p, err;
|
var p, err;
|
||||||
try {
|
try {
|
||||||
|
|
@ -140,8 +181,12 @@ angular.module('copayApp.services')
|
||||||
return cb(err, p);
|
return cb(err, p);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Is this ever used?
|
||||||
root.deleteProfile = function(cb) {
|
root.deleteProfile = function(cb) {
|
||||||
storage.remove('profile', cb);
|
storage.remove('profile', cb);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue