mirror of
https://github.com/nextcloud/passman.git
synced 2025-10-09 04:56:58 +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
|
||||
if(!window['PassmanImporter']){
|
||||
var PassmanImporter = {}
|
||||
}
|
||||
var PassmanImporter = PassmanImporter || {};
|
||||
(function(window, $, 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) {
|
||||
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
|
||||
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;
|
||||
};
|
||||
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);
|
||||
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];
|
||||
}
|
||||
} else {
|
||||
for (var i = 1, row; row = rows[i]; i++) {
|
||||
lines.push(this.parseRow_(row));
|
||||
}
|
||||
}
|
||||
return lines;
|
||||
};
|
||||
return result;
|
||||
};
|
||||
|
||||
PassmanImporter.readJson = function (string){
|
||||
return JSON.parse(string);
|
||||
};
|
||||
PassmanImporter.join_ = function(arr, sep) {
|
||||
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
|
||||
if (!window['PassmanImporter']) {
|
||||
var PassmanImporter = {}
|
||||
}
|
||||
// Define the importer
|
||||
PassmanImporter.clippers = {
|
||||
info: {
|
||||
name: 'Clipperz.is',
|
||||
id: 'clippers',
|
||||
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);
|
||||
}
|
||||
var PassmanImporter = PassmanImporter || {};
|
||||
(function(window, $, PassmanImporter) {
|
||||
'use strict';
|
||||
PassmanImporter.clippers = {
|
||||
info: {
|
||||
name: 'Clipperz.is',
|
||||
id: 'clippers',
|
||||
description: 'Go to menu -> Export -> Download HTML + JSON. Fields will be imported as custom fields.'
|
||||
}
|
||||
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
|
||||
if (!window['PassmanImporter']) {
|
||||
var PassmanImporter = {}
|
||||
}
|
||||
// Define the importer
|
||||
PassmanImporter.dashLaneCsv = {
|
||||
info: {
|
||||
name: 'Dashlane 4 csv',
|
||||
id: 'dashLaneCsv',
|
||||
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);
|
||||
var PassmanImporter = PassmanImporter || {};
|
||||
(function(window, $, PassmanImporter) {
|
||||
'use strict';
|
||||
// Define the importer
|
||||
PassmanImporter.dashLaneCsv = {
|
||||
info: {
|
||||
name: 'Dashlane 4 csv',
|
||||
id: 'dashLaneCsv',
|
||||
description: 'Create an csv export. Go to File -> export -> Unsecured archive (readable) in CSV format'
|
||||
}
|
||||
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
|
||||
if (!window['PassmanImporter']) {
|
||||
var PassmanImporter = {}
|
||||
}
|
||||
// Define the importer
|
||||
PassmanImporter.keepassCsv = {
|
||||
info: {
|
||||
name: 'KeePass csv',
|
||||
id: 'keepassCsv',
|
||||
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);
|
||||
var PassmanImporter = PassmanImporter || {};
|
||||
(function(window, $, PassmanImporter) {
|
||||
'use strict';
|
||||
// Define the importer
|
||||
PassmanImporter.keepassCsv = {
|
||||
info: {
|
||||
name: 'KeePass csv',
|
||||
id: 'keepassCsv',
|
||||
description: 'Create an csv export with the following options enabled: http://i.imgur.com/CaeTA4d.png'
|
||||
}
|
||||
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
|
||||
if (!window['PassmanImporter']) {
|
||||
var PassmanImporter = {}
|
||||
}
|
||||
// Define the importer
|
||||
PassmanImporter.lastpassCsv = {
|
||||
info: {
|
||||
name: 'LastPass csv',
|
||||
id: 'lastpassCsv',
|
||||
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);
|
||||
var PassmanImporter = PassmanImporter || {};
|
||||
(function(window, $, PassmanImporter) {
|
||||
'use strict';
|
||||
// Define the importer
|
||||
PassmanImporter.lastpassCsv = {
|
||||
info: {
|
||||
name: 'LastPass csv',
|
||||
id: 'lastpassCsv',
|
||||
description: 'Create an csv export. Go to More options -> Advanced -> Export -> Last Pass CSV File'
|
||||
}
|
||||
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
|
||||
if (!window['PassmanImporter']) {
|
||||
var PassmanImporter = {}
|
||||
}
|
||||
// Define the importer
|
||||
PassmanImporter.passmanJson = {
|
||||
info: {
|
||||
name: 'Passman JSON',
|
||||
id: 'passmanJson',
|
||||
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);
|
||||
var PassmanImporter = PassmanImporter || {};
|
||||
(function(window, $, PassmanImporter) {
|
||||
'use strict';
|
||||
PassmanImporter.passmanJson = {
|
||||
info: {
|
||||
name: 'Passman JSON',
|
||||
id: 'passmanJson',
|
||||
description: 'Export the item in passman as passman json, with all fields enabled'
|
||||
}
|
||||
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
|
||||
if (!window['PassmanImporter']) {
|
||||
var PassmanImporter = {}
|
||||
}
|
||||
// Define the importer
|
||||
PassmanImporter.passpackCsv = {
|
||||
info: {
|
||||
name: 'Passpack csv',
|
||||
id: 'passpackCsv',
|
||||
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);
|
||||
var PassmanImporter = PassmanImporter || {};
|
||||
(function(window, $, PassmanImporter) {
|
||||
'use strict';
|
||||
// Define the importer
|
||||
PassmanImporter.passpackCsv = {
|
||||
info: {
|
||||
name: 'Passpack csv',
|
||||
id: 'passpackCsv',
|
||||
description: 'Go to Tools -> Export. Select Comma Separated Values, All entries then continue.'
|
||||
}
|
||||
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
|
||||
if (!window['PassmanImporter']) {
|
||||
var PassmanImporter = {}
|
||||
}
|
||||
var PassmanImporter = PassmanImporter || {};
|
||||
(function(window, $, PassmanImporter) {
|
||||
'use strict';
|
||||
// Define the importer
|
||||
|
||||
// Define the importer
|
||||
PassmanImporter.randomData = {
|
||||
info: {
|
||||
name: 'Random data',
|
||||
id: 'randomData',
|
||||
description: 'Create\'s 50 random credentials for testing purposes.'
|
||||
}
|
||||
};
|
||||
PassmanImporter.randomData = {
|
||||
info: {
|
||||
name: 'Random data',
|
||||
id: 'randomData',
|
||||
description: 'Create\'s 50 random credentials for testing purposes.'
|
||||
}
|
||||
};
|
||||
|
||||
PassmanImporter.randomData.readFile = function () {
|
||||
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 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) {
|
||||
if(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;
|
||||
PassmanImporter.randomData.readFile = function () {
|
||||
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 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) {
|
||||
if(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);
|
||||
var ta = 0;
|
||||
var _tags = [];
|
||||
while (ta < tag_amount) {
|
||||
var item = tags[Math.floor(Math.random() * tags.length)];
|
||||
if (_tags.indexOf(item) === -1) {
|
||||
_tags.push(item);
|
||||
ta++
|
||||
var tag_amount = Math.floor(Math.random() * 5);
|
||||
var ta = 0;
|
||||
var _tags = [];
|
||||
while (ta < tag_amount) {
|
||||
var item = tags[Math.floor(Math.random() * tags.length)];
|
||||
if (_tags.indexOf(item) === -1) {
|
||||
_tags.push(item);
|
||||
ta++
|
||||
}
|
||||
}
|
||||
}
|
||||
_credential.tags = _tags.map(function (item) {
|
||||
if (item) {
|
||||
return {text: item}
|
||||
_credential.tags = _tags.map(function (item) {
|
||||
if (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 {
|
||||
callback(credential_list)
|
||||
generateCredential(max, i , callback)
|
||||
}
|
||||
} else {
|
||||
generateCredential(max, i , callback)
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
generateCredential(50, 1, function (credential_list) {
|
||||
_this.call_then(credential_list);
|
||||
generateCredential(50, 1, function (credential_list) {
|
||||
_this.call_then(credential_list);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
})(window, $, PassmanImporter);
|
|
@ -1,40 +1,43 @@
|
|||
// Importers should always start with this
|
||||
if (!window['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"'
|
||||
}
|
||||
};
|
||||
var PassmanImporter = PassmanImporter || {};
|
||||
|
||||
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);
|
||||
}
|
||||
(function(window, $, PassmanImporter) {
|
||||
'use strict';
|
||||
|
||||
var progress = {
|
||||
percent: i/parsed_csv.length*100,
|
||||
loaded: i,
|
||||
total: parsed_csv.length
|
||||
};
|
||||
|
||||
this.call_progress(progress);
|
||||
// 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"'
|
||||
}
|
||||
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