Closed ajmchambers closed 7 years ago
could you put some catches so we can figure out which db is actually giving the error?
I've poked about a bit more simplified the example a bit.
I get the error at the db2.crypto({key: new Uint8Array(key)});
line not actually the .get
or .post
.
Heres the simplified javascript, and heres a jsbin:
var db = new PouchDB('testing');
var db2 = new PouchDB('testing');
db.crypto({
password: 'secret',
cb: (err, key) => {
var keyCopy = new Uint8Array(key);
console.log('key:', key);
console.log('keyCopy:', keyCopy);
// error occurs here
db2.crypto({key: new Uint8Array(key)});
}
});
Heres the error:
ok weird let me investigate
the issue is just I assume something is a node buffer but don't take into account it just being a plain uint8 buffer, for now you can change
db2.crypto({key: new Uint8Array(key)});
to
db2.crypto({key: Buffer.from(key)});
while i prepare a patch
Hey I read the post Security in Offline First Apps which got me interested in trying out crypto-pouch. I've been messing about trying to understand how this works but I've been getting the above error, just wondering what I'm doing wrong.
I'm using
db.crypto
with the callback function so I can get the key, I'm trying to create a copy of the key and use it withdb.crypto({key: key})
but with the copy I'm getting the error:TypeError: Key data must be a BufferSource for non-JWK formats
I have this index.html:
this app.js:
In the console I get the above mentioned error with
db3
:Would love a bit of help, I'm probably just doing something silly here.
Cheers!