keeweb / kdbxweb

Web Kdbx library
https://app.keeweb.info
MIT License
413 stars 57 forks source link

How to get Informations ? #24

Closed AlFalahTaieb closed 5 years ago

AlFalahTaieb commented 5 years ago

First of all thank you so much for making this package, it's saving my life,

I got some questions :

At the moment i'm able to lad the Database, my only concern didn't figure out how i can display all my titles/username/passwords ?

Thank you soo much

antelle commented 5 years ago

Hi! Something like this:

kdbxweb.Kdbx.load(file, credentials).then(db => {
    for (const group of db.groups) {
        processGroup(group);
    }
}).catch(e => {
    console.error('Error', e);
});

function processGroup(group) {
    console.log(`Group: ${group.name}`);
    for (const entry of group.entries) {
        console.log(`Entry: ${field(entry, 'Title')}: ${field(entry, 'UserName')}/${field(entry, 'Password')}`);
    }
    for (const subGroup of group.groups) {
        processGroup(subGroup);
    }
}

function field(entry, name) {
    const field = entry.fields[name];
    if (field && field.getText) {
        return field.getText();
    }
    return field;
}