keeweb / kdbxweb

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

Password field #45

Open mmajcica opened 2 years ago

mmajcica commented 2 years ago

We are experiencing some inconsistent behavior with the Password field. Following code:

const entry = db.getDefaultGroup().entries.find((e) => e.fields.get('UserName') === entryName);
const passwordField = entry.fields.get('Password');

Sometimes returns an object of type ProtectedValue, sometime is a string. This is pushing us to implement the readout of that field in the following way:

const passwordField = entry.fields.get('Password');
let password = '';

if (passwordField instanceof kdbxweb.ProtectedValue) {
    password = (passwordField as kdbxweb.ProtectedValue).getText();
} else {
    password = passwordField;
}

Is there a reason for this behavior or is there a better way to prevent/fetch this?

Thanks