calvinmetcalf / crypto-pouch

plugin for encrypted pouchdb/couchdb databases
MIT License
243 stars 43 forks source link

Crypto-Pouch and typescript #40

Closed tubauwe closed 8 years ago

tubauwe commented 8 years ago

I'm trying to use Crypto-Pouch in an Ionic 2 application. After switching to Ionic 2 RC0 I managed after a couple of days to use PouchDB again. But I'm not able to use Crypto-Pouch.

Because Ionic 2 suggest to use typescript and not javascript, I need a type definition for Crypto-Pouch. Do you know, how to do this? Thanks in advance.

In the Ionic forum I described in this topic my Problem.

calvinmetcalf commented 8 years ago

I don't use typescript so I'm not really sure how I can help you. I don't think you HAVE to use typescript so if you don't really know how to use it either, then maybe don't.

tubauwe commented 8 years ago

The error message is:

Uncaught TypeError: Cannot read property 'listenerCount' of undefined _stream_readable.js:38

Do you have an idea to solve?

hadrien-toma commented 8 years ago

Same error for me as described here too.

tubauwe commented 8 years ago

After the latest updates in build process of ionic, I tried using crypto-pouch again. By using the following lines in my data provider, I get no error messages first (not trying to encrypt the database):

import PouchDB from 'pouchdb';
import CryptoPouch from 'crypto-pouch';
PouchDB.plugin(CryptoPouch);

But if I insert the crypto command in the code, I get one of the following errors:

  1. Trying only myDB.crypto('password'); I get this error message:

    TypeError: Failed to execute 'importKey' on 'SubtleCrypto': The provided value is not of type '(ArrayBufferView or ArrayBufferView or Dictionary)'

  2. Trying this

    myDB.crypto('password').then((st) => { console.log(st); }

    I get this error message:

    TypeError: Cannot read property 'then' of undefined

I think I'm a step ahead now, but I don't know to solve it completely. Can you help me? Thanks in advance.

calvinmetcalf commented 8 years ago

2 shouldn't work any more as of version 2,

1 is a bug that I will fix either latter today or tommorow, for now just run

myDB.crypto(Buffer.from('password', 'utf8'))

calvinmetcalf commented 8 years ago

ok new version of native-crypto published, reinstall your deps and try again

tubauwe commented 7 years ago

After removing the folder _nodemodules in my project and using npm install to get all dependencies again, I get this error again:

TypeError: Cannot read property 'listenerCount' of undefined
    at http://localhost:8100/build/main.js:106800:8
    at http://localhost:8100/build/main.js:127811:2

Is it possible, that the fixed error is coming up again after an update?

This error disappears if I remove mydb.crypto(...).