@op-engineering/op-sqlite 14.1.2 → 14.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -276,7 +276,7 @@ dependencies {
276
276
  implementation 'com.facebook.react:react-native'
277
277
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
278
278
  if (useSQLCipher) {
279
- implementation('io.github.ronickg:openssl:3.3.2')
279
+ implementation('io.github.ronickg:openssl:3.3.2-1')
280
280
  }
281
281
  }
282
282
 
@@ -157,13 +157,15 @@ DBHostObject::DBHostObject(jsi::Runtime &rt,
157
157
  std::string &db_name, std::string &path,
158
158
  std::string &url, std::string &auth_token,
159
159
  int sync_interval, bool offline,
160
- std::string &encryption_key)
160
+ std::string &encryption_key,
161
+ std::string &remote_encryption_key)
161
162
  : db_name(db_name), invoker(std::move(invoker)), rt(rt) {
162
163
 
163
164
  _thread_pool = std::make_shared<ThreadPool>();
164
165
 
165
166
  db = opsqlite_libsql_open_sync(db_name, path, url, auth_token,
166
- sync_interval, offline, encryption_key);
167
+ sync_interval, offline, encryption_key,
168
+ remote_encryption_key);
167
169
 
168
170
  create_jsi_functions();
169
171
  }
@@ -59,7 +59,8 @@ class JSI_EXPORT DBHostObject : public jsi::HostObject {
59
59
  DBHostObject(jsi::Runtime &rt, std::shared_ptr<react::CallInvoker> invoker,
60
60
  std::string &db_name, std::string &path, std::string &url,
61
61
  std::string &auth_token, int sync_interval, bool offline,
62
- std::string &encryption_key);
62
+ std::string &encryption_key,
63
+ std::string &remote_encryption_key);
63
64
  #endif
64
65
 
65
66
  std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime &rt) override;
package/cpp/bindings.cpp CHANGED
@@ -150,6 +150,12 @@ void install(jsi::Runtime &rt,
150
150
  options.getProperty(rt, "encryptionKey").asString(rt).utf8(rt);
151
151
  }
152
152
 
153
+ std::string remote_encryption_key;
154
+ if (options.hasProperty(rt, "remoteEncryptionKey")) {
155
+ encryption_key =
156
+ options.getProperty(rt, "remoteEncryptionKey").asString(rt).utf8(rt);
157
+ }
158
+
153
159
  std::string location;
154
160
  if (options.hasProperty(rt, "location")) {
155
161
  location =
@@ -166,7 +172,7 @@ void install(jsi::Runtime &rt,
166
172
  }
167
173
 
168
174
  std::shared_ptr<DBHostObject> db = std::make_shared<DBHostObject>(
169
- rt, invoker, name, path, url, auth_token, sync_interval, offline, encryption_key);
175
+ rt, invoker, name, path, url, auth_token, sync_interval, offline, encryption_key, remote_encryption_key);
170
176
  return jsi::Object::createFromHostObject(rt, db);
171
177
  });
172
178
  #endif
package/cpp/bridge.cpp CHANGED
@@ -850,7 +850,7 @@ opsqlite_execute_batch(sqlite3 *db,
850
850
  }
851
851
 
852
852
  int affectedRows = 0;
853
- opsqlite_execute(db, "BEGIN EXCLUSIVE TRANSACTION", nullptr);
853
+ // opsqlite_execute(db, "BEGIN EXCLUSIVE TRANSACTION", nullptr);
854
854
  for (int i = 0; i < commandCount; i++) {
855
855
  const auto &command = commands->at(i);
856
856
  // We do not provide a datastructure to receive query data because we
@@ -863,7 +863,7 @@ opsqlite_execute_batch(sqlite3 *db,
863
863
  throw exc;
864
864
  }
865
865
  }
866
- opsqlite_execute(db, "COMMIT", nullptr);
866
+ // opsqlite_execute(db, "COMMIT", nullptr);
867
867
  return BatchResult{
868
868
  .affectedRows = affectedRows,
869
869
  .commands = static_cast<int>(commandCount),
@@ -40,7 +40,8 @@ DB opsqlite_libsql_open_sync(std::string const &name,
40
40
  std::string const &base_path,
41
41
  std::string const &url,
42
42
  std::string const &auth_token, int sync_interval,
43
- bool offline, std::string const &encryption_key) {
43
+ bool offline, std::string const &encryption_key,
44
+ std::string const &remote_encryption_key) {
44
45
  std::string path = opsqlite_get_db_path(name, base_path);
45
46
 
46
47
  int status;
@@ -53,6 +54,7 @@ DB opsqlite_libsql_open_sync(std::string const &name,
53
54
  .auth_token = auth_token.c_str(),
54
55
  .read_your_writes = '1',
55
56
  .encryption_key = encryption_key.c_str(),
57
+ .remote_encryption_key = remote_encryption_key.c_str(),
56
58
  .sync_interval = sync_interval,
57
59
  .with_webpki = '1',
58
60
  .offline = offline};
@@ -716,7 +718,7 @@ opsqlite_libsql_execute_batch(DB const &db,
716
718
 
717
719
  try {
718
720
  int affectedRows = 0;
719
- opsqlite_libsql_execute(db, "BEGIN EXCLUSIVE TRANSACTION", nullptr);
721
+ // opsqlite_libsql_execute(db, "BEGIN EXCLUSIVE TRANSACTION", nullptr);
720
722
  for (int i = 0; i < commandCount; i++) {
721
723
  auto command = commands->at(i);
722
724
  // We do not provide a datastructure to receive query data because
@@ -725,13 +727,13 @@ opsqlite_libsql_execute_batch(DB const &db,
725
727
  opsqlite_libsql_execute(db, command.sql, &command.params);
726
728
  affectedRows += result.affectedRows;
727
729
  }
728
- opsqlite_libsql_execute(db, "COMMIT", nullptr);
730
+ // opsqlite_libsql_execute(db, "COMMIT", nullptr);
729
731
  return BatchResult{
730
732
  .affectedRows = affectedRows,
731
733
  .commands = static_cast<int>(commandCount),
732
734
  };
733
735
  } catch (std::exception &exc) {
734
- opsqlite_libsql_execute(db, "ROLLBACK", nullptr);
736
+ // opsqlite_libsql_execute(db, "ROLLBACK", nullptr);
735
737
  return BatchResult{
736
738
  .message = exc.what(),
737
739
  };
@@ -41,7 +41,8 @@ DB opsqlite_libsql_open_remote(std::string const &url,
41
41
  DB opsqlite_libsql_open_sync(std::string const &name, std::string const &path,
42
42
  std::string const &url,
43
43
  std::string const &auth_token, int sync_interval,
44
- bool offline, std::string const &encryption_key);
44
+ bool offline, std::string const &encryption_key,
45
+ std::string const &remote_encryption_key);
45
46
 
46
47
  void opsqlite_libsql_close(DB &db);
47
48
 
@@ -41,6 +41,7 @@ typedef struct {
41
41
  int sync_interval;
42
42
  char with_webpki;
43
43
  char offline;
44
+ const char *remote_encryption_key;
44
45
  } libsql_config;
45
46
 
46
47
  typedef const libsql_connection *libsql_connection_t;