mirror of
https://github.com/nextcloud/passman.git
synced 2025-10-14 15:36:16 +08:00
Use global namespace for importers
This commit is contained in:
parent
8b31278429
commit
d5a123abf4
9 changed files with 527 additions and 516 deletions
|
@ -1,98 +1,99 @@
|
||||||
// Importers should always start with this
|
var PassmanImporter = PassmanImporter || {};
|
||||||
if(!window['PassmanImporter']){
|
(function(window, $, PassmanImporter) {
|
||||||
var PassmanImporter = {}
|
'use strict';
|
||||||
}
|
|
||||||
|
|
||||||
PassmanImporter.parseRow_ = function(row) {
|
|
||||||
// Strip leading quote.
|
|
||||||
row = row.trim();
|
|
||||||
var isQuoted = false;
|
|
||||||
if (row.charAt(0) == '"') {
|
|
||||||
row = row.substring(1);
|
|
||||||
isQuoted = true;
|
|
||||||
}
|
|
||||||
if (row.charAt(row.length - 2) == '"') {
|
|
||||||
row = row.substring(0, row.length - 2);
|
|
||||||
isQuoted = true;
|
|
||||||
}
|
|
||||||
// Strip trailing quote. There seems to be a character between the last quote
|
|
||||||
// and the line ending, hence 2 instead of 1.
|
|
||||||
if(isQuoted == true) {
|
|
||||||
row = row.split('","');
|
|
||||||
} else {
|
|
||||||
row = row.split(',');
|
|
||||||
}
|
|
||||||
return row;
|
|
||||||
};
|
|
||||||
PassmanImporter.htmlDecode = function(input){
|
|
||||||
var e = document.createElement('div');
|
|
||||||
e.innerHTML = input;
|
|
||||||
return e.childNodes[0].nodeValue;
|
|
||||||
};
|
|
||||||
PassmanImporter.toObject_ = function(headings, row) {
|
|
||||||
var result = {};
|
|
||||||
for (var i = 0, ii = row.length; i < ii; i++) {
|
|
||||||
headings[i] = headings[i].replace(',','_')
|
|
||||||
.toLowerCase().replace(' ','_')
|
|
||||||
.replace('(','').replace(')','')
|
|
||||||
.replace('"','');
|
|
||||||
result[headings[i]] = row[i];
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
PassmanImporter.join_ = function(arr, sep) {
|
PassmanImporter.parseRow_ = function(row) {
|
||||||
var parts = [];
|
// Strip leading quote.
|
||||||
for (var i = 0, ii = arr.length; i < ii; i++) {
|
row = row.trim();
|
||||||
arr[i] && parts.push(arr[i]);
|
var isQuoted = false;
|
||||||
}
|
if (row.charAt(0) == '"') {
|
||||||
return parts.join(sep);
|
row = row.substring(1);
|
||||||
};
|
isQuoted = true;
|
||||||
|
}
|
||||||
PassmanImporter.newCredential = function () {
|
if (row.charAt(row.length - 2) == '"') {
|
||||||
var credential = {
|
row = row.substring(0, row.length - 2);
|
||||||
'credential_id': null,
|
isQuoted = true;
|
||||||
'guid': null,
|
}
|
||||||
'vault_id': null,
|
// Strip trailing quote. There seems to be a character between the last quote
|
||||||
'label': null,
|
// and the line ending, hence 2 instead of 1.
|
||||||
'description': null,
|
if(isQuoted == true) {
|
||||||
'created': null,
|
row = row.split('","');
|
||||||
'changed': null,
|
} else {
|
||||||
'tags': [],
|
row = row.split(',');
|
||||||
'email': null,
|
}
|
||||||
'username': null,
|
return row;
|
||||||
'password': null,
|
|
||||||
'url': null,
|
|
||||||
'favicon': null,
|
|
||||||
'renew_interval': null,
|
|
||||||
'expire_time': 0,
|
|
||||||
'delete_time': 0,
|
|
||||||
'files': [],
|
|
||||||
'custom_fields': [],
|
|
||||||
'otp': {},
|
|
||||||
'hidden': false
|
|
||||||
};
|
};
|
||||||
return credential;
|
PassmanImporter.htmlDecode = function(input){
|
||||||
};
|
var e = document.createElement('div');
|
||||||
|
e.innerHTML = input;
|
||||||
PassmanImporter.readCsv = function( csv, hasHeadings ){
|
return e.childNodes[0].nodeValue;
|
||||||
hasHeadings = (hasHeadings === undefined) ? true : hasHeadings;
|
};
|
||||||
var lines = [];
|
PassmanImporter.toObject_ = function(headings, row) {
|
||||||
var rows = csv.split('\n');
|
var result = {};
|
||||||
if(hasHeadings) {
|
for (var i = 0, ii = row.length; i < ii; i++) {
|
||||||
var headings = this.parseRow_(rows[0]);
|
headings[i] = headings[i].replace(',','_')
|
||||||
for (var i = 1, row; row = rows[i]; i++) {
|
.toLowerCase().replace(' ','_')
|
||||||
row = this.toObject_(headings, this.parseRow_(row));
|
.replace('(','').replace(')','')
|
||||||
lines.push(row);
|
.replace('"','');
|
||||||
|
result[headings[i]] = row[i];
|
||||||
}
|
}
|
||||||
} else {
|
return result;
|
||||||
for (var i = 1, row; row = rows[i]; i++) {
|
};
|
||||||
lines.push(this.parseRow_(row));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return lines;
|
|
||||||
};
|
|
||||||
|
|
||||||
PassmanImporter.readJson = function (string){
|
PassmanImporter.join_ = function(arr, sep) {
|
||||||
return JSON.parse(string);
|
var parts = [];
|
||||||
};
|
for (var i = 0, ii = arr.length; i < ii; i++) {
|
||||||
|
arr[i] && parts.push(arr[i]);
|
||||||
|
}
|
||||||
|
return parts.join(sep);
|
||||||
|
};
|
||||||
|
|
||||||
|
PassmanImporter.newCredential = function () {
|
||||||
|
var credential = {
|
||||||
|
'credential_id': null,
|
||||||
|
'guid': null,
|
||||||
|
'vault_id': null,
|
||||||
|
'label': null,
|
||||||
|
'description': null,
|
||||||
|
'created': null,
|
||||||
|
'changed': null,
|
||||||
|
'tags': [],
|
||||||
|
'email': null,
|
||||||
|
'username': null,
|
||||||
|
'password': null,
|
||||||
|
'url': null,
|
||||||
|
'favicon': null,
|
||||||
|
'renew_interval': null,
|
||||||
|
'expire_time': 0,
|
||||||
|
'delete_time': 0,
|
||||||
|
'files': [],
|
||||||
|
'custom_fields': [],
|
||||||
|
'otp': {},
|
||||||
|
'hidden': false
|
||||||
|
};
|
||||||
|
return credential;
|
||||||
|
};
|
||||||
|
|
||||||
|
PassmanImporter.readCsv = function( csv, hasHeadings ){
|
||||||
|
hasHeadings = (hasHeadings === undefined) ? true : hasHeadings;
|
||||||
|
var lines = [];
|
||||||
|
var rows = csv.split('\n');
|
||||||
|
if(hasHeadings) {
|
||||||
|
var headings = this.parseRow_(rows[0]);
|
||||||
|
for (var i = 1, row; row = rows[i]; i++) {
|
||||||
|
row = this.toObject_(headings, this.parseRow_(row));
|
||||||
|
lines.push(row);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (var i = 1, row; row = rows[i]; i++) {
|
||||||
|
lines.push(this.parseRow_(row));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lines;
|
||||||
|
};
|
||||||
|
|
||||||
|
PassmanImporter.readJson = function (string){
|
||||||
|
return JSON.parse(string);
|
||||||
|
};
|
||||||
|
})(window, $, PassmanImporter);
|
||||||
|
|
|
@ -1,58 +1,58 @@
|
||||||
// Importers should always start with this
|
// Importers should always start with this
|
||||||
if (!window['PassmanImporter']) {
|
var PassmanImporter = PassmanImporter || {};
|
||||||
var PassmanImporter = {}
|
(function(window, $, PassmanImporter) {
|
||||||
}
|
'use strict';
|
||||||
// Define the importer
|
PassmanImporter.clippers = {
|
||||||
PassmanImporter.clippers = {
|
info: {
|
||||||
info: {
|
name: 'Clipperz.is',
|
||||||
name: 'Clipperz.is',
|
id: 'clippers',
|
||||||
id: 'clippers',
|
description: 'Go to menu -> Export -> Download HTML + JSON. Fields will be imported as custom fields.'
|
||||||
description: 'Go to menu -> Export -> Download HTML + JSON. Fields will be imported as custom fields.'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
PassmanImporter.clippers.readFile = function (file_data) {
|
|
||||||
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 progress = {
|
|
||||||
percent: i/json_objects.length*100,
|
|
||||||
loaded: i,
|
|
||||||
total: json_objects.length
|
|
||||||
};
|
|
||||||
this.call_progress(progress);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.call_then(credential_list);
|
};
|
||||||
});
|
|
||||||
};
|
PassmanImporter.clippers.readFile = function (file_data) {
|
||||||
|
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 progress = {
|
||||||
|
percent: i/json_objects.length*100,
|
||||||
|
loaded: i,
|
||||||
|
total: json_objects.length
|
||||||
|
};
|
||||||
|
this.call_progress(progress);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.call_then(credential_list);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
})(window, $, PassmanImporter);
|
||||||
|
|
|
@ -1,48 +1,49 @@
|
||||||
// Importers should always start with this
|
// Importers should always start with this
|
||||||
if (!window['PassmanImporter']) {
|
var PassmanImporter = PassmanImporter || {};
|
||||||
var PassmanImporter = {}
|
(function(window, $, PassmanImporter) {
|
||||||
}
|
'use strict';
|
||||||
// Define the importer
|
// Define the importer
|
||||||
PassmanImporter.dashLaneCsv = {
|
PassmanImporter.dashLaneCsv = {
|
||||||
info: {
|
info: {
|
||||||
name: 'Dashlane 4 csv',
|
name: 'Dashlane 4 csv',
|
||||||
id: 'dashLaneCsv',
|
id: 'dashLaneCsv',
|
||||||
description: 'Create an csv export. Go to File -> export -> Unsecured archive (readable) in CSV format'
|
description: 'Create an csv export. Go to File -> export -> Unsecured archive (readable) in CSV format'
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
PassmanImporter.dashLaneCsv.readFile = function (file_data) {
|
|
||||||
return new C_Promise(function(){
|
|
||||||
var rows = file_data.split('\n');
|
|
||||||
var credential_list = [];
|
|
||||||
for (var i = 0; i < rows.length; i++) {
|
|
||||||
var 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
this.call_then(credential_list);
|
};
|
||||||
});
|
|
||||||
};
|
PassmanImporter.dashLaneCsv.readFile = function (file_data) {
|
||||||
|
return new C_Promise(function(){
|
||||||
|
var rows = file_data.split('\n');
|
||||||
|
var credential_list = [];
|
||||||
|
for (var i = 0; i < rows.length; i++) {
|
||||||
|
var 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
this.call_then(credential_list);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
})(window, $, PassmanImporter);
|
||||||
|
|
|
@ -1,50 +1,51 @@
|
||||||
// Importers should always start with this
|
// Importers should always start with this
|
||||||
if (!window['PassmanImporter']) {
|
var PassmanImporter = PassmanImporter || {};
|
||||||
var PassmanImporter = {}
|
(function(window, $, PassmanImporter) {
|
||||||
}
|
'use strict';
|
||||||
// Define the importer
|
// Define the importer
|
||||||
PassmanImporter.keepassCsv = {
|
PassmanImporter.keepassCsv = {
|
||||||
info: {
|
info: {
|
||||||
name: 'KeePass csv',
|
name: 'KeePass csv',
|
||||||
id: 'keepassCsv',
|
id: 'keepassCsv',
|
||||||
description: 'Create an csv export with the following options enabled: http://i.imgur.com/CaeTA4d.png'
|
description: 'Create an csv export with the following options enabled: http://i.imgur.com/CaeTA4d.png'
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
PassmanImporter.keepassCsv.readFile = function (file_data) {
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
this.call_then(credential_list);
|
};
|
||||||
});
|
|
||||||
return p;
|
PassmanImporter.keepassCsv.readFile = function (file_data) {
|
||||||
};
|
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);
|
||||||
|
}
|
||||||
|
this.call_then(credential_list);
|
||||||
|
});
|
||||||
|
return p;
|
||||||
|
};
|
||||||
|
})(window, $, PassmanImporter);
|
||||||
|
|
|
@ -1,39 +1,40 @@
|
||||||
// Importers should always start with this
|
// Importers should always start with this
|
||||||
if (!window['PassmanImporter']) {
|
var PassmanImporter = PassmanImporter || {};
|
||||||
var PassmanImporter = {}
|
(function(window, $, PassmanImporter) {
|
||||||
}
|
'use strict';
|
||||||
// Define the importer
|
// Define the importer
|
||||||
PassmanImporter.lastpassCsv = {
|
PassmanImporter.lastpassCsv = {
|
||||||
info: {
|
info: {
|
||||||
name: 'LastPass csv',
|
name: 'LastPass csv',
|
||||||
id: 'lastpassCsv',
|
id: 'lastpassCsv',
|
||||||
description: 'Create an csv export. Go to More options -> Advanced -> Export -> Last Pass CSV File'
|
description: 'Create an csv export. Go to More options -> Advanced -> Export -> Last Pass CSV File'
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
PassmanImporter.lastpassCsv.readFile = function (file_data) {
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
this.call_then(credential_list)
|
};
|
||||||
});
|
|
||||||
};
|
PassmanImporter.lastpassCsv.readFile = function (file_data) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
this.call_then(credential_list)
|
||||||
|
});
|
||||||
|
};
|
||||||
|
})(window, $, PassmanImporter);
|
|
@ -1,70 +1,70 @@
|
||||||
// Importers should always start with this
|
// Importers should always start with this
|
||||||
if (!window['PassmanImporter']) {
|
var PassmanImporter = PassmanImporter || {};
|
||||||
var PassmanImporter = {}
|
(function(window, $, PassmanImporter) {
|
||||||
}
|
'use strict';
|
||||||
// Define the importer
|
PassmanImporter.passmanJson = {
|
||||||
PassmanImporter.passmanJson = {
|
info: {
|
||||||
info: {
|
name: 'Passman JSON',
|
||||||
name: 'Passman JSON',
|
id: 'passmanJson',
|
||||||
id: 'passmanJson',
|
description: 'Export the item in passman as passman json, with all fields enabled'
|
||||||
description: 'Export the item in passman as passman json, with all fields enabled'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
PassmanImporter.passmanJson.readFile = function (file_data) {
|
|
||||||
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;
|
|
||||||
_credential.description = item.description;
|
|
||||||
//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(_credential.label){
|
|
||||||
credential_list.push(_credential);
|
|
||||||
}
|
|
||||||
var progress = {
|
|
||||||
percent: i/parsed_json.length*100,
|
|
||||||
loaded: i,
|
|
||||||
total: parsed_json.length
|
|
||||||
};
|
|
||||||
|
|
||||||
this.call_progress(progress);
|
|
||||||
}
|
}
|
||||||
this.call_then(credential_list);
|
};
|
||||||
});
|
|
||||||
};
|
PassmanImporter.passmanJson.readFile = function (file_data) {
|
||||||
|
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;
|
||||||
|
_credential.description = item.description;
|
||||||
|
//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(_credential.label){
|
||||||
|
credential_list.push(_credential);
|
||||||
|
}
|
||||||
|
var progress = {
|
||||||
|
percent: i/parsed_json.length*100,
|
||||||
|
loaded: i,
|
||||||
|
total: parsed_json.length
|
||||||
|
};
|
||||||
|
|
||||||
|
this.call_progress(progress);
|
||||||
|
}
|
||||||
|
this.call_then(credential_list);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
})(window, $, PassmanImporter);
|
||||||
|
|
|
@ -1,52 +1,53 @@
|
||||||
// Importers should always start with this
|
// Importers should always start with this
|
||||||
if (!window['PassmanImporter']) {
|
var PassmanImporter = PassmanImporter || {};
|
||||||
var PassmanImporter = {}
|
(function(window, $, PassmanImporter) {
|
||||||
}
|
'use strict';
|
||||||
// Define the importer
|
// Define the importer
|
||||||
PassmanImporter.passpackCsv = {
|
PassmanImporter.passpackCsv = {
|
||||||
info: {
|
info: {
|
||||||
name: 'Passpack csv',
|
name: 'Passpack csv',
|
||||||
id: 'passpackCsv',
|
id: 'passpackCsv',
|
||||||
description: 'Go to Tools -> Export. Select Comma Separated Values, All entries then continue.'
|
description: 'Go to Tools -> Export. Select Comma Separated Values, All entries then continue.'
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
PassmanImporter.passpackCsv.readFile = function (file_data) {
|
|
||||||
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);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
_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);
|
|
||||||
}
|
}
|
||||||
this.call_then(credential_list);
|
};
|
||||||
})
|
|
||||||
};
|
PassmanImporter.passpackCsv.readFile = function (file_data) {
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
_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);
|
||||||
|
}
|
||||||
|
this.call_then(credential_list);
|
||||||
|
})
|
||||||
|
};
|
||||||
|
})(window, $, PassmanImporter);
|
|
@ -1,94 +1,97 @@
|
||||||
// Importers should always start with this
|
// Importers should always start with this
|
||||||
if (!window['PassmanImporter']) {
|
var PassmanImporter = PassmanImporter || {};
|
||||||
var PassmanImporter = {}
|
(function(window, $, PassmanImporter) {
|
||||||
}
|
'use strict';
|
||||||
|
// Define the importer
|
||||||
|
|
||||||
// Define the importer
|
// Define the importer
|
||||||
PassmanImporter.randomData = {
|
PassmanImporter.randomData = {
|
||||||
info: {
|
info: {
|
||||||
name: 'Random data',
|
name: 'Random data',
|
||||||
id: 'randomData',
|
id: 'randomData',
|
||||||
description: 'Create\'s 50 random credentials for testing purposes.'
|
description: 'Create\'s 50 random credentials for testing purposes.'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
PassmanImporter.randomData.readFile = function () {
|
PassmanImporter.randomData.readFile = function () {
|
||||||
return new C_Promise(function () {
|
return new C_Promise(function () {
|
||||||
var tags =
|
var tags =
|
||||||
['Social media',
|
['Social media',
|
||||||
'Hosting',
|
'Hosting',
|
||||||
'Forums',
|
'Forums',
|
||||||
'Webshops',
|
'Webshops',
|
||||||
'FTP',
|
'FTP',
|
||||||
'SSH',
|
'SSH',
|
||||||
'Banking',
|
'Banking',
|
||||||
'Applications',
|
'Applications',
|
||||||
'Server stuff',
|
'Server stuff',
|
||||||
'mysql',
|
'mysql',
|
||||||
'Wifi',
|
'Wifi',
|
||||||
'Games',
|
'Games',
|
||||||
'Certificate',
|
'Certificate',
|
||||||
'Serials'
|
'Serials'
|
||||||
];
|
];
|
||||||
var label;
|
var label;
|
||||||
var credential_list = [];
|
var credential_list = [];
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var generateCredential = function (max, i, callback) {
|
var generateCredential = function (max, i, callback) {
|
||||||
if (jQuery) {
|
if (jQuery) {
|
||||||
var url = OC.generateUrl('apps/passman/api/internal/generate_person');
|
var url = OC.generateUrl('apps/passman/api/internal/generate_person');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: url,
|
url: url,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
if(data) {
|
if(data) {
|
||||||
var _credential = PassmanImporter.newCredential();
|
var _credential = PassmanImporter.newCredential();
|
||||||
label = (Math.random() >= 0.5) ? data.domain : data.email_d + ' - ' + data.email_u;
|
label = (Math.random() >= 0.5) ? data.domain : data.email_d + ' - ' + data.email_u;
|
||||||
_credential.label = label;
|
_credential.label = label;
|
||||||
_credential.username = data.username;
|
_credential.username = data.username;
|
||||||
_credential.password = data.password;
|
_credential.password = data.password;
|
||||||
_credential.url = data.url;
|
_credential.url = data.url;
|
||||||
|
|
||||||
var tag_amount = Math.floor(Math.random() * 5);
|
var tag_amount = Math.floor(Math.random() * 5);
|
||||||
var ta = 0;
|
var ta = 0;
|
||||||
var _tags = [];
|
var _tags = [];
|
||||||
while (ta < tag_amount) {
|
while (ta < tag_amount) {
|
||||||
var item = tags[Math.floor(Math.random() * tags.length)];
|
var item = tags[Math.floor(Math.random() * tags.length)];
|
||||||
if (_tags.indexOf(item) === -1) {
|
if (_tags.indexOf(item) === -1) {
|
||||||
_tags.push(item);
|
_tags.push(item);
|
||||||
ta++
|
ta++
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
_credential.tags = _tags.map(function (item) {
|
||||||
_credential.tags = _tags.map(function (item) {
|
if (item) {
|
||||||
if (item) {
|
return {text: item}
|
||||||
return {text: item}
|
}
|
||||||
|
|
||||||
|
}).filter(function (item) {
|
||||||
|
return (item);
|
||||||
|
});
|
||||||
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
}).filter(function (item) {
|
|
||||||
return (item);
|
|
||||||
});
|
|
||||||
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 {
|
} else {
|
||||||
callback(credential_list)
|
generateCredential(max, i , callback)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
generateCredential(max, i , callback)
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
};
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
generateCredential(50, 1, function (credential_list) {
|
generateCredential(50, 1, function (credential_list) {
|
||||||
_this.call_then(credential_list);
|
_this.call_then(credential_list);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
};
|
||||||
};
|
})(window, $, PassmanImporter);
|
|
@ -1,40 +1,43 @@
|
||||||
// Importers should always start with this
|
// Importers should always start with this
|
||||||
if (!window['PassmanImporter']) {
|
var PassmanImporter = PassmanImporter || {};
|
||||||
var PassmanImporter = {}
|
|
||||||
}
|
|
||||||
// Define the importer
|
|
||||||
PassmanImporter.zohoCsv = {
|
|
||||||
info: {
|
|
||||||
name: 'ZOHO csv',
|
|
||||||
id: 'zohoCsv',
|
|
||||||
description: 'Create an csv export. Go to Tools -> Export secrets -> Select "General CSV" and click "Export Secrets"'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
PassmanImporter.zohoCsv.readFile = function (file_data) {
|
(function(window, $, PassmanImporter) {
|
||||||
return new C_Promise(function(){
|
'use strict';
|
||||||
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 = {
|
// Define the importer
|
||||||
percent: i/parsed_csv.length*100,
|
PassmanImporter.zohoCsv = {
|
||||||
loaded: i,
|
info: {
|
||||||
total: parsed_csv.length
|
name: 'ZOHO csv',
|
||||||
};
|
id: 'zohoCsv',
|
||||||
|
description: 'Create an csv export. Go to Tools -> Export secrets -> Select "General CSV" and click "Export Secrets"'
|
||||||
this.call_progress(progress);
|
|
||||||
}
|
}
|
||||||
this.call_then(credential_list);
|
};
|
||||||
})
|
|
||||||
};
|
PassmanImporter.zohoCsv.readFile = function (file_data) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
this.call_then(credential_list);
|
||||||
|
})
|
||||||
|
};
|
||||||
|
})(window, $, PassmanImporter);
|
||||||
|
|
Loading…
Add table
Reference in a new issue