passman/js/app/services/shareservice.js
Marcos Zuriaga 19bcdd91c0 Sharing RSA key generation and settings page
Included Forge lib
2016-09-25 17:46:55 +02:00

34 lines
852 B
JavaScript

'use strict';
/**
* @ngdoc service
* @name passmanApp.ShareService
* @description
* # ShareService
* Service in the passmanApp.
*/
angular.module('passmanApp')
.service('ShareService', ['$http', function ($http) {
var _tags = [];
return {
search: function (string) {
var queryUrl = OC.generateUrl('apps/passman/api/v2/sharing/search');
return $http.post(queryUrl, {search: string}).then(function (response) {
if (response.data) {
return response.data;
} else {
return response;
}
});
},
generateRSAKeys: function(key_length){
return forge.pki.rsa.generateKeyPair(key_length);
},
rsaKeyPairToPEM: function(keypair){
return {
'publicKey' : forge.pki.publicKeyToPem(keypair.publicKey),
'privateKey' : forge.pki.privateKeyToPem(keypair.privateKey)
};
}
}
}]);