Giter VIP home page Giter VIP logo

cordova-sqlcipher-adapter's People

Contributors

aarononeal avatar brodybits avatar craig-at-rsg avatar davibe avatar dwinterbourne avatar ef4 avatar gillardo avatar gulian avatar j3k0 avatar joenoon avatar kakysha avatar lcsanchez avatar marcucio avatar mineshaftgap avatar nadyaa avatar nleclerc avatar nolanlawson avatar ollide avatar omjokine avatar rafaelbeckel avatar rahmadid avatar rkistner avatar sgrebnov avatar ste4net avatar steipete avatar steveoh avatar taybin avatar vjrantal avatar vldmrrr avatar vojto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cordova-sqlcipher-adapter's Issues

Is there an easy way to check that the database is encrypted in Android?

I just switched from Cordova-sqlite-storage to Cordova-sqlcipher-adapter because my db needs to be encrypted. When running my app on iOS I see a console message that indicates whether the db is encrypted (E.g. "Open DB with encryption" or "Open with NO encryption"). The only messages I see in Android logging is "OPEN database: app.db" & "DB: opened: app.db". Should I expect to see any messages in Android that indicate encryption status? If not, it would be nice to add them. Thanks for your excellent work on sqlcipher!

Plugin does not work with Worklight 6.2

Hi,

Issue is specific to the Android environment in Worklight 6.2 (IBM MobileFirst).

File names conflict with Worklight JSONstore file names (i.e. the sqlcipher.jar and .so libraries for each architecture). So, if you are trying to include this plugin but do not have JSONstore enabled, the files are removed during the Android environment build. If you enable JSONstore, the build will replace the files with the Worklight version of them.


Is it possible for you to release a version of this plugin that has slightly different naming?


Worklight uses the exact same file names as yours. The exact files I'm referring to:

android/sqlcipher/libs/sqlcipher.jar
android/sqlcipher/libs/[armeabi | armeabi-v7a | x86]libdatabase_sqlcipher.so
android/sqlcipher/libs/[armeabi | armeabi-v7a | x86]libsqlcipher_android.so
android/sqlcipher/libs/[armeabi | armeabi-v7a | x86]libstlport_shared.so

From what I've read, I've gathered that Worklight uses version 2.1 of sqlcipher. If you know of an easy way to implement the current (or an older) version of your plugin using version 2.1 of sqlcipher please let me know.

Any assistance on this would be very helpful, thanks!

Android: A lot of transactions can crash the App

Hi,

when doing sort of heavy load on the database (50 INSERTS or so) we get following error and our app crashes. We are investigating at the moment. Does anyone have an idea? :)

03-27 14:41:23.680: E/System(13520): net.sqlcipher.database.SQLiteCompiledSql.finalize() timed out after 10000 ms; limit is 10000 ms
03-27 14:41:23.700: E/System(13520): java.util.concurrent.TimeoutException
03-27 14:41:23.700: E/System(13520):    at java.lang.Object.wait(Native Method)
03-27 14:41:23.700: E/System(13520):    at java.lang.Thread.parkFor(Thread.java:1231)
03-27 14:41:23.700: E/System(13520):    at sun.misc.Unsafe.park(Unsafe.java:323)
03-27 14:41:23.700: E/System(13520):    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
03-27 14:41:23.700: E/System(13520):    at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:813)
03-27 14:41:23.700: E/System(13520):    at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:846)
03-27 14:41:23.700: E/System(13520):    at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1176)
03-27 14:41:23.700: E/System(13520):    at java.util.concurrent.locks.ReentrantLock$FairSync.lock(ReentrantLock.java:200)
03-27 14:41:23.700: E/System(13520):    at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:261)
03-27 14:41:23.700: E/System(13520):    at net.sqlcipher.database.SQLiteDatabase.lock(SQLiteDatabase.java:435)
03-27 14:41:23.700: E/System(13520):    at net.sqlcipher.database.SQLiteCompiledSql.releaseSqlStatement(SQLiteCompiledSql.java:106)
03-27 14:41:23.700: E/System(13520):    at net.sqlcipher.database.SQLiteCompiledSql.finalize(SQLiteCompiledSql.java:152)
03-27 14:41:23.700: E/System(13520):    at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:186)
03-27 14:41:23.700: E/System(13520):    at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:169)
03-27 14:41:23.700: E/System(13520):    at java.lang.Thread.run(Thread.java:856)

FAILED, aborting any pending transactions

everything was working fine. i don't know what happened but i am getting this error when i am trying to run the app 2nd time after installation.

OPEN database: db.db
OPEN database: db.db FAILED, aborting any pending transactions
Could not open database
TypeError: undefined is not a function
    at SQLitePlugin.transaction (file:///android_asset/www/plugins/cordova-sqlcipher-adapter/www/SQLitePlugin.js:115:7)
    at Object.execute (file:///android_asset/www/js/ng-cordova.min.js:9:23737)
    at Scope.$scope.searchWord (file:///android_asset/www/js/controllers.js:411:17)
    at fn (eval at <anonymous> (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:27643:15), <anonymous>:4:294)
    at Scope.$eval (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:30400:28)
    at file:///android_asset/www/lib/ionic/js/ionic.bundle.js:37225:13
    at file:///android_asset/www/lib/ionic/js/ionic.bundle.js:39989:9
    at forEach (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:13696:20)
    at $$writeModelToScope (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:39987:5)
    at writeToModelIfNeeded (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:39980:14)

any help is much appreciated.

Coming across the error 'database not open' in SQLitePlugin.js

On trying to open database with the prescribed command, I am getting an error and it navigates to the following line (114) in SQLitePlugin.js

error(newSQLError('database not open'));

My code is as below:

function onDeviceReady() {
/console.log(navigator.notification);/
alert("inside onDeviceReady of login.js");
var dbObj = window.sqlitePlugin.openDatabase({name: DB_NAME, key: 'sdtaylor', location: 1},
dataStorage.successcb,
dataStorage.errorcb);

...
other code
..............
};

$(document).on("pagebeforeshow","#loginPage", function() {
window.sessionStorage.clear();
document.addEventListener("deviceready", onDeviceReady, false);
});

executeSql not called in transaction

Hi,

I am getting crazy...

I have spent a whole day trying to figure out what's wrong in this function, so any help will be greatly appreciated.

This the function (in my DBService class) :

    this.saveNews = function() {

        var deferred             = $.Deferred();

        this.db.transaction(

            function (tx) {

                console.log("saveNews - global_news_data.rows.length="+global_news_data.rows.length);
                for(var i = 0; i < global_news_data.rows.length; i++)
                {
                    if(global_news_data.rows[i].ID != null) {

                        console.log("SELECT news_id="+global_news_data.rows[i].ID);

                        tx.executeSql("SELECT * FROM news WHERE news_id = ?", [global_news_data.rows[i].ID], 
                            function(tx, res) {
                                console.log("SELECT news_id="+global_news_data.rows[i].ID+" OK !!!");
                                if(res.rows.length==0) {
                                    tx.executeSql("INSERT INTO news (news_id, news_post_title, news_post_date_gmt, news_post_date_long, news_post_content, news_comment_count, news_views, news_image, news_author) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", [global_news_data.rows[i].ID, global_news_data.rows[i].post_title, global_news_data.rows[i].post_date_gmt, global_news_data.rows[i].post_date_long, global_news_data.rows[i].post_content, global_news_data.rows[i].comment_count, global_news_data.rows[i].views, global_news_data.rows[i].img, global_news_data.rows[i].display_name], 
                                        function(tx, res) {
                                            console.log("news inserted !!!");
                                        },
                                        function (tx, error) {
                                            console.log('news INSERT error : ' + error.message);
                                            return true;
                                        }
                                    );
                                }
                                else {
                                    tx.executeSql("UPDATE news SET news_comment_count = ?, news_views = ? WHERE news_id = ?", [global_news_data.rows[i].comment_count, global_news_data.rows[i].views, global_news_data.rows[i].ID], 
                                        function(tx, res) {
                                            console.log("news updated !!!");
                                        },
                                        function (tx, error) {
                                            console.log('news UPDATE error : ' + error.message);
                                            return true;
                                        }
                                    );
                                }
                            },
                            function (tx, error) {
                                console.log('news SELECT error : ' + error.message);
                                return true;
                            }
                        );
                    }
                }
            },
            function (error) {
                deferred.reject("saveNews transaction Error: "+error.code+", msg:"+error.message);
            },
            function () {
                console.log('saveNews transaction success');
                deferred.resolve();
            }
        );
        return deferred.promise();
    }

None of the transaction callbacks are called. I just see "SELECT news_id=xxx" 175 times because I have 175 news to update. It seems the first tx.executeSql in not called.

Thanks a lot.

Not able to create the database

I am using the plugin in my ionic cordova project, I am ubale to create the database,Below is the code which I am using to create database.

var db = window.openDatabase({name: "my.db", key: "myFirstDatabase", location: 1}, function(db){console.log("created");},function(res){console.log("error");});

But if i am using the older way I am able to create.

var db = window.openDatabase("Database", "1.0", "Demo", -1);

Ps: Since I am using angular js using openDatabase directly from window.

Android: Cursor not closed explicitly

Hi,

we frequently get logging output indicating the cursors not getting closed on Android Devices. They occur every time we do several transactions in a row. All the transactions are handled just fine, no errors. But maybe these lines lead to something that can be improved. Thanks for your time.

03-27 14:12:24.920: W/SQLiteCompiledSql(31066): Releasing statement in a finalizer. Please ensure that you explicitly call close() on your cursor: INSERT INTO foo (bar, bar2, bar3 
03-27 14:12:24.920: W/SQLiteCompiledSql(31066): net.sqlcipher.database.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here
03-27 14:12:24.920: W/SQLiteCompiledSql(31066):     at net.sqlcipher.database.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:62)
03-27 14:12:24.920: W/SQLiteCompiledSql(31066):     at net.sqlcipher.database.SQLiteProgram.<init>(SQLiteProgram.java:103)
03-27 14:12:24.920: W/SQLiteCompiledSql(31066):     at net.sqlcipher.database.SQLiteStatement.<init>(SQLiteStatement.java:39)
03-27 14:12:24.920: W/SQLiteCompiledSql(31066):     at net.sqlcipher.database.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1241)
03-27 14:12:24.920: W/SQLiteCompiledSql(31066):     at org.pgsqlite.SQLitePlugin.executeSqlBatch(SQLitePlugin.java:427)
03-27 14:12:24.920: W/SQLiteCompiledSql(31066):     at org.pgsqlite.SQLitePlugin.access$100(SQLitePlugin.java:40)
03-27 14:12:24.920: W/SQLiteCompiledSql(31066):     at org.pgsqlite.SQLitePlugin$DBRunner.run(SQLitePlugin.java:702)
03-27 14:12:24.920: W/SQLiteCompiledSql(31066):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
03-27 14:12:24.920: W/SQLiteCompiledSql(31066):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
03-27 14:12:24.920: W/SQLiteCompiledSql(31066):     at java.lang.Thread.run(Thread.java:856)

error: method does not override or implement a method from a supertype

I installed cordova-sqlite-ext plugin for Pre-Populated database and also installed this cipher-adapter.

When I do "ionic cordorva build android", the cipher-adapter's build fails.

BUILD FAILED

    Total time: 1.25 secs
    Error: /Users/comseong/dev/ionic3/myApp-tab/platforms/android/gradlew: Command failed with exit code 1 
    Error output:
    /Users/comseong/dev/ionic3/myApp-tab/platforms/android/src/io/sqlc/SQLiteConnectorDatabase.java:55: 
    error: method does not override or implement a method from a supertype
         @Override
         ^
    /Users/comseong/dev/ionic3/myApp-tab/platforms/android/src/io/sqlc/SQLiteConnectorDatabase.java:77: 
    error: method does not override or implement a method from a supertype
         @Override
         ^
    Note: Some input files use or override a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    Note: /Users/comseong/dev/ionic3/myApp-tab/platforms/android/src/cordova/plugins/Diagnostic.java uses 
    unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    2 errors
    
    FAILURE: Build failed with an exception.

Cannot read database with CORRECT password directly after attempt to open with INCORRECT password

On Android/iOS the workaround seems to be to close and then open again. Here is the test case:

      it(suiteName + ' Attempt to open encrypted DB with INCORRECT password THEN OPEN & READ with CORRECT PASSWORD [PLUGIN BROKEN: MUST CLOSE THEN TRY AGAIN]', function (done) {
        if (isWindows) pending('SKIP for Windows: CALLBACK NOT RECEIVED');
        var dbName = 'Encrypted-DB-attempt-incorrect-password-then-correct-password.db';
        var test_data = 'test-data';

        window.sqlitePlugin.openDatabase({name: dbName, key: 'test-password', location: 'default'}, function (db1) {
            expect(db1).toBeDefined();
            // CREATE TABLE to put some contents into the DB:
            db1.transaction(function(tx) {
              tx.executeSql('DROP TABLE IF EXISTS tt');
              tx.executeSql('CREATE TABLE IF NOT EXISTS tt (test_data)');
              tx.executeSql('INSERT INTO tt (test_data) VALUES (?)', [test_data]);
            }, function(error) {
              // NOT EXPECTED:
              expect(false).toBe(true);
              expect(error.message).toBe('--');
              done();
            }, function() {
              db1.close(function () {

                window.sqlitePlugin.openDatabase({name: dbName, key: 'another-password', location: 'default'}, function (db2) {
                  // NOT EXPECTED:
                  expect(false).toBe(true);
                  done();
                }, function (error) {
                  // EXPECTED RESULT:
                  expect(error).toBeDefined();
                  // FUTURE TBD CHECK code/message

                  window.sqlitePlugin.openDatabase({name: dbName, key: 'test-password', location: 'default'}, function (db3) {
                    // EXPECTED RESULT:
                    expect(db3).toBeDefined();
                    //* ** ALT 1:
                    db3.transaction(function(tx) {
                      tx.executeSql('SELECT * FROM tt', null, function(ignored, rs) {
                        expect('PLUGIN FIXED PLEASE UPDATE THIS TEST').toBe('--');
                        expect(rs).toBeDefined();
                        expect(rs.rows).toBeDefined();
                        expect(rs.rows.length).toBe(1);
                        expect(rs.rows.item(0).test_data).toBe(test_data);
                        done();
                      }, function (ignored, error) {
                        // NOT EXPECTED:
                        expect(false).toBe(true);
                        expect(error.message).toBe('--');
                        done();
                      });

                    }, function (error) {
                      // TEST GETS HERE [Android/iOS/macOS]:
                      //expect(false).toBe(true);
                      //expect(error.message).toBe('--');
                      expect(error).toBeDefined();
                      db3.close(function() {
                        expect('PLUGIN BEHAVIOR CHANGED PLEASE UPDATE THIS TEST AND CHECK STORED DATA HERE').toBe('--');
                        done();
                      }, function(error) {
                        // TBD ???:
                        //expect(error).toBeDefined();
                        expect(error).not.toBeDefined();
                        // TRY AGAIN:
                        window.sqlitePlugin.openDatabase({name: dbName, key: 'test-password', location: 'default'}, function (db4) {
                          // EXPECTED RESULT:
                          expect(db4).toBeDefined();
                          //* ** ALT 1:
                          db4.transaction(function(tx) {
                            tx.executeSql('SELECT * FROM tt', null, function(ignored, rs) {
                              expect(rs).toBeDefined();
                              expect(rs.rows).toBeDefined();
                              expect(rs.rows.length).toBe(1);
                              expect(rs.rows.item(0).test_data).toBe(test_data);
                              done();
                            }, function (ignored, error) {
                              // NOT EXPECTED:
                              expect(false).toBe(true);
                              expect(error.message).toBe('--');
                              done();
                            });
                          }, function (error) {
                            // NOT EXPECTED:
                            expect(false).toBe(true);
                            expect(error.message).toBe('--');
                            done();
                          });
                        });
                      });
                    });
                    // */
                    /* ** FUTURE TBD ALT 2 [NO SQL CALLBACK RECEIVED]:
                    expect('check1').toBe('--'); // TEST ALT 2 GETS HERE
                    db3.executeSql('SELECT * FROM tt', null, function(rs) {
                      // NOT TRIGGERED Android/iOS:
                      expect(rs).toBeDefined();
                      // FUTURE TBD CHECK rs
                      done();
                    }, function (error) {
                      // NOT TRIGGERED Android/iOS:
                      // NOT EXPECTED:
                      expect(false).toBe(true);
                      expect(error.message).toBe('--');
                      done();
                    });
                    expect('check2').toBe('--'); // TEST ALT 2 GETS HERE
                    // */
                  });

                });

              }, function (error) {
                // NOT EXPECTED:
                expect(false).toBe(true);
                expect(error.message).toBe('--');
                done();
              });
            });
        }, function (error) {
          // NOT EXPECTED:
          expect(false).toBe(true);
          expect(error.message).toBe('--');
          done();
        });
      });

Do I need a sqlcipher license?

Hi,

I would like to use this adapter on a "closed source" project and don't want to place sqlcipher's BSD-license in my app. Am I free from doing it because this plugin has an MIT license? If not and I buy a sqlcipher license from Zetetic, can I use it with this plugin?

Thanks!

addStatement() not applying values to a query

I am trying to use this plugin to run an encrypted database for the next version of our app (we are using older versions of plugins at the moment and are wanting to update). One of the errors I am seeing frequently when trying to save data is

net.sqlcipher.database.SQLiteConstraintException: error code 19: NOT NULL constraint failed: events.id

This indicates that we are not setting certain values in our tables, particularly values that are supposed to be not null. This occurs when we use an sql statement like the following.

INSERT INTO events (id, formId, startTime, finishTime, userId, plannedFlag, json) VALUES ( ?, ?, ?, ?,?, ?, ?)]: NOT NULL constraint failed: events.id

After digging through our code, and the code of SQLitePlugin.js, I was able to confirm that the values are being sent correctly as an array of objects. This array of objects is making it into SQLitePluginTransaction.prototype.addStatement(), and it is doing so as the correct parameter. However, the check to see whether the values object is an array or not

if (!!values && values.constructor === Array)

is returning false. To check what the state of things is I added

if(values) console.log(values.constructor);

to the top of this function and got the following output:

"function Array() { [native code] }"

So it would appear that the object is an array, but values.constructor === Array is returning false. Is there some way that we can get around this / make this check more secure (while still maintaining as much speed as possible)?

I have noticed these errors being thrown on both iOS 8 and Android 4.4, but have only tracked the details down on Android (though I presume they are the same issues, since it is the same errors being thrown). If we do not have constraints on our tables then we do not get any errors, but no data is being stored either (since the values are not being passed along with the sql query).

Plugin-Update from 0.1.4-rc to 0.1.7 resulting in Incompatibility

I am experiencing problems after updating the plugin with databases that were created with earlier versions.

In my case I was updating from 0.1.4-rc to 0.1.7 in order to solve this issue regarding Android 7: #41

That worked...
...but: I am getting Errors Reading from tables of databases that were created with earlier versions of my app (with plugin 0.1.4rc).

Doing a "Select *" statement results in an "get field slot from row 0 col 0 failed" on Android and gives me an empty result on ios.

I tried to localize the problem by updating step by step.

0.1.4rc (current version in my app) - android & ios working fine
0.1.5 - android works, ios fails
0.1.6 - both fail
0.1.7 - both fail

I did update the default-location from "2" to "default" which should be the same. Correct me if I'm wrong. If I do a fresh install of the app - everything works like a charm... but well... we need the users existing database.

Everything I do is done in the success-callback of openDatabase.

The sequence is about this:

openDatabase
Create table a if not exists
Create table b if not exists
Select * from table b

=> Android: "get field slot from row 0 col 0 failed"
=> iOS: Empty result

I look forward to post a test program today...

What is Windows "Universal" (8.1) ?

Hello there,

I am a translator who happens to work on the doc related to this plugin.

In your doc, you are using this word "Windows Universal 8.1". Does this mean that "Windows 8.1 + Windows Phone 8.1" ?
Or any other thing?

It is lovely to know what you mean.

Thanks you for your advice in advance.

What is the use of password in openDatabase command.

As per documentation, the openDatabase is as below:

var db = window.sqlitePlugin.openDatabase({name: 'my.db', key: 'your-password-here', location: 'default'}, successcb, errorcb);

I would like to know what is the use of 'your-password-here', if I write a password then wouldn't it be visible on browser source code? What is the user of this password?

Diffecult to get object

Hi,

Here i have added a image for my issue. Whlie trying to get the data from DB its coming like this, so i cant able to get the data, so please provide valid solution to proceed further
sql error

Please tell me how to get the rounded values ACCCODE and ACCTYPE. Thanks in advance

PouchDB compatibility

I'm trying to make this work with PouchDB. So far I made a couple of fixes to PouchDB, specifically to pass the encryption key in. Also pouch caches database objects on their name only, changed this to use the full options, ie. also the encryption key.
Now a have basic operation with pouch and sqlcipher working (can put and get objects), however queries fail (both temporary and persistent). Any ideas how to make this work or hints how to fix it?

Windows: error C4996: 'fopen': This function or variable may be unsafe.

c:\temp\sqlcipher\plugins\cordova-sqlcipher-adapter\src\common\sqlite3.c(17959): error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_S ECURE_NO_WARNINGS. See online help for details. [C:\temp\sqlCipher\plugins\cordova-sqlcipher-adapter\src\windows\SQLite3-Win-RT\SQLite3\SQLite3.UWP\SQLite3.UWP.vcxproj]

Looks like this is due to the following change

af3d1ed

Windows build fails due to incorrect dep references

λ cordova --version
6.2.0
λ cordova platforms
  windows 4.3.2
C:\temp\sqlCipher
λ cordova build windows --archs=x86
Building project: C:\temp\sqlCipher\platforms\windows\CordovaApp.Windows.jsproj
        Configuration : debug
        Platform      : x86
  pch.cpp
  Constants.cpp
  Database.cpp
  Statement.cpp
c:\temp\sqlcipher\plugins\cordova-sqlcipher-adapter\src\windows\sqlite3-win-rt\sqlite3\database.cpp(57): warning C4244: 'return' : conversion from 'sqlite3_int64' to 'int', possible loss of data [C:\temp\sqlCip her\plugins\cordova-sqlcipher-adapter\src\windows\SQLite3-Win-RT\SQLite3\SQLite3.Windows\SQLite3.Windows.vcxproj]
  sqlite3.c
  cbc_encrypt.c
  cbc_decrypt.c
  cbc_start.c
  cbc_done.c
  crypt_find_cipher.c
  crypt_find_hash.c
  crypt_register_hash.c
c1 : fatal error C1083: Cannot open source file: 'C:\temp\sqlCipher\plugins\cordova-sqlcipher-adapter\src\external\common\sqlite3.c': No such file or directory [C:\temp\sqlCipher\plugins\cordova-sqlcipher-adapt er\src\windows\SQLite3-Win-RT\SQLite3\SQLite3.Windows\SQLite3.Windows.vcxproj]
c1 : fatal error C1083: Cannot open source file: 'C:\temp\sqlCipher\plugins\cordova-sqlcipher-adapter\src\external\libTomCrypt\crypt_find_hash.c': No such file or directory [C:\temp\sqlCipher\plugins\cordova-sq lcipher-adapter\src\windows\SQLite3-Win-RT\SQLite3\SQLite3.Windows\SQLite3.Windows.vcxproj]
c1 : fatal error C1083: Cannot open source file: 'C:\temp\sqlCipher\plugins\cordova-sqlcipher-adapter\src\external\libTomCrypt\crypt_find_cipher.c': No such file or directory [C:\temp\sqlCipher\plugins\cordova- sqlcipher-adapter\src\windows\SQLite3-Win-RT\SQLite3\SQLite3.Windows\SQLite3.Windows.vcxproj]
c1 : fatal error C1083: Cannot open source file: 'C:\temp\sqlCipher\plugins\cordova-sqlcipher-adapter\src\external\libTomCrypt\crypt_register_hash.c': No such file or directory [C:\temp\sqlCipher\plugins\cordov a-sqlcipher-adapter\src\windows\SQLite3-Win-RT\SQLite3\SQLite3.Windows\SQLite3.Windows.vcxproj]
c1 : fatal error C1083: Cannot open source file: 'C:\temp\sqlCipher\plugins\cordova-sqlcipher-adapter\src\external\libTomCrypt\cbc_encrypt.c': No such file or directory [C:\temp\sqlCipher\plugins\cordova-sqlcip her-adapter\src\windows\SQLite3-Win-RT\SQLite3\SQLite3.Windows\SQLite3.Windows.vcxproj]
c1 : fatal error C1083: Cannot open source file: 'C:\temp\sqlCipher\plugins\cordova-sqlcipher-adapter\src\external\libTomCrypt\cbc_done.c': No such file or directory [C:\temp\sqlCipher\plugins\cordova-sqlcipher -adapter\src\windows\SQLite3-Win-RT\SQLite3\SQLite3.Windows\SQLite3.Windows.vcxproj]
c1 : fatal error C1083: Cannot open source file: 'C:\temp\sqlCipher\plugins\cordova-sqlcipher-adapter\src\external\libTomCrypt\cbc_start.c': No such file or directory [C:\temp\sqlCipher\plugins\cordova-sqlciphe r-adapter\src\windows\SQLite3-Win-RT\SQLite3\SQLite3.Windows\SQLite3.Windows.vcxproj]
c1 : fatal error C1083: Cannot open source file: 'C:\temp\sqlCipher\plugins\cordova-sqlcipher-adapter\src\external\libTomCrypt\cbc_decrypt.c': No such file or directory [C:\temp\sqlCipher\plugins\cordova-sqlcip her-adapter\src\windows\SQLite3-Win-RT\SQLite3\SQLite3.Windows\SQLite3.Windows.vcxproj]
...
Error: C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe: Command failed with exit code 1

libTomCrypt is stored in src\windows\ but the plugin expects it to be in src\external\ folder.

Android Nougat: Detected problems with app native libraries

Hi,

we just upgrade our Nexus 9 to Android N and now get the following popup while working with our app:

libraryproblem

The log file says:
08-30 09:06:58.573: W/linker(3898): library "libutils.so" ("/system/lib/libutils.so") needed or dlopened by "/data/app/de.ergovia.our.app/lib/arm/libsqlcipher_android.so" is not accessible for the namespace "classloader-namespace" - the access is temporarily granted as a workaround for http://b/26394120, note that the access will be removed in future releases of Android.

The changelog paragraph "NDK Apps Linking to Platform Libraries" has some info about this matter.

Nougat is still very fresh, just thinking this information may be of some value to you.
thx for looking into this :)

The app is working flawlessly apart from the popup ;)

Check if encrypted database exists while locked

Hi Chris,
This is a great plugin, Thanks!

I'm using sqlcipher and I want to determine (without the key) if a database has been created so that if the DB is closed or if the app restarts I can present the relevant UI to the user i.e. create password if no DB exists yet or login/forgot passcode if the DB does exist but it's closed.

I assume the only way to test this without the key is to determine if a DB file exists. I've read through some of the posts relating to DB file location e.g. storesafe/cordova-sqlite-storage#223 but the file locations mentioned here don't seem work.

on iOS I've tried -
window.resolveLocalFileSystemURL("cdvfile://localhost/persistent/<database.name>" and
window.resolveLocalFileSystemURL(cordova.file.applicationStorageDirectory + "/<database.name>" but neither return a success callback.

You mention the location is or will be noted in the readme but I can't seem to find it.

Is there a set location for the DB file or can it be determined?

If there's an alternative way of checking if a closed DB exists could you point me in the right direction?

I would need to determine this for both iOS and Android platforms

Any help would be appreciated.

Thanks

Ryan

Is 64bit CPU suppored [Android]?

Hi!
Like in the title, I want to know if the 64bit architectures are supported now? (x86_64 and arm64).
From your repo status description:

SQLCipher 3.5.6 for Android built from brodybits / android-database-sqlcipher-build-fix, now with 64-bit CPU support

NOTE: 64-bit CPUs such as x64_64, ARM-64, and MIPS are currently not supported by the SQLCipher for Android build (support for these CPUs is for future consideration).

Which statement is true for now?

Error: EXDEV, cross-device link not permitted

Hi, I am getting this error message when trying to install the plugin on windows

E:/myproject> cordova plugin add https://github.com/litehelpers/Cordova-sqlcipher-adapter

Fetching plugin "https://github.com/litehelpers/Cordova-sqlcipher-adapter" via git clone
Repository "https://github.com/litehelpers/Cordova-sqlcipher-adapter" checked out to git ref "master".
shell.js: internal error
Error: EXDEV, cross-device link not permitted 'C:\Users\SMAIRA~1.IO-\AppData\Local\Temp\git\1435577873838\AUTHORS.md'
at Error (native)
at Object.fs.renameSync (fs.js:636:18)
at C:\Users\sm\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\shelljs\src\mv.js:77:8
at Array.forEach (native)
at Object._mv (C:\Users\sm\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\shelljs\src\mv.js:53:11)
at Object.mv (C:\Users\sm\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\shelljs\src\common.js:186:23)
at C:\Users\sm\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\plugman\util\plugins.js:53:19
at _fulfilled (C:\Users\sm\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:787:54)
at self.promiseDispatch.done (C:\Users\sm\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:816:30)
at Promise.promise.promiseDispatch (C:\Users\sm\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:749:13)

transaction callbacks are never called [in case of invalid db handle]

Hi,
i just exchanged the SQLitePlugin (1.0.6) with the SQLCipher-Adaptor in my project via "cordova plugin add ...". Then i added the "key-parameter to the openDatabase(). Now neither the success- nor the error-callback of the transaction are called. Has something changed here?

My code:
var db = window.sqlitePlugin.openDatabase({name: "mydb", key: "your-password-here"});
db.transaction(create, error, success);

with create, error and success being proper functions.

Thank you!

Pre-populate sqlcipher database

The README states 'Pre-populatd DB is NOT supported by this version.' (Thanks for documenting this upfront)

Is there a technical reason why this isn't supported? Would it be insecure or infeasible to implement this feature?

I want to bundle app content in a pre-populated database, but I want to make it a little more difficult for someone to steal our content than simply unzipping the apk.

How to test the success of encryption

Hi,
How do we check the success of encryption? In other words how can be sure that the data is encrypted after using this plugin?

When we try to access the database of the android device under WebSQL through chrome:inspect, we do not see any encrypted database, but we see nothing at all under WebSQL.

We expected to see a database under WebSQL with tables, having encrypted data. Since the data is encrypted we don't see anything - that is fine. But how can we be sure that the data is encrypted and not simply hidden.

Kindly help.

Thanks.

get field slot from row 0 col 0 failed

I am storing data in which one of the column is blob with big data.
I am getting below error while trying to retrieve the data in android.

get field slot from row 0 col 0 failed

Can you please help me with it.

PouchDB is not opening sqlite db with encryption support.

Hi,
Main document for the sqlcipher plugin indicates the pouchdb is working this adaptor is part of pouchdb and thanks to nolanlawson who made it work. Based on this, I am trying the following code and PouchDB is not opening db as encrypted and displayed the following on console.

OPEN database: _pouch_userDB.txt
open full db path: /var/mobile/Containers/Data/Application/99BA28C6-03BB-4636-9224-9EF708B79C94/Documents/_pouch_userDB.db
Open DB with NO encryption

Here is the code !

      var db2 = new PouchDB('userDB.db', {adapter: 'websql', key: 'password'});
      db2.info().then(console.log.bind(console));
      db2.put({_id: '1', name: 'username'})
        .then(usr => {
          console.log(`${usr} saved`);
        }).
        catch(ex=> {
          console.log(`${ex} occurred`)
        });

Where as the following works fine in the same app

      var db = window.sqlitePlugin.openDatabase({name: "my.db", key: "your-password-here"});
      db.transaction(function (tx) {
        tx.executeSql('DROP TABLE IF EXISTS test_table');
        tx.executeSql('CREATE TABLE IF NOT EXISTS test_table (id integer primary key, data text, data_num integer)');

        tx.executeSql("INSERT INTO test_table (data, data_num) VALUES (?,?)", ["test", 100], function (tx, res) {
          console.log("insertId: " + res.insertId + " -- probably 1");
          console.log("rowsAffected: " + res.rowsAffected + " -- should be 1");

          tx.executeSql("select count(id) as cnt from test_table;", [], function (tx, res) {
            console.log("res.rows.length: " + res.rows.length + " -- should be 1");
            console.log("res.rows.item(0).cnt: " + res.rows.item(0).cnt + " -- should be 1");
          });

        }, function (e) {
          console.log("ERROR: " + e.message);
        });
      });

And here is the console output!

OPEN database: my.db
open full db path: /var/mobile/Containers/Data/Application/99BA28C6-03BB-4636-9224-9EF708B79C94/Documents/my.db
Open DB with encryption

It will be really helpful if someone please point out the mistake. What am I missing to pass to PouchDB constructor ?

Replace libTomCrypt with OpenSSL crypto library in Windows version

SQLCipher was originally designed to use the crypto library from OpenSSL to do the actual encryption but can now use multiple encryption libraries: OpenSSL libcrypto, Apple Security framework, or libTomCrypt. It is desired to replace libTomCrypt with the OpenSSL crypto library built for Windows.

I think it is desired to rebuild the crypto library from scratch instead of relying on a crypto library that may (or may not) be installed. We will never know if different Windows OS installations may have different crypto builds, or no crypto build in certain cases. The SQLCipher project encountered these issues with Android devices in the past.

It is highly recommended to follow how the build is done in the script at: https://github.com/sqlcipher/android-database-sqlcipher/blob/master/build-openssl-libraries.sh

I am not sure whether it would work better to have the OpenSSL crypto build done by the *.vcxproj files provided by this plugin or to invoke the build manually and then ship the build library with this project. I suspect it would be the second.

I have an improvement: Type check on constructor object.

Hello,
I was searching for a bug a very long time, and I think this is a huge pitfall the JS community can meet here.

Simple: I had a number as password and there was no error, instead there was nothing.
Only appears on IOS.

Suggestion:

SQLitePlugin.prototype.open = function (success, error) {
  ....
  /*
  If this.openargs has any wrong types, the plugin wont give a callback.
  In my case the password was a number, caused by an encryption lib I was using it returned a number which I used to encrypt.

  Right above this comment there could be a type check, which would remove this pitfall.
  */
  cordova.exec(opensuccesscb, openerrorcb, "SQLitePlugin", "open", [this.openargs]);
  ....
};

Could not open database

My code is
var db = window.sqlitePlugin.openDatabase({name: "d2a.db", location: 1},function(success){ console.log(success); },function(error){ console.log(error); });

My log is below:
new transaction is waiting for open operation
plugins/cordova-sqlite-storage/www/SQLitePlugin.js:197 OPEN database: d2a.db FAILED, aborting any pending transactions
static/js/d2a-sqlite.js:148 Error: Could not open database
at newSQLError (plugins/cordova-sqlite-storage/www/SQLitePlugin.js:26)
at plugins/cordova-sqlite-storage/www/SQLitePlugin.js:199
at Object.callbackFromNative (cordova.js:295)
at :1:9
static/js/d2a-sqlite.js:194 transaction error: Invalid database handle

Check if db name is a string [Name of the database on android contains the key]

I have looked at where the database is stored on android and to my surprise the file name is the whole object passed as the argument on opening the database, it is for command
var db = window.sqlitePlugin.openDatabase({name: "my.db", key: "your-password-here", location: 1});

the name of the file containing the database is
{name: "my.db", key: "your-password-here", location: 1}

instead of my.db I expected. Exposing the key this way makes the encryption useless.

The same applies to the sqlite plugin, the file name is again the whole json jstring.

Incorrect [rowsAffected cases] on Android

From storesafe/cordova-sqlite-storage#458: this will affect this version on Android since SQLCipher for Android is using a version of the AOSP (Android) SQLite database classes. The solution would be to use Android-sqlite-connector with the native driver libraries built with SQLCipher. [Incorrect insertId/rowsAffected in case of extra semicolon before SQL on Android]

How to change db password

I want to change db password but no command to do it.
I found code in SQLiteDatabase class have changePassword method, How can i use changePassword in JS/Cordova

It can not open database

I've tried to open database which does not exist in order to create it

var sql = 'CREATE TABLE DataM (Name VARCHAR (100) NOT NULL, Price DECIMAL NOT NULL, Quantity INT NOT NULL, Date DATETIME NOT NULL)';
var db = window.sqlitePlugin.openDatabase({name: 'Waste.db', key: 'password', location: 'default'});
db.transaction(function(tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS DataM (Name, Price, Quantity, Date');
tx.executeSql('SELECT Count(*) FROM DataM', []);
//tx.executeSql('INSERT INTO DemoTable VALUES (?,?)', ['Betty', 202]);
}, function(error) {
console.log('Transaction ERROR: ' + error.message);
}, function() {
console.log('Populated database OK');
});

And there is error
OPEN database: Waste.db
SQLitePlugin.js:106 new transaction is waiting for open operation
SQLitePlugin.js:197 OPEN database: Waste.db FAILED, aborting any pending transactions
SQLitePlugin.js:83 Could not open database
add.js:49 Transaction ERROR: Invalid database handle

Is there a way to re-encode the existing database (with a new key)?

I am currently working on a password enabled app in which the data is only visible if the password is correct. I would like to be able to write a recover password feature, which would (at the end of the logical flow) re-encode the database with a NEW passkey.

I couldn't see an option on the page, but wanted to double check. I suspect I may have to do this manually, but wanted to ask.

WKWebView incompatible

The older engine on iOS using UIWebKit which is fine but it's slow on Cordova apps. I'm about upgrading the new iOS engine called WKWebView which can reduce 50-80% memory usage. However, the big issue is I can't open SQLite db anymore. Anyone can tell me if you're successful using this plugin to open the db?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.