How to use kdbxweb - 10 common examples

To help you get started, we’ve selected a few kdbxweb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github subdavis / Tusk / services / keepassService.js View on Github external
return passwordFileStoreRegistry.getChosenDatabaseFile(settings).then(function(buf) {
			var h = keepassHeader.readHeader(buf);
			if (!h) throw new Error('Failed to read file header');

			if (h.kdbx) { // KDBX - use kdbxweb library
				kdbxweb.CryptoEngine.argon2 = argon2;
				var kdbxCreds = jsonCredentialsToKdbx(masterKey);
				return kdbxweb.Kdbx.load(buf, kdbxCreds).then(db => {
					var psk = new Uint8Array(db.header.protectedStreamKey, 0, db.header.protectedStreamKey.length);
					var entries = parseKdbxDb(db.groups);
					majorVersion = db.header.versionMajor;
					return processReferences(entries, majorVersion);
				});
			} else { // KDB - we don't support this anymore
				throw "Unsupported Database Version";
			}
		}).then(function(entries) {
			return {
github subdavis / Tusk / services / keepassService.js View on Github external
return bufferPromise.then(function (buf) {
			var h = keepassHeader.readHeader(buf);
			if (!h) throw new Error('Failed to read file header');

			if (h.kdbx) { // KDBX - use kdbxweb library
				kdbxweb.CryptoEngine.argon2 = argon2;
				var kdbxCreds = jsonCredentialsToKdbx(masterKey);
				return kdbxweb.Kdbx.load(buf, kdbxCreds).then(db => {
					var psk = new Uint8Array(db.header.protectedStreamKey, 0, db.header.protectedStreamKey.length);
					var entries = parseKdbxDb(db.groups);
					majorVersion = db.header.versionMajor;
					return processReferences(entries, majorVersion);
				});
			} else { // KDB - we don't support this anymore
				throw "Unsupported Database Version";
			}
		}).then(function (entries) {
			return {
github iotaledger / trinity-wallet / src / mobile / nodejs-assets / nodejs-project / main.js View on Github external
// Temporary solution until Argon2 support is added to Java lib

const rnBridge = require('rn-bridge'); // eslint-disable-line import/no-unresolved
const argon2 = require('argon2');
const kdbxweb = require('kdbxweb');

/**
 * Bind kdbxweb and argon2
 */
kdbxweb.CryptoEngine.argon2 = (password, salt, memory, iterations, length, parallelism, type, version) => {
    return argon2.hash(password, {
        hashLength: length,
        timeCost: iterations,
        memoryCost: memory,
        parallelism,
        type,
        version,
        salt: Buffer.from(salt),
        raw: true,
    });
};

/**
 * Encrypt seed to .kdbx database format
 * @method createSeedVault
 *
github subdavis / Tusk / services / keepassService.js View on Github external
return bufferPromise.then(function (buf) {
			var h = keepassHeader.readHeader(buf);
			if (!h) throw new Error('Failed to read file header');

			if (h.kdbx) { // KDBX - use kdbxweb library
				kdbxweb.CryptoEngine.argon2 = argon2;
				var kdbxCreds = jsonCredentialsToKdbx(masterKey);
				return kdbxweb.Kdbx.load(buf, kdbxCreds).then(db => {
					var psk = new Uint8Array(db.header.protectedStreamKey, 0, db.header.protectedStreamKey.length);
					var entries = parseKdbxDb(db.groups);
					majorVersion = db.header.versionMajor;
					return processReferences(entries, majorVersion);
				});
			} else { // KDB - we don't support this anymore
				throw "Unsupported Database Version";
			}
		}).then(function (entries) {
			return {
github subdavis / Tusk / services / keepassService.js View on Github external
return passwordFileStoreRegistry.getChosenDatabaseFile(settings).then(function(buf) {
			var h = keepassHeader.readHeader(buf);
			if (!h) throw new Error('Failed to read file header');

			if (h.kdbx) { // KDBX - use kdbxweb library
				kdbxweb.CryptoEngine.argon2 = argon2;
				var kdbxCreds = jsonCredentialsToKdbx(masterKey);
				return kdbxweb.Kdbx.load(buf, kdbxCreds).then(db => {
					var psk = new Uint8Array(db.header.protectedStreamKey, 0, db.header.protectedStreamKey.length);
					var entries = parseKdbxDb(db.groups);
					majorVersion = db.header.versionMajor;
					return processReferences(entries, majorVersion);
				});
			} else { // KDB - we don't support this anymore
				throw "Unsupported Database Version";
			}
		}).then(function(entries) {
			return {
github keeweb / keeweb / app / scripts / comp / feature-tester.js View on Github external
.then(res => {
                            if (kdbxweb.ByteUtils.bytesToHex(res) !== exp) {
                                throw 'AES is not working properly';
                            }
                            if (kdbxweb.CryptoEngine.random(1).length !== 1) {
                                throw 'Random is not working';
                            }
                        });
                })
github keeweb / keeweb / app / scripts / comp / feature-tester.js View on Github external
return Promise.resolve().then(() => {
            const aesCbc = kdbxweb.CryptoEngine.createAesCbc();
            const key = '6b2796fa863a6552986c428528d053b76de7ba8e12f8c0e74edb5ed44da3f601';
            const data = 'e567554429098a38d5f819115edffd39';
            const iv = '4db46dff4add42cb813b98de98e627c4';
            const exp = '46ab4c37d9ec594e5742971f76f7c1620bc29f2e0736b27832d6bcc5c1c39dc1';
            return aesCbc
                .importKey(kdbxweb.ByteUtils.hexToBytes(key))
                .then(() => {
                    return aesCbc
                        .encrypt(
                            kdbxweb.ByteUtils.hexToBytes(data),
                            kdbxweb.ByteUtils.hexToBytes(iv)
                        )
                        .then(res => {
                            if (kdbxweb.ByteUtils.bytesToHex(res) !== exp) {
                                throw 'AES is not working properly';
                            }
github mydicebot / mydicebot.github.io / src / api / controllers / apiController.js View on Github external
exports.keereg = async function(req, res) {
    try{
        let filePath = path.resolve(path.join(process.execPath, '../keepass/')+req.body.keepassfile+'.kdbx');
        if(isMobile(req)) {
            //filePath = path.resolve('/tmp/keepass/'+req.body.keepassfile+'.kdbx');
            filePath = path.resolve(path.join(__dirname, '../../keepass/'+req.body.keepassfile+'.kdbx'));
        }
        if(process.env.electron) {
            filePath = path.resolve(path.join(config.mydice.path, '/keepass/'+req.body.keepassfile+'.kdbx'));
        }
        let cred = new kdbxweb.Credentials(kdbxweb.ProtectedValue.fromString(req.body.keepassword));
        let db = kdbxweb.Kdbx.create(cred, 'mydicebot');
        //let subGroup = db.createGroup(db.getDefaultGroup(), 'mydicebot');
        db.save().then(ab => {
            fs.writeFileSync(filePath, Buffer.from(ab));
            return res.status(200).json('ok');
        });
    } catch(err) {
        console.log(err);
        return res.status(500).send({err: err.toString()});
    }
};
github iotaledger / trinity-wallet / src / desktop / native / libs / kdbx.js View on Github external
const importVault = async (buffer, password) => {
    const credentials = new kdbxweb.Credentials(kdbxweb.ProtectedValue.fromString(password));

    const db = await kdbxweb.Kdbx.load(buffer, credentials);
    const entries = db.getDefaultGroup().entries;
    const seeds = [];

    for (let i = 0; i < entries.length; i++) {
        if (entries[i].fields.Seed) {
            seeds.push({
                title: entries[i].fields.Title || `Seed #${i + 1}`,
                seed: entries[i].fields.Seed.getText()
                    .split('')
                    .map((char) => charToByte(char.toUpperCase()))
                    .filter((byte) => byte > -1),
            });
        }
    }
github keeweb / keeweb / app / scripts / views / fields / field-view-text.js View on Github external
endEdit(newVal, extra) {
        if (this.gen) {
            this.hideGenerator();
        }
        if (!this.editing) {
            return;
        }
        delete this.input;
        if (this.mobileControls) {
            this.mobileControls.cancel.remove();
            this.mobileControls.apply.remove();
            delete this.mobileControls;
        }
        this.stopBlurListener();
        if (typeof newVal === 'string' && this.value instanceof kdbxweb.ProtectedValue) {
            newVal = kdbxweb.ProtectedValue.fromString(newVal);
        }
        if (typeof newVal === 'string') {
            newVal = $.trim(newVal);
        }
        super.endEdit(newVal, extra);
    }