implemented get-database-groups

This commit is contained in:
antelle 2021-04-12 23:05:57 +02:00
parent fe86cd6320
commit b9e08cd9e3
No known key found for this signature in database
GPG Key ID: 63C9777AAB7C563C
1 changed files with 30 additions and 8 deletions

View File

@ -113,12 +113,6 @@ function ensureAtLeastOneFileIsOpen() {
}
}
function validateAssociation(payload) {
if (payload.id !== KeeWebAssociationId) {
throw makeError(Errors.noOpenFiles);
}
}
function checkContentRequestPermissions(request) {
ensureAtLeastOneFileIsOpen();
@ -277,7 +271,10 @@ const ProtocolHandlers = {
'test-associate'(request) {
const payload = decryptRequest(request);
ensureAtLeastOneFileIsOpen();
validateAssociation(payload);
if (payload.id !== KeeWebAssociationId) {
throw makeError(Errors.noOpenFiles);
}
return encryptResponse(request, {
success: 'true',
@ -312,7 +309,32 @@ const ProtocolHandlers = {
decryptRequest(request);
await checkContentRequestPermissions(request);
throw new Error('Not implemented');
const makeGroups = (group) => {
const res = {
name: group.title,
uuid: kdbxweb.ByteUtils.bytesToHex(group.group.uuid.bytes),
children: []
};
for (const subGroup of group.items) {
if (subGroup.matches()) {
res.children.push(makeGroups(subGroup));
}
}
return res;
};
const groups = [];
for (const file of appModel.files.filter((f) => f.active)) {
for (const group of file.groups) {
groups.push(makeGroups(group));
}
}
return encryptResponse(request, {
success: 'true',
version: getVersion(request),
groups: { groups }
});
},
async 'create-new-group'(request) {