In my app I’m using the plugin crypto-pouch for pouchdb database encryption. This was working without any problems until the last few weeks.
I updated to the last versions of ionic and cordova. Following mostly this article, I started a new test-project. This is working well in browser and on an android device (Google Nexus 9). But if I make the following changes, the problem begins:
First I install the plugin crypto-pouch:
npm install crypto-pouch --save
Then I inserted the plugin in the database provider like this:
import { Injectable } from '@angular/core';
import * as PouchDB from 'pouchdb';
import cordovaSqlitePlugin from 'pouchdb-adapter-cordova-sqlite';
import CryptoPouch from 'crypto-pouch';
PouchDB.plugin(cordovaSqlitePlugin);
PouchDB.plugin(CryptoPouch);
@Injectable()
export class DatabaseProvider {
private db;
initDB() {
this.db = new PouchDB('test.db', { adapter: 'websql' });
this.db.crypto('pa$$w0rd');
}
}
The function initDB() is called from app.components.ts like this:
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, database: DatabaseProvider) {
platform.ready().then(() => {
statusBar.styleDefault();
splashScreen.hide();
database.initDB();
});
}
If I’m testing this in browser (Chrome) everything is okay, but on the android device I’m getting the following error:
ERROR Error: Uncaught (in promise): TypeError: "size" argument must be a number
TypeError: "size" argument must be a number
at assertSize (main.js:15392)
at allocUnsafe (main.js:15423)
at Function.Buffer.allocUnsafe (main.js:15437)
at module.exports (main.js:80244)
at main.js:122523
at t.invoke (polyfills.js:3)
at Object.onInvoke (main.js:4427)
at t.invoke (polyfills.js:3)
at r.run (polyfills.js:3)
at polyfills.js:3
at assertSize (main.js:15392)
at allocUnsafe (main.js:15423)
at Function.Buffer.allocUnsafe (main.js:15437)
at module.exports (main.js:80244)
at main.js:122523
at t.invoke (polyfills.js:3)
at Object.onInvoke (main.js:4427)
at t.invoke (polyfills.js:3)
at r.run (polyfills.js:3)
at polyfills.js:3
at c (polyfills.js:3)
at polyfills.js:3
at t.invokeTask (polyfills.js:3)
at Object.onInvokeTask (main.js:4418)
at t.invokeTask (polyfills.js:3)
at r.runTask (polyfills.js:3)
at o (polyfills.js:3)
at invoke (polyfills.js:3)
at n (polyfills.js:2)
Can you help me, please? I don’t have any ideas, how to solve this. Thanks in advance!