mirror of
https://github.com/nextcloud/passman.git
synced 2025-01-01 04:51:44 +08:00
commit
994c9839fa
19 changed files with 577 additions and 272 deletions
15
css/app.css
15
css/app.css
|
@ -282,13 +282,6 @@
|
|||
#app-content #app-content-wrapper .edit_credential .custom_fields table tr td, #app-content #app-content-wrapper .edit_credential .files table tr td {
|
||||
height: 50px;
|
||||
vertical-align: middle; }
|
||||
#app-content #app-content-wrapper .edit_credential .file_tab .progress {
|
||||
margin-top: 10px;
|
||||
height: 10px; }
|
||||
#app-content #app-content-wrapper .edit_credential .file_tab .progress .progress-bar {
|
||||
height: 10px;
|
||||
background-image: none;
|
||||
background-color: #0082c9; }
|
||||
#app-content #app-content-wrapper .app_sidebar {
|
||||
padding: 10px;
|
||||
overflow-y: auto; }
|
||||
|
@ -331,6 +324,14 @@
|
|||
cursor: pointer;
|
||||
margin-right: 4px; }
|
||||
|
||||
.progress {
|
||||
margin-top: 10px;
|
||||
height: 10px; }
|
||||
.progress .progress-bar {
|
||||
height: 10px;
|
||||
background-image: none;
|
||||
background-color: #0082c9; }
|
||||
|
||||
.settings-container div {
|
||||
padding-left: 15px; }
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -51,8 +51,12 @@ angular.module('passmanApp')
|
|||
};
|
||||
|
||||
var parsed_data;
|
||||
$scope.current_import_index = 0;
|
||||
$scope.current_import_length = 0;
|
||||
|
||||
$scope.import_progress = {
|
||||
progress: 0,
|
||||
loaded: 0,
|
||||
total: 0
|
||||
};
|
||||
var addCredential = function(parsed_data_index){
|
||||
if(!parsed_data[parsed_data_index]){
|
||||
return;
|
||||
|
@ -66,34 +70,59 @@ angular.module('passmanApp')
|
|||
return
|
||||
}
|
||||
_log('Adding '+ _credential.label);
|
||||
$scope.current_import_index = parsed_data_index;
|
||||
_credential.vault_id = $scope.active_vault.vault_id;
|
||||
CredentialService.createCredential(_credential).then(function (result) {
|
||||
if(result.credential_id){
|
||||
_log('Added '+ _credential.label);
|
||||
if(parsed_data[ parsed_data_index +1]) {
|
||||
$scope.import_progress = {
|
||||
progress: parsed_data_index / parsed_data.length * 100,
|
||||
loaded: parsed_data_index,
|
||||
total: parsed_data.length
|
||||
};
|
||||
|
||||
addCredential(parsed_data_index +1)
|
||||
} else {
|
||||
$scope.import_progress = {
|
||||
progress: 100,
|
||||
loaded: parsed_data.length-1,
|
||||
total: parsed_data.length-1
|
||||
};
|
||||
_log('DONE!');
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
|
||||
$scope.file_read_progress = {
|
||||
percent: 0,
|
||||
loaded: 0,
|
||||
total: 0
|
||||
};
|
||||
$scope.startImport = function(){
|
||||
$scope.import_progress = 0;
|
||||
$scope.file_read_percent = 0;
|
||||
if(file_data){
|
||||
$window.PassmanImporter[$scope.selectedImporter.id].readFile(file_data, function(parseddata){
|
||||
$window.PassmanImporter[$scope.selectedImporter.id]
|
||||
.readFile(file_data)
|
||||
.then(function(parseddata){
|
||||
parsed_data = parseddata;
|
||||
$scope.file_read_progress = {
|
||||
percent: 100,
|
||||
loaded: parsed_data.length,
|
||||
total: parsed_data.length
|
||||
};
|
||||
_log('Parsed '+ parsed_data.length + ' credentials, starting to import');
|
||||
$scope.current_import_length = parsed_data.length;
|
||||
if( parsed_data.length > 0){
|
||||
addCredential(0);
|
||||
} else {
|
||||
// @TODO Show message no data found
|
||||
}
|
||||
}).progress(function(progress){
|
||||
$scope.file_read_progress = progress;
|
||||
$scope.$apply();
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,32 +5,29 @@ angular.module('passmanApp')
|
|||
.controller('SharingSettingsCtrl', ['$scope', 'VaultService', 'CredentialService', 'SettingsService', '$location', '$routeParams', 'ShareService', 'EncryptService',
|
||||
function ($scope, VaultService, CredentialService, SettingsService, $location, $routeParams, ShareService, EncryptService) {
|
||||
$scope.active_vault = VaultService.getActiveVault();
|
||||
$scope.sharing_keys = ShareService.getSharingKeys();
|
||||
|
||||
$scope.progress = 1;
|
||||
$scope.generating = false;
|
||||
|
||||
$scope.sharing_keys = ShareService.getSharingKeys();
|
||||
|
||||
$scope.generateKeys = function (length) {
|
||||
$scope.progress = 1;
|
||||
$scope.generating = true;
|
||||
|
||||
ShareService.generateRSAKeys(length, function(progress){
|
||||
ShareService.generateRSAKeys(length).progress(function(progress){
|
||||
$scope.progress = progress > 0 ? 2:1;
|
||||
$scope.$apply();
|
||||
console.log($scope.progress);
|
||||
}, function(kp){
|
||||
}).then(function(kp){
|
||||
console.log('stuff done');
|
||||
$scope.generating = false;
|
||||
|
||||
var pem = ShareService.rsaKeyPairToPEM(kp)
|
||||
|
||||
$scope.active_vault.private_sharing_key = pem.privateKey;
|
||||
$scope.active_vault.private_sharing_key = EncryptService.encryptString(pem.privateKey);
|
||||
$scope.active_vault.public_sharing_key = pem.publicKey;
|
||||
|
||||
|
||||
var _vault = angular.copy($scope.active_vault);
|
||||
_vault.private_sharing_key = EncryptService.encryptString(_vault.private_sharing_key);
|
||||
VaultService.updateSharingKeys(_vault).then(function (result) {
|
||||
console.log('done')
|
||||
VaultService.updateSharingKeys($scope.active_vault).then(function (result) {
|
||||
$scope.sharing_keys = ShareService.getSharingKeys();
|
||||
})
|
||||
});
|
||||
}
|
||||
|
|
|
@ -9,6 +9,11 @@
|
|||
*/
|
||||
angular.module('passmanApp')
|
||||
.service('ShareService', ['$http', 'VaultService', 'EncryptService', function ($http, VaultService, EncryptService) {
|
||||
// Setup sjcl random engine to max paranoia level and start collecting data
|
||||
var paranoia_level = 10
|
||||
sjcl.random.setDefaultParanoia(paranoia_level);
|
||||
sjcl.random.startCollectors();
|
||||
|
||||
return {
|
||||
search: function (string) {
|
||||
var queryUrl = OC.generateUrl('apps/passman/api/v2/sharing/search');
|
||||
|
@ -21,24 +26,43 @@ angular.module('passmanApp')
|
|||
});
|
||||
},
|
||||
generateRSAKeys: function(key_length, progress, callback){
|
||||
var state = forge.pki.rsa.createKeyPairGenerationState(key_length, 0x10001);
|
||||
var step = function() {
|
||||
// run for 100 ms
|
||||
if(!forge.pki.rsa.stepKeyPairGenerationState(state, 100)) {
|
||||
// console.log(state);
|
||||
if (state.p !== null) {
|
||||
progress(50);
|
||||
var p = new C_Promise(function(){
|
||||
var state = forge.pki.rsa.createKeyPairGenerationState(key_length, 0x10001);
|
||||
var step = function() {
|
||||
// run for 100 ms
|
||||
if(!forge.pki.rsa.stepKeyPairGenerationState(state, 100)) {
|
||||
// console.log(state);
|
||||
if (state.p !== null) {
|
||||
// progress(50);
|
||||
this.call_progress(50);
|
||||
}
|
||||
else {
|
||||
// progress(0);
|
||||
this.call_progress(0);
|
||||
}
|
||||
setTimeout(step.bind(this), 1);
|
||||
}
|
||||
else {
|
||||
progress(0);
|
||||
// callback(state.keys);
|
||||
this.call_then(state.keys);
|
||||
}
|
||||
setTimeout(step, 1);
|
||||
}
|
||||
else {
|
||||
callback(state.keys);
|
||||
}
|
||||
};
|
||||
setTimeout(step, 100);
|
||||
};
|
||||
setTimeout(step.bind(this), 100);
|
||||
});
|
||||
return p;
|
||||
},
|
||||
generateSharedKey: function(size){
|
||||
size = size || 20;
|
||||
return new C_Promise(function(){
|
||||
CRYPTO.PASSWORD.generate(size,
|
||||
function(pass) {
|
||||
this.call_then(pass);
|
||||
},
|
||||
function(progress) {
|
||||
this.call_progress(progress);
|
||||
}
|
||||
);
|
||||
})
|
||||
},
|
||||
rsaKeyPairToPEM: function(keypair){
|
||||
return {
|
||||
|
|
|
@ -12,39 +12,47 @@ PassmanImporter.clippers = {
|
|||
};
|
||||
|
||||
PassmanImporter.clippers.readFile = function (file_data, callback) {
|
||||
var credential_list = [];
|
||||
var re = /<textarea>(.*?)<\/textarea>/gi;
|
||||
var matches = re.exec(file_data);
|
||||
if(matches){
|
||||
var raw_json = matches[0].substring(10);
|
||||
raw_json = PassmanImporter.htmlDecode(raw_json.slice(0, -11));
|
||||
var json_objects = PassmanImporter.readJson(raw_json);
|
||||
for(var i = 0; i < json_objects.length; i++){
|
||||
var card = json_objects[i];
|
||||
re = /(\w+)/gi;
|
||||
var tags = card.label.match(re);
|
||||
card.label = card.label.replace(tags.join(' '), '').trim();
|
||||
tags = tags.map(function(item){ return {text: item.replace('', '') }});
|
||||
return new C_Promise(function() {
|
||||
var credential_list = [];
|
||||
var re = /<textarea>(.*?)<\/textarea>/gi;
|
||||
var matches = re.exec(file_data);
|
||||
if(matches){
|
||||
var raw_json = matches[0].substring(10);
|
||||
raw_json = PassmanImporter.htmlDecode(raw_json.slice(0, -11));
|
||||
var json_objects = PassmanImporter.readJson(raw_json);
|
||||
for(var i = 0; i < json_objects.length; i++){
|
||||
var card = json_objects[i];
|
||||
re = /(\w+)/gi;
|
||||
var tags = card.label.match(re);
|
||||
card.label = card.label.replace(tags.join(' '), '').trim();
|
||||
tags = tags.map(function(item){ return {text: item.replace('', '') }});
|
||||
|
||||
|
||||
var _credential = PassmanImporter.newCredential();
|
||||
_credential.label = card.label;
|
||||
_credential.description = card.data.notes;
|
||||
_credential.tags = tags;
|
||||
for(var field in card.currentVersion.fields){
|
||||
var field_data = card.currentVersion.fields[field];
|
||||
_credential.custom_fields.push(
|
||||
{
|
||||
'label': field_data.label,
|
||||
'value': field_data.value,
|
||||
'secret': (field_data.hidden == true)
|
||||
}
|
||||
)
|
||||
}
|
||||
if(_credential.label){
|
||||
credential_list.push(_credential);
|
||||
var _credential = PassmanImporter.newCredential();
|
||||
_credential.label = card.label;
|
||||
_credential.description = card.data.notes;
|
||||
_credential.tags = tags;
|
||||
for(var field in card.currentVersion.fields){
|
||||
var field_data = card.currentVersion.fields[field];
|
||||
_credential.custom_fields.push(
|
||||
{
|
||||
'label': field_data.label,
|
||||
'value': field_data.value,
|
||||
'secret': (field_data.hidden == true)
|
||||
}
|
||||
)
|
||||
}
|
||||
if(_credential.label){
|
||||
credential_list.push(_credential);
|
||||
}
|
||||
var progress = {
|
||||
percent: i/json_objects.length*100,
|
||||
loaded: i,
|
||||
total: json_objects.length
|
||||
};
|
||||
this.call_progress(progress);
|
||||
}
|
||||
}
|
||||
}
|
||||
callback(credential_list);
|
||||
this.call_then(credential_list);
|
||||
});
|
||||
};
|
|
@ -12,28 +12,37 @@ PassmanImporter.dashLaneCsv = {
|
|||
};
|
||||
|
||||
PassmanImporter.dashLaneCsv.readFile = function (file_data, callback) {
|
||||
var rows = file_data.split('\n');
|
||||
var credential_list = [];
|
||||
for (var i = 1, row; row = rows[i]; i++) {
|
||||
row = rows[i];
|
||||
var row_data = row.split('","');
|
||||
if (row_data[0].charAt(0) == '"') {
|
||||
row_data[0] = row_data[0].substring(1);
|
||||
}
|
||||
return new C_Promise(function(){
|
||||
var rows = file_data.split('\n');
|
||||
var credential_list = [];
|
||||
for (var i = 1, row; row = rows[i]; i++) {
|
||||
row = rows[i];
|
||||
var row_data = row.split('","');
|
||||
if (row_data[0].charAt(0) == '"') {
|
||||
row_data[0] = row_data[0].substring(1);
|
||||
}
|
||||
|
||||
if (row_data[row_data.length-1].toString().charAt(row_data[row_data.length - 1].length - 1) == '"') {
|
||||
row_data[row_data.length - 1] = row_data[row_data.length -1].substring(0, row_data[row_data.length - 1].length - 1);
|
||||
}
|
||||
if (row_data[row_data.length-1].toString().charAt(row_data[row_data.length - 1].length - 1) == '"') {
|
||||
row_data[row_data.length - 1] = row_data[row_data.length -1].substring(0, row_data[row_data.length - 1].length - 1);
|
||||
}
|
||||
|
||||
var _credential = PassmanImporter.newCredential();
|
||||
_credential.label = row_data[0];
|
||||
_credential.username = row_data[2];
|
||||
_credential.password = row_data[row_data.length - 2];
|
||||
_credential.url = row_data[0];
|
||||
_credential.description = row_data[row_data.length - 1];
|
||||
if(_credential.label){
|
||||
credential_list.push(_credential);
|
||||
var _credential = PassmanImporter.newCredential();
|
||||
_credential.label = row_data[0];
|
||||
_credential.username = row_data[2];
|
||||
_credential.password = row_data[row_data.length - 2];
|
||||
_credential.url = row_data[0];
|
||||
_credential.description = row_data[row_data.length - 1];
|
||||
if(_credential.label){
|
||||
credential_list.push(_credential);
|
||||
}
|
||||
|
||||
var progress = {
|
||||
percent: i/rows.length*100,
|
||||
loaded: i,
|
||||
total: rows.length
|
||||
};
|
||||
this.call_progress(progress);
|
||||
}
|
||||
}
|
||||
callback(credential_list);
|
||||
this.call_then(credential_list);
|
||||
});
|
||||
};
|
|
@ -12,28 +12,39 @@ PassmanImporter.keepassCsv = {
|
|||
};
|
||||
|
||||
PassmanImporter.keepassCsv.readFile = function (file_data, callback) {
|
||||
var parsed_csv = PassmanImporter.readCsv(file_data);
|
||||
var credential_list = [];
|
||||
for (var i = 0; i < parsed_csv.length; i++) {
|
||||
var row = parsed_csv[i];
|
||||
var _credential = PassmanImporter.newCredential();
|
||||
_credential.label = row.account;
|
||||
_credential.username = row.login_name;
|
||||
_credential.password = row.password;
|
||||
_credential.url = row.web_site;
|
||||
if (row.hasOwnProperty('expires')) {
|
||||
row.expires = row.expires.replace('"','');
|
||||
_credential.expire_time = new Date(row.expires).getTime() / 1000;
|
||||
}
|
||||
var tags = [{text: row.group}];
|
||||
if (row.hasOwnProperty('group_tree')) {
|
||||
var exploded_tree = row.group_tree.split('\\\\');
|
||||
for (var t = 0; t < exploded_tree.length; t++) {
|
||||
tags.push({text: exploded_tree[t]});
|
||||
var p = new C_Promise(function(){
|
||||
var parsed_csv = PassmanImporter.readCsv(file_data);
|
||||
var credential_list = [];
|
||||
for (var i = 0; i < parsed_csv.length; i++) {
|
||||
var row = parsed_csv[i];
|
||||
var _credential = PassmanImporter.newCredential();
|
||||
_credential.label = row.account;
|
||||
_credential.username = row.login_name;
|
||||
_credential.password = row.password;
|
||||
_credential.url = row.web_site;
|
||||
if (row.hasOwnProperty('expires')) {
|
||||
row.expires = row.expires.replace('"','');
|
||||
_credential.expire_time = new Date(row.expires).getTime() / 1000;
|
||||
}
|
||||
var tags = [{text: row.group}];
|
||||
if (row.hasOwnProperty('group_tree')) {
|
||||
var exploded_tree = row.group_tree.split('\\\\');
|
||||
for (var t = 0; t < exploded_tree.length; t++) {
|
||||
tags.push({text: exploded_tree[t]});
|
||||
}
|
||||
}
|
||||
_credential.tags = tags;
|
||||
credential_list.push(_credential);
|
||||
|
||||
var progress = {
|
||||
percent: i/parsed_csv.length*100,
|
||||
loaded: i,
|
||||
total: parsed_csv.length
|
||||
};
|
||||
|
||||
this.call_progress(progress);
|
||||
}
|
||||
_credential.tags = tags;
|
||||
credential_list.push(_credential);
|
||||
}
|
||||
callback(credential_list);
|
||||
this.call_then(credential_list);
|
||||
});
|
||||
return p;
|
||||
};
|
|
@ -12,20 +12,28 @@ PassmanImporter.lastpassCsv = {
|
|||
};
|
||||
|
||||
PassmanImporter.lastpassCsv.readFile = function (file_data, callback) {
|
||||
var parsed_csv = PassmanImporter.readCsv(file_data);
|
||||
var credential_list = [];
|
||||
for (var i = 0; i < parsed_csv.length; i++) {
|
||||
var row = parsed_csv[i];
|
||||
var _credential = PassmanImporter.newCredential();
|
||||
_credential.label = PassmanImporter.htmlDecode(row.name);
|
||||
_credential.username = row.username;
|
||||
_credential.password = row.password;
|
||||
_credential.url = row.url;
|
||||
_credential.tags = [{text: row.grouping}];
|
||||
_credential.description = row.extra;
|
||||
if(_credential.label){
|
||||
credential_list.push(_credential);
|
||||
return new C_Promise(function(){
|
||||
var parsed_csv = PassmanImporter.readCsv(file_data);
|
||||
var credential_list = [];
|
||||
for (var i = 0; i < parsed_csv.length; i++) {
|
||||
var row = parsed_csv[i];
|
||||
var _credential = PassmanImporter.newCredential();
|
||||
_credential.label = PassmanImporter.htmlDecode(row.name);
|
||||
_credential.username = row.username;
|
||||
_credential.password = row.password;
|
||||
_credential.url = row.url;
|
||||
_credential.tags = [{text: row.grouping}];
|
||||
_credential.description = row.extra;
|
||||
if(_credential.label){
|
||||
credential_list.push(_credential);
|
||||
}
|
||||
var progress = {
|
||||
percent: i/parsed_csv.length*100,
|
||||
loaded: i,
|
||||
total: parsed_csv.length
|
||||
};
|
||||
this.call_progress(progress);
|
||||
}
|
||||
}
|
||||
callback(credential_list);
|
||||
this.call_then(credential_list)
|
||||
});
|
||||
};
|
|
@ -12,49 +12,58 @@ PassmanImporter.passmanJson = {
|
|||
};
|
||||
|
||||
PassmanImporter.passmanJson.readFile = function (file_data, callback) {
|
||||
var parsed_json = PassmanImporter.readJson(file_data);
|
||||
var credential_list = [];
|
||||
for (var i = 0; i < parsed_json.length; i++) {
|
||||
var item = parsed_json[i];
|
||||
var _credential = PassmanImporter.newCredential();
|
||||
_credential.label = item.label;
|
||||
_credential.username = item.account;
|
||||
_credential.password = item.password;
|
||||
_credential.email = item.email;
|
||||
_credential.url = item.url;
|
||||
_credential.tags = item.tags;
|
||||
//Check for custom fields
|
||||
if (item.hasOwnProperty('customFields')) {
|
||||
//Check for otp
|
||||
if (item.customFields.length > 0) {
|
||||
for (var cf = 0; cf < item.customFields.length; cf++) {
|
||||
_credential.custom_fields.push(
|
||||
{
|
||||
'label': item.customFields[cf].label,
|
||||
'value': item.customFields[cf].value,
|
||||
'secret': (item.customFields[cf].clicktoshow == '1')
|
||||
}
|
||||
)
|
||||
return new C_Promise(function(){
|
||||
var parsed_json = PassmanImporter.readJson(file_data);
|
||||
var credential_list = [];
|
||||
for (var i = 0; i < parsed_json.length; i++) {
|
||||
var item = parsed_json[i];
|
||||
var _credential = PassmanImporter.newCredential();
|
||||
_credential.label = item.label;
|
||||
_credential.username = item.account;
|
||||
_credential.password = item.password;
|
||||
_credential.email = item.email;
|
||||
_credential.url = item.url;
|
||||
_credential.tags = item.tags;
|
||||
//Check for custom fields
|
||||
if (item.hasOwnProperty('customFields')) {
|
||||
//Check for otp
|
||||
if (item.customFields.length > 0) {
|
||||
for (var cf = 0; cf < item.customFields.length; cf++) {
|
||||
_credential.custom_fields.push(
|
||||
{
|
||||
'label': item.customFields[cf].label,
|
||||
'value': item.customFields[cf].value,
|
||||
'secret': (item.customFields[cf].clicktoshow == '1')
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (item.hasOwnProperty('otpsecret')) {
|
||||
if (item.otpsecret) {
|
||||
_credential.otp = {
|
||||
'issuer': item.otpsecret.issuer,
|
||||
'label': item.otpsecret.label,
|
||||
'qr_uri': {
|
||||
'image': item.otpsecret.qrCode,
|
||||
'qrData': ''
|
||||
},
|
||||
'secret': item.otpsecret.secret,
|
||||
'type': item.otpsecret.type
|
||||
if (item.hasOwnProperty('otpsecret')) {
|
||||
if (item.otpsecret) {
|
||||
_credential.otp = {
|
||||
'issuer': item.otpsecret.issuer,
|
||||
'label': item.otpsecret.label,
|
||||
'qr_uri': {
|
||||
'image': item.otpsecret.qrCode,
|
||||
'qrData': ''
|
||||
},
|
||||
'secret': item.otpsecret.secret,
|
||||
'type': item.otpsecret.type
|
||||
}
|
||||
}
|
||||
}
|
||||
if(_credential.label){
|
||||
credential_list.push(_credential);
|
||||
}
|
||||
var progress = {
|
||||
percent: i/parsed_json.length*100,
|
||||
loaded: i,
|
||||
total: parsed_json.length
|
||||
};
|
||||
|
||||
this.call_progress(progress);
|
||||
}
|
||||
if(_credential.label){
|
||||
credential_list.push(_credential);
|
||||
}
|
||||
}
|
||||
callback(credential_list);
|
||||
this.call_then(credential_list);
|
||||
});
|
||||
};
|
|
@ -12,31 +12,41 @@ PassmanImporter.passpackCsv = {
|
|||
};
|
||||
|
||||
PassmanImporter.passpackCsv.readFile = function (file_data, callback) {
|
||||
var parsed_csv = PassmanImporter.readCsv(file_data, false);
|
||||
var credential_list = [];
|
||||
for (var i = 0; i < parsed_csv.length; i++) {
|
||||
var row = parsed_csv[i];
|
||||
var _credential = PassmanImporter.newCredential();
|
||||
_credential.label = row[0];
|
||||
_credential.username = row[1];
|
||||
_credential.password = row[2];
|
||||
_credential.url = row[3];
|
||||
var tags = row[4].split(' ');
|
||||
if (tags.length > 0) {
|
||||
_credential.tags = tags.map(function (item) {
|
||||
if (item) {
|
||||
return {text: item}
|
||||
}
|
||||
return new C_Promise(function(){
|
||||
var parsed_csv = PassmanImporter.readCsv(file_data, false);
|
||||
var credential_list = [];
|
||||
for (var i = 0; i < parsed_csv.length; i++) {
|
||||
var row = parsed_csv[i];
|
||||
var _credential = PassmanImporter.newCredential();
|
||||
_credential.label = row[0];
|
||||
_credential.username = row[1];
|
||||
_credential.password = row[2];
|
||||
_credential.url = row[3];
|
||||
var tags = row[4].split(' ');
|
||||
if (tags.length > 0) {
|
||||
_credential.tags = tags.map(function (item) {
|
||||
if (item) {
|
||||
return {text: item}
|
||||
}
|
||||
|
||||
}).filter(function (item) {
|
||||
return (item);
|
||||
});
|
||||
}).filter(function (item) {
|
||||
return (item);
|
||||
});
|
||||
}
|
||||
_credential.description = row[5];
|
||||
_credential.email = row[6];
|
||||
if (_credential.label) {
|
||||
credential_list.push(_credential);
|
||||
}
|
||||
|
||||
var progress = {
|
||||
percent: i/parsed_csv.length*100,
|
||||
loaded: i,
|
||||
total: parsed_csv.length
|
||||
};
|
||||
|
||||
this.call_progress(progress);
|
||||
}
|
||||
_credential.description = row[5];
|
||||
_credential.email = row[6];
|
||||
if (_credential.label) {
|
||||
credential_list.push(_credential);
|
||||
}
|
||||
}
|
||||
callback(credential_list);
|
||||
this.call_then(credential_list);
|
||||
})
|
||||
};
|
|
@ -11,60 +11,71 @@ PassmanImporter.randomData = {
|
|||
}
|
||||
};
|
||||
|
||||
PassmanImporter.randomData.readFile = function (file_data,callback) {
|
||||
var credential_list = [];
|
||||
var tags =
|
||||
['Social media',
|
||||
'Hosting',
|
||||
'Forums',
|
||||
'Webshops',
|
||||
'FTP',
|
||||
'SSH',
|
||||
'Banking',
|
||||
'Applications',
|
||||
'Server stuff',
|
||||
'mysql',
|
||||
'Wifi',
|
||||
'Games',
|
||||
'Certificate',
|
||||
'Serials'
|
||||
PassmanImporter.randomData.readFile = function (file_data, callback) {
|
||||
return new C_Promise(function () {
|
||||
var tags =
|
||||
['Social media',
|
||||
'Hosting',
|
||||
'Forums',
|
||||
'Webshops',
|
||||
'FTP',
|
||||
'SSH',
|
||||
'Banking',
|
||||
'Applications',
|
||||
'Server stuff',
|
||||
'mysql',
|
||||
'Wifi',
|
||||
'Games',
|
||||
'Certificate',
|
||||
'Serials'
|
||||
];
|
||||
var label;
|
||||
var generateCredential = function (max, i, cb) {
|
||||
if(jQuery){
|
||||
var url = OC.generateUrl('apps/passman/api/internal/generate_person');
|
||||
$.ajax({
|
||||
url: url,
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
var _credential = PassmanImporter.newCredential();
|
||||
label = (Math.random() >= 0.5) ? data.domain : data.email_d +' - ' + data.email_u;
|
||||
_credential.label = label;
|
||||
_credential.username = data.username;
|
||||
_credential.password = data.password;
|
||||
_credential.url = data.url;
|
||||
var label;
|
||||
var credential_list = [];
|
||||
var _this = this;
|
||||
var generateCredential = function (max, i, callback) {
|
||||
if (jQuery) {
|
||||
var url = OC.generateUrl('apps/passman/api/internal/generate_person');
|
||||
$.ajax({
|
||||
url: url,
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
var _credential = PassmanImporter.newCredential();
|
||||
label = (Math.random() >= 0.5) ? data.domain : data.email_d + ' - ' + data.email_u;
|
||||
_credential.label = label;
|
||||
_credential.username = data.username;
|
||||
_credential.password = data.password;
|
||||
_credential.url = data.url;
|
||||
|
||||
var tag_amount = Math.floor(Math.random()*5);
|
||||
for(var ta = 0; ta < tag_amount; ta++){
|
||||
var item = tags[Math.floor(Math.random()*tags.length)];
|
||||
var tag = {
|
||||
text: item
|
||||
};
|
||||
if(_credential.tags.indexOf(tag) === -1){
|
||||
_credential.tags.push(tag);
|
||||
var tag_amount = Math.floor(Math.random() * 5);
|
||||
for (var ta = 0; ta < tag_amount; ta++) {
|
||||
var item = tags[Math.floor(Math.random() * tags.length)];
|
||||
var tag = {
|
||||
text: item
|
||||
};
|
||||
if (_credential.tags.indexOf(tag) === -1) {
|
||||
_credential.tags.push(tag);
|
||||
}
|
||||
}
|
||||
credential_list.push(_credential);
|
||||
if (i <= max) {
|
||||
var progress = {
|
||||
percent: i / max * 100,
|
||||
loaded: i,
|
||||
total: max
|
||||
};
|
||||
_this.call_progress(progress);
|
||||
generateCredential(max, i + 1, callback)
|
||||
} else {
|
||||
callback(credential_list)
|
||||
}
|
||||
}
|
||||
credential_list.push(_credential);
|
||||
if(i <= max){
|
||||
generateCredential(max, i + 1, callback)
|
||||
} else {
|
||||
cb(credential_list)
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
generateCredential(9, 0,function(credential_list){
|
||||
callback(credential_list);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
generateCredential(10, 1, function (credential_list) {
|
||||
_this.call_then(credential_list);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
@ -12,19 +12,29 @@ PassmanImporter.zohoCsv = {
|
|||
};
|
||||
|
||||
PassmanImporter.zohoCsv.readFile = function (file_data, callback) {
|
||||
var parsed_csv = PassmanImporter.readCsv(file_data, false);
|
||||
var credential_list = [];
|
||||
for (var i = 0; i < parsed_csv.length; i++) {
|
||||
var row = parsed_csv[i];
|
||||
var _credential = PassmanImporter.newCredential();
|
||||
_credential.label = row[0];
|
||||
_credential.username = row[3];
|
||||
_credential.password = row[4];
|
||||
_credential.url = row[1];
|
||||
_credential.description = row[2];
|
||||
if(_credential.label){
|
||||
credential_list.push(_credential);
|
||||
return new C_Promise(function(){
|
||||
var parsed_csv = PassmanImporter.readCsv(file_data, false);
|
||||
var credential_list = [];
|
||||
for (var i = 0; i < parsed_csv.length; i++) {
|
||||
var row = parsed_csv[i];
|
||||
var _credential = PassmanImporter.newCredential();
|
||||
_credential.label = row[0];
|
||||
_credential.username = row[3];
|
||||
_credential.password = row[4];
|
||||
_credential.url = row[1];
|
||||
_credential.description = row[2];
|
||||
if(_credential.label){
|
||||
credential_list.push(_credential);
|
||||
}
|
||||
|
||||
var progress = {
|
||||
percent: i/parsed_csv.length*100,
|
||||
loaded: i,
|
||||
total: parsed_csv.length
|
||||
};
|
||||
|
||||
this.call_progress(progress);
|
||||
}
|
||||
}
|
||||
callback(credential_list);
|
||||
this.call_then(credential_list);
|
||||
})
|
||||
};
|
129
js/lib/crypto_wrap.js
Normal file
129
js/lib/crypto_wrap.js
Normal file
|
@ -0,0 +1,129 @@
|
|||
/**
|
||||
* ownCloud/NextCloud - passman
|
||||
*
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later. See the COPYING file.
|
||||
*
|
||||
* @author Marcos Zuriaga <wolfi@wolfi.es>
|
||||
* @copyright Marcos Zuriarga 2015
|
||||
*/
|
||||
var CRYPTO = { // Global variables of the object:
|
||||
paranoia_level: null,
|
||||
|
||||
PASSWORD : {
|
||||
/**
|
||||
* Callback will be called once the password its generated, it should accept one parameter, and the parameter will be the key (
|
||||
* CRYPTO.PASSWORD.generate(100, function(password){
|
||||
* console.log("The generated password is: " + password);
|
||||
* // Do more stuff here
|
||||
* }, function (current_percentage){
|
||||
* console.log("The current password generation progress it's: " + current_percentage + "%");
|
||||
* // Do real stuff here, update a progressbar, etc.
|
||||
* }
|
||||
* );
|
||||
* )
|
||||
* @param length The minium length of the generated password (it generates in packs of 4 characters,
|
||||
* so it can end up being up to 3 characters longer)
|
||||
* @param callback The function to be called after the password generation its done
|
||||
* @param progress The process of the generation, optional, called each 4 characters generated.
|
||||
*/
|
||||
generate : function (length, callback, progress, start_string) {
|
||||
if (!sjcl.random.isReady(paranoia_level)) {
|
||||
setTimeout(this.generate(length, callback, progress, start_string), 500);
|
||||
return;
|
||||
}
|
||||
|
||||
if (start_string == null) start_string = "";
|
||||
if (start_string.length < length) {
|
||||
start_string += CRYPTO.RANDOM.getRandomASCII();
|
||||
if (progress != null) progress(start_string.length / length * 100);
|
||||
}
|
||||
else {
|
||||
callback(start_string);
|
||||
if (progress != null) progress(100);
|
||||
return;
|
||||
}
|
||||
|
||||
setTimeout(this.generate(length, callback, progress, start_string), 100);
|
||||
},
|
||||
|
||||
logRepeatedCharCount: function (str) {
|
||||
var chars = [];
|
||||
|
||||
for (i = 0; i < str.length; i++) {
|
||||
chars[str.charAt(i)] = (chars[str.charAt(i)] == null) ? 0 : chars[str.charAt(i)] + 1;
|
||||
}
|
||||
return chars;
|
||||
},
|
||||
},
|
||||
|
||||
RANDOM: {
|
||||
/**
|
||||
* Returns a random string of 4 characters length
|
||||
*/
|
||||
getRandomASCII : function () {
|
||||
// console.warn(paranoia_level);
|
||||
|
||||
var ret = "";
|
||||
while (ret.length < 4) {
|
||||
var int = sjcl.random.randomWords(1, paranoia_level);
|
||||
int = int[0];
|
||||
|
||||
var tmp = this._isASCII((int & 0xFF000000) >> 24);
|
||||
if (tmp) ret += tmp;
|
||||
|
||||
tmp = this._isASCII((int & 0x00FF0000) >> 16);
|
||||
if (tmp) ret += tmp;
|
||||
|
||||
tmp = this._isASCII((int & 0x0000FF00) >> 8);
|
||||
if (tmp) ret += tmp;
|
||||
|
||||
tmp = this._isASCII(int & 0x000000FF);
|
||||
if (tmp) ret += tmp;
|
||||
}
|
||||
|
||||
return ret;
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks whether the given data it's an ascii character, returning the corresponding character; returns false otherwise
|
||||
*
|
||||
* @param data
|
||||
* @returns {string}
|
||||
* @private
|
||||
*/
|
||||
_isASCII : function (data) {
|
||||
return (data > 31 && data < 127) ? String.fromCharCode(data) : false;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Initializes the random and other cryptographic engines needed for this library to work
|
||||
* The default paranoia, in case no paranoia level it's provided, it's 10 (1024).
|
||||
* The higher paranoia level allowed by sjcl.
|
||||
*
|
||||
* PARANOIA_LEVELS:
|
||||
* 0 = 0
|
||||
* 1 = 48
|
||||
* 2 = 64
|
||||
* 3 = 96
|
||||
* 4 = 128
|
||||
* 5 = 192
|
||||
* 6 = 256
|
||||
* 7 = 384
|
||||
* 8 = 512
|
||||
* 9 = 768
|
||||
* 10 = 1024
|
||||
*
|
||||
* @param default_paranoia (0-10 integer)
|
||||
*/
|
||||
initEngines : function (default_paranoia) {
|
||||
paranoia_level = default_paranoia || 10;
|
||||
|
||||
sjcl.random.setDefaultParanoia(this.paranoia_level);
|
||||
sjcl.random.startCollectors();
|
||||
|
||||
console.warn('Crypto stuff initialized');
|
||||
}
|
||||
};
|
||||
CRYPTO.initEngines();
|
36
js/lib/promise.js
Normal file
36
js/lib/promise.js
Normal file
|
@ -0,0 +1,36 @@
|
|||
/**
|
||||
* ownCloud/NextCloud - passman
|
||||
*
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later. See the COPYING file.
|
||||
*
|
||||
* @author Marcos Zuriaga <wolfi@wolfi.es>
|
||||
* @copyright Marcos Zuriarga 2016
|
||||
*/
|
||||
|
||||
function C_Promise(workload){
|
||||
this.update = null; this.finally = null; this.error_function = null;
|
||||
this.then = function(callback){
|
||||
this.finally = callback;
|
||||
return this;
|
||||
};
|
||||
this.progress = function(callback){
|
||||
this.update = callback;
|
||||
return this;
|
||||
};
|
||||
this.error = function (callback){
|
||||
this.error_function = callback;
|
||||
return this;
|
||||
};
|
||||
this.call_then = function(data){
|
||||
if (this.finally !== null) this.finally(data);
|
||||
};
|
||||
this.call_progress = function(data){
|
||||
if (this.update !== null) this.update(data);
|
||||
};
|
||||
this.call_error = function(data){
|
||||
if(this.error_function !== null) this.error_function(data);
|
||||
};
|
||||
|
||||
setTimeout(workload.bind(this), 100);
|
||||
}
|
|
@ -57,7 +57,7 @@ angular.module('views/partials/forms/settings/general_settings.html', []).run(['
|
|||
angular.module('views/partials/forms/settings/import.html', []).run(['$templateCache', function($templateCache) {
|
||||
'use strict';
|
||||
$templateCache.put('views/partials/forms/settings/import.html',
|
||||
'<div ng-controller="ImportCtrl"><div class="row"><div class="col-xs-6"><label>Import type<select ng-init="importerType" ng-model="importerType" ng-change="setImporter(importerType)"><option ng-repeat="importer in available_importers" value="{{importer}}">{{importer.name}}</option></select></label><div><b>{{selectedImporter.description}}</b></div><input ng-if="selectedImporter" type="file" file-select success="fileLoaded" error="fileLoadError" progress="fileSelectProgress"><br><button class="button" ng-click="startImport()" ng-if="selectedImporter">Import</button><div ng-if="current_import_length">{{ current_import_index }} / {{ current_import_length - 1}}</div></div><div class="col-xs-6"><div ng-if="log" class="import_log"><textarea id="import_log" auto-scroll="log">{{log.join(\'\\n\')}}</textarea></div></div></div></div>');
|
||||
'<div ng-controller="ImportCtrl"><div class="row"><div class="col-xs-6"><label>Import type<select ng-init="importerType" ng-model="importerType" ng-change="setImporter(importerType)"><option ng-repeat="importer in available_importers" value="{{importer}}">{{importer.name}}</option></select></label><div><b>{{selectedImporter.description}}</b></div><input ng-if="selectedImporter" type="file" file-select success="fileLoaded" error="fileLoadError" progress="fileSelectProgress"><br><button class="button" ng-click="startImport()" ng-if="selectedImporter">Import</button><div ng-if="file_read_progress.percent > 0">Read progress<div progress-bar="file_read_progress.percent"></div><br>{{ file_read_progress.loaded }} / {{ file_read_progress.total }}</div><div ng-if="import_progress.progress > 0">Upload progress<div progress-bar="import_progress.progress"></div><br>{{ import_progress.loaded }} / {{ import_progress.total }}</div></div><div class="col-xs-6"><div ng-if="log" class="import_log"><textarea id="import_log" auto-scroll="log">{{log.join(\'\\n\')}}</textarea></div></div></div></div>');
|
||||
}]);
|
||||
|
||||
angular.module('views/partials/forms/settings/sharing.html', []).run(['$templateCache', function($templateCache) {
|
||||
|
|
|
@ -197,15 +197,7 @@
|
|||
}
|
||||
}
|
||||
.file_tab {
|
||||
.progress {
|
||||
margin-top: 10px;
|
||||
height: 10px;
|
||||
.progress-bar {
|
||||
height: 10px;
|
||||
background-image: none;
|
||||
background-color: #0082c9;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
.app_sidebar {
|
||||
|
@ -269,4 +261,13 @@
|
|||
margin-right: 4px;
|
||||
}
|
||||
}
|
||||
}
|
||||
.progress {
|
||||
margin-top: 10px;
|
||||
height: 10px;
|
||||
.progress-bar {
|
||||
height: 10px;
|
||||
background-image: none;
|
||||
background-color: #0082c9;
|
||||
}
|
||||
}
|
|
@ -22,6 +22,8 @@ script('passman', 'vendor/angular-xeditable/xeditable.min');
|
|||
script('passman', 'vendor/sha/sha');
|
||||
script('passman', 'vendor/llqrcode/llqrcode');
|
||||
script('passman', 'vendor/forge.0.6.9.min');
|
||||
script('passman', 'lib/promise');
|
||||
script('passman', 'lib/crypto_wrap');
|
||||
|
||||
|
||||
script('passman', 'app/app');
|
||||
|
|
|
@ -16,8 +16,18 @@
|
|||
<button class="button" ng-click="startImport()"
|
||||
ng-if="selectedImporter">Import
|
||||
</button>
|
||||
<div ng-if="current_import_length">
|
||||
{{ current_import_index }} / {{ current_import_length - 1}}
|
||||
|
||||
<div ng-if="file_read_progress.percent > 0">
|
||||
Read progress
|
||||
<div progress-bar="file_read_progress.percent"></div>
|
||||
<br />
|
||||
{{ file_read_progress.loaded }} / {{ file_read_progress.total }}
|
||||
</div>
|
||||
<div ng-if="import_progress.progress > 0">
|
||||
Upload progress
|
||||
<div progress-bar="import_progress.progress"></div>
|
||||
<br />
|
||||
{{ import_progress.loaded }} / {{ import_progress.total }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
|
|
Loading…
Reference in a new issue