create entries

This commit is contained in:
antelle 2017-05-25 10:20:31 +02:00
parent 8c5cd0f27a
commit e7b4f840ce
2 changed files with 26 additions and 4 deletions

View File

@ -1,5 +1,5 @@
{
"version": "0.0.4",
"version": "0.0.5",
"manifestVersion": "0.1.0",
"name": "keewebhttp",
"description": "KeeWebHttp allows to use browser extensions with KeeWeb",
@ -11,9 +11,9 @@
"licence": "MIT",
"url": "https://plugins.keeweb.info/plugins/keewebhttp",
"resources": {
"js": "zYOLvScOBZRr8tLIYFBE/EMQjxYEcf4rWvLAD6sTtIfieArA2COWRyq3h2XBMtcvb3plOiK5DrUFKtwtthAU8XdFMf6aIEZfXFVfinOZ8MnPF1mp0tzxN6dGi6GLITOW5gk409cOvJVvYQ1Trvg8xvhE9BKHn0ewwOddo6yZByICwj9hkfznHDJo8veBw5m3DD8l7t2c0MVtn1R0gxb78fuOt3kSS7w7qpxV+Q0o3gRUcOW5HwoFAvh5hrUt5KuZ8dzcR8Muxqqh/FqaAaiDkJNmZzW/xC6eT9l/3aayQPk/ST/Q36HJMuB/EbNodiaE5Bj5HxGojFpDNdZr1NmXsw=="
"js": "KQOP+7rjV3DVJNK8KWza27i8I0cdPh4waLJoJWh46AgKSU5PO5HAXv0NTAx2i3j8HCkoxhpIxlfn65GxpHg9fYcjC0qU/8I+xQcQ6HaH18D3X4d5QZcmrCcJlJPk6ZulOIV0ooLQ9P8PCC1MWN671iXx0rK6uJTsauce9lWzn6xTrsBR6dlaOz8Gzis7ZxPOd+mtquKqVTjRuHWhR8EUI4I1xhC6XlGDRwncCYDQ8JDY3kJGoDstSSS2puTBI3anbUg/BRcaj96qO2Dav0yH/E2PS743KbiIbIkBivCgiQEOch5DMcm++avymfQL0PgdoNZvP7xvnZ6OGl/+G5ChiA=="
},
"publicKey": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0oZB2Kt7AzRFNqf8FuO3C3kepHPAIQYiDPYdQxHcsiaFCwyKVx6K1cE/3vBhb8/2rj+QIIWNfAAuu1Y+2VK90ZBeq6HciukWzQRO/HWhfdy0c7JwDAslmyGI5olj0ZQkNLhkde1MiMxjDPpRhZtdJaryVO5cFJaJESpv3dV6m0qXsaQCluWYOSNfSjP9C8o2zRVjSi3ZQZnZIV5pnk9K2MtlZIPXrN9iJiM5zZ9DTSnqApI6dC9mX4R3LvGN+GTovm9C8Crl+qb106nGRR3LcweicDnPyMtZLa/E0DBpWYxUVLDp6WeLhxoUBr+6+t3Xp9IDnPoANDQXJXD0f1vQxQIDAQAB",
"desktop": true,
"versionMin": "1.5.1"
}
}

View File

@ -12,6 +12,7 @@ function run() {
const kdbxweb = require('kdbxweb');
const AppModel = require('models/app-model');
const EntryModel = require('models/entry-model');
const GroupModel = require('models/group-model');
const AutoTypeFilter = require('auto-type/auto-type-filter');
const Logger = require('util/logger');
const Alerts = require('comp/alerts');
@ -24,6 +25,7 @@ function run() {
const EntryTitle = 'KeePassHttp Settings';
const EntryFieldPrefix = 'AES Key: ';
const EntryUuid = 'NGl6QIpbQcCfNol9Yj7LMQ==';
const CreatePasswordsGroupTitle = 'KeePassHttp Passwords';
const keys = {};
const addedKeys = {};
@ -425,7 +427,27 @@ function run() {
logger.info(`setLogin(${url}, ${login}, ${password.length}): ${result}`);
} else {
logger.error(`setLogin(${url}, ${login}, ${password.length}): not implemented`);
// TODO: create entry
let group, file;
AppModel.instance.files.forEach(f => {
f.forEachGroup(g => {
if (g.get('title') === CreatePasswordsGroupTitle) {
group = g;
file = f;
}
});
});
if (!group) {
file = AppModel.instance.files.first();
group = GroupModel.newGroup(file.get('groups').first(), file);
group.setName(CreatePasswordsGroupTitle);
}
const entry = EntryModel.newEntry(group, file);
const domain = url.match(/^(?:\w+:\/\/)?(?:(?:www|wwws|secure)\.)?([^\/]+)\/?(?:.*)/);
const title = domain && domain[1] || 'Saved Password';
entry.setField('Title', title);
entry.setField('URL', url);
entry.setField('UserName', login);
entry.setField('Password', kdbxweb.ProtectedValue.fromString(password));
}
Backbone.trigger('refresh');