keewebhttp: fix config entry search
This commit is contained in:
parent
0f33a73441
commit
85f64dc94d
|
@ -11,7 +11,7 @@
|
||||||
"licence": "MIT",
|
"licence": "MIT",
|
||||||
"url": "https://plugins.keeweb.info/plugins/keewebhttp",
|
"url": "https://plugins.keeweb.info/plugins/keewebhttp",
|
||||||
"resources": {
|
"resources": {
|
||||||
"js": "to0fWxarSAgke4VqZoV3P/dO92ea7RDlmCCyXJEbFOKER+JpJraPsPn0oeWoSzY396T7e2hRxM8HNo7rcnZtkojtCNALmOmz5aSg1cD8CmB3jYJJaG3r5t7WduyrOrha9+tU8XM5faAYeg6lrJb42D6e67/GHZG3GkPSpq3963Wjv36lb9/XQtUkgAOpV5dnuJhNdostFqngWnadvov1NnSNZtr6fbSoq+4worBPUnZTuDqzPTW0QIa2rfoA+Qsg4DLUBnuRLrgTA/8ObzI+qH5aKujIk4sBw6QZffGMpzESFlockS65cr5gmSu152A5oEgkqXT1sRKhMDC1qrFgnA=="
|
"js": "TckiF5MG/wcxxDccWP/JWeAQUlw6PD8/cNLirc/68eUNJ9MhwT7Rox1191V26BN8pdbzvqamBy30gGa1WvHa8byRAN9l7BoN2gCHOrf52hNPAkWGVXrrDEKkuMlvODifqjbzqW0llPoF1Ylq9vmTVei0qYLhCgsiz3Y8q5v7Ng6MWqph//DpiZuXq8xN23qjMEav5Rkab4/7IIbNlZOCEgt9JALQ6uW76OOWpoXNWegWIGDvkrs83Dq4WRn9As2YP6EueAywVkCCSjc9XkrbMTNOBOhTL7vgzyx5QiPfW7cWilcp27DGXbTp2uAbzyEnAiNg/U0wDckmqr8k2BwSbQ=="
|
||||||
},
|
},
|
||||||
"publicKey": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0oZB2Kt7AzRFNqf8FuO3C3kepHPAIQYiDPYdQxHcsiaFCwyKVx6K1cE/3vBhb8/2rj+QIIWNfAAuu1Y+2VK90ZBeq6HciukWzQRO/HWhfdy0c7JwDAslmyGI5olj0ZQkNLhkde1MiMxjDPpRhZtdJaryVO5cFJaJESpv3dV6m0qXsaQCluWYOSNfSjP9C8o2zRVjSi3ZQZnZIV5pnk9K2MtlZIPXrN9iJiM5zZ9DTSnqApI6dC9mX4R3LvGN+GTovm9C8Crl+qb106nGRR3LcweicDnPyMtZLa/E0DBpWYxUVLDp6WeLhxoUBr+6+t3Xp9IDnPoANDQXJXD0f1vQxQIDAQAB",
|
"publicKey": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0oZB2Kt7AzRFNqf8FuO3C3kepHPAIQYiDPYdQxHcsiaFCwyKVx6K1cE/3vBhb8/2rj+QIIWNfAAuu1Y+2VK90ZBeq6HciukWzQRO/HWhfdy0c7JwDAslmyGI5olj0ZQkNLhkde1MiMxjDPpRhZtdJaryVO5cFJaJESpv3dV6m0qXsaQCluWYOSNfSjP9C8o2zRVjSi3ZQZnZIV5pnk9K2MtlZIPXrN9iJiM5zZ9DTSnqApI6dC9mX4R3LvGN+GTovm9C8Crl+qb106nGRR3LcweicDnPyMtZLa/E0DBpWYxUVLDp6WeLhxoUBr+6+t3Xp9IDnPoANDQXJXD0f1vQxQIDAQAB",
|
||||||
"desktop": true,
|
"desktop": true,
|
||||||
|
|
|
@ -10,6 +10,7 @@ function run() {
|
||||||
const path = nodeRequire('path');
|
const path = nodeRequire('path');
|
||||||
const electron = nodeRequire('electron');
|
const electron = nodeRequire('electron');
|
||||||
|
|
||||||
|
const Backbone = require('backbone');
|
||||||
const kdbxweb = require('kdbxweb');
|
const kdbxweb = require('kdbxweb');
|
||||||
const AppModel = require('models/app-model');
|
const AppModel = require('models/app-model');
|
||||||
const EntryModel = require('models/entry-model');
|
const EntryModel = require('models/entry-model');
|
||||||
|
@ -24,6 +25,7 @@ function run() {
|
||||||
const FileReadTimeout = 500;
|
const FileReadTimeout = 500;
|
||||||
const EntryTitle = 'KeePassHttp Settings';
|
const EntryTitle = 'KeePassHttp Settings';
|
||||||
const EntryFieldPrefix = 'AES Key: ';
|
const EntryFieldPrefix = 'AES Key: ';
|
||||||
|
const EntryUuid = 'NGl6QIpbQcCfNol9Yj7LMQ==';
|
||||||
|
|
||||||
const keys = {};
|
const keys = {};
|
||||||
const addedKeys = {};
|
const addedKeys = {};
|
||||||
|
@ -163,6 +165,7 @@ function run() {
|
||||||
let settingsEntry = getSettingsEntry(file);
|
let settingsEntry = getSettingsEntry(file);
|
||||||
if (!settingsEntry) {
|
if (!settingsEntry) {
|
||||||
settingsEntry = EntryModel.newEntry(file.get('groups').first(), file);
|
settingsEntry = EntryModel.newEntry(file.get('groups').first(), file);
|
||||||
|
settingsEntry.entry.uuid = new kdbxweb.KdbxUuid(EntryUuid);
|
||||||
settingsEntry.setField('Title', EntryTitle);
|
settingsEntry.setField('Title', EntryTitle);
|
||||||
}
|
}
|
||||||
for (const key of Object.keys(addedKeys)) {
|
for (const key of Object.keys(addedKeys)) {
|
||||||
|
@ -177,16 +180,11 @@ function run() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file.reload();
|
file.reload();
|
||||||
|
Backbone.trigger('refresh');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSettingsEntry(file) {
|
function getSettingsEntry(file) {
|
||||||
let entry = null;
|
return file.getEntry(file.subId(EntryUuid));
|
||||||
file.get('groups').first().forEachOwnEntry({ textLower: EntryTitle.toLowerCase() }, e => {
|
|
||||||
if (e.title === EntryTitle) {
|
|
||||||
entry = e;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return entry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class RequestContext {
|
class RequestContext {
|
||||||
|
@ -362,7 +360,7 @@ function run() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.req.Id = 'KeeWeb_' + new Date().toISOString() + '_' + crypto.randomBytes(16).toString('hex');
|
this.req.Id = 'KeeWeb ' + new Date().toISOString();
|
||||||
logger.info(`associate: ${this.req.Id}`);
|
logger.info(`associate: ${this.req.Id}`);
|
||||||
this.saveKeyWithId();
|
this.saveKeyWithId();
|
||||||
this.createResponse();
|
this.createResponse();
|
||||||
|
@ -385,13 +383,24 @@ function run() {
|
||||||
this.resp.Count = entries.length;
|
this.resp.Count = entries.length;
|
||||||
logger.info(`getLogins(${url}): ${this.resp.Count}`);
|
logger.info(`getLogins(${url}): ${this.resp.Count}`);
|
||||||
if (!config.onlyCount) {
|
if (!config.onlyCount) {
|
||||||
this.resp.Entries = entries.map(entry => ({
|
this.resp.Entries = entries.map(entry => {
|
||||||
Login: entry.user ? this.encrypt(entry.user) : '',
|
let customFields = null;
|
||||||
Name: entry.title ? this.encrypt(entry.title) : '',
|
for (const field of Object.keys(entry.fields)) {
|
||||||
Password: entry.password ? this.encrypt(entry.password) : '',
|
if (!customFields) {
|
||||||
StringFields: null,
|
customFields = [];
|
||||||
Uuid: this.encrypt(entry.id)
|
}
|
||||||
}));
|
const fieldKey = this.encrypt(field);
|
||||||
|
const fieldValue = this.encrypt(entry.fields[field]);
|
||||||
|
customFields.push({ Key: fieldKey, Value: fieldValue });
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
Login: entry.user ? this.encrypt(entry.user) : '',
|
||||||
|
Name: entry.title ? this.encrypt(entry.title) : '',
|
||||||
|
Password: entry.password ? this.encrypt(entry.password) : '',
|
||||||
|
StringFields: customFields,
|
||||||
|
Uuid: this.encrypt(entry.entry.uuid.id)
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue