Creating DB of Keepass returns Error InvalidArg: data using kdbxweb Library

15 Views Asked by At

I'm trying to put the Keepass Information in variables (JS). In the last step when I'm storing de DB information I got the "InvalidArg: data" Error

The version of kdbxweb is 2.1.1

The version of Node.js is v20.11.0

The version of Keepass is 2.50 (64 bits)

OS: Windows 10

The extension of the file is .mjs

The code is:

import kdbxweb from 'kdbxweb';
import { promises as fs } from 'fs';

// DB PATH
const ruta = 'genericRoute';

// DB PASSWORD
const clave = 'genericPassword';

// Loading DB
async function cargarBaseDeDatos(){
    try{
        
        const datos = await fs.readFile(ruta);
        console.log('Informacion de datos:', datos);
        let credenciales = new kdbxweb.Credentials(kdbxweb.ProtectedValue.fromString(clave));
        
        await credenciales.ready;
        console.log('Informacion de credenciales:', credenciales);

        const db = await kdbxweb.Kdbx.load(datos, credenciales);

    } catch (error){
        console.error('Error al cargar la base de datos', error.message);
    }
    
    
}

cargarBaseDeDatos();

The result of running this code is:

Informacion de datos: <Buffer 03 d9 a2 9a 67 fb 4b b5 01 00 03 00 02 10 00 31 c1 f2 e6 bf 71 43 50 be 58 05 21 6a fc 5a ff 03 04 00 01 00 00 00 04 20 00 ed 08 87 7b f1 1b f1 52 e3 ... 2460 more bytes>

Informacion de credenciales: <ref *1> KdbxCredentials {

keyFileHash: undefined,

_challengeResponse: undefined,

ready: Promise { [Circular *1] },

passwordHash: ProtectedValue {

value: Uint8Array(32) [
  229, 142, 255, 116, 165, 223,  87, 124,
   32, 212,   8,  15, 131, 147, 248, 132,
   92,  54,  70, 180, 225, 154, 110, 232,
   48, 106,  57, 168, 245,  59, 152,  67
],

salt: Uint8Array(32) [
  169, 158, 109, 236,  58,  71, 49,   7,
    9, 109, 148,  43,  41, 128, 76, 120,
  146, 141, 114, 168,  43, 221, 77,  37,
  175,  79, 201, 210, 107,  33, 45, 219
]

} }

Error al cargar la base de datos Error InvalidArg: data

Doesn't matter if you change the value of clave you will keep having the same result of the running. Doesn't matter if it is the correct pasword or not.

I trid all the configuration of a .JS extension

0

There are 0 best solutions below