@capgo/capacitor-fast-sql 8.0.26 → 8.0.31

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.
@@ -10,10 +10,19 @@ Pod::Spec.new do |s|
10
10
  s.homepage = package['repository']['url']
11
11
  s.author = package['author']
12
12
  s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
- s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
14
13
  s.ios.deployment_target = '15.0'
15
- s.dependency 'Capacitor'
16
- s.dependency 'Telegraph', '~> 0.30'
17
- s.dependency 'SQLCipher', '~> 4.10'
18
14
  s.swift_version = '5.1'
15
+ s.default_subspecs = 'Core'
16
+
17
+ s.subspec 'Core' do |ss|
18
+ ss.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
19
+ ss.dependency 'Capacitor'
20
+ ss.dependency 'Telegraph', '~> 0.30'
21
+ end
22
+
23
+ # Optional encryption support. Include this subspec to enable SQLCipher.
24
+ s.subspec 'SQLCipher' do |ss|
25
+ ss.dependency 'CapgoCapacitorFastSql/Core'
26
+ ss.dependency 'SQLCipher', '~> 4.10'
27
+ end
19
28
  end
package/README.md CHANGED
@@ -103,7 +103,9 @@ Then reference it in your `AndroidManifest.xml`:
103
103
  </application>
104
104
  ```
105
105
 
106
- ## Encryption (Android)
106
+ ## Encryption
107
+
108
+ ### Android
107
109
 
108
110
  Encryption uses [SQLCipher](https://www.zetetic.net/sqlcipher/) and is opt-in. Add the SQLCipher dependency to your **app-level** `build.gradle`:
109
111
 
@@ -125,6 +127,18 @@ const db = await FastSQL.connect({
125
127
 
126
128
  If SQLCipher is not installed and `encrypted: true` is passed, the plugin returns a clear error message instead of crashing.
127
129
 
130
+ ### iOS
131
+
132
+ SQLCipher is optional on iOS. The plugin builds without it; encryption calls will return `Encryption is not available in this build` unless SQLCipher is installed.
133
+
134
+ To enable encryption via CocoaPods, update your `ios/App/Podfile` after `capacitor install`/`cap sync` to use the SQLCipher subspec:
135
+
136
+ ```ruby
137
+ pod 'CapgoCapacitorFastSql/SQLCipher', :path => '../../node_modules/@capgo/capacitor-fast-sql'
138
+ ```
139
+
140
+ Then run `pod install` in the `ios/App` directory. If you skip this subspec, keep `encrypted: false`.
141
+
128
142
  ## Web Platform
129
143
 
130
144
  On the web, this plugin uses [sql.js](https://sql.js.org/) (SQLite compiled to WebAssembly) with IndexedDB for persistence.
@@ -54,7 +54,7 @@ dependencies {
54
54
  implementation 'androidx.sqlite:sqlite:2.6.2'
55
55
  implementation 'com.google.code.gson:gson:2.13.2'
56
56
  implementation 'org.nanohttpd:nanohttpd:2.3.1'
57
- compileOnly 'net.zetetic:sqlcipher-android:4.14.0'
57
+ compileOnly 'net.zetetic:sqlcipher-android:4.14.1'
58
58
  testImplementation "junit:junit:$junitVersion"
59
59
  androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
60
60
  androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
@@ -19,7 +19,7 @@ import java.util.Map;
19
19
  @CapacitorPlugin(name = "CapgoCapacitorFastSql")
20
20
  public class CapgoCapacitorFastSqlPlugin extends Plugin {
21
21
 
22
- private final String pluginVersion = "8.0.26";
22
+ private final String pluginVersion = "8.0.31";
23
23
 
24
24
  private Map<String, DatabaseConnection> databases = new HashMap<>();
25
25
  private SQLHTTPServer server;
@@ -8,7 +8,9 @@ import com.google.gson.JsonElement;
8
8
  import com.google.gson.JsonObject;
9
9
  import com.google.gson.JsonParser;
10
10
  import fi.iki.elonen.NanoHTTPD; // Note: org.nanohttpd:nanohttpd:2.3.1 still uses fi.iki.elonen package
11
+ import java.io.DataInputStream;
11
12
  import java.io.IOException;
13
+ import java.nio.charset.StandardCharsets;
12
14
  import java.security.SecureRandom;
13
15
  import java.util.Map;
14
16
  import java.util.concurrent.ExecutionException;
@@ -105,11 +107,11 @@ public class SQLHTTPServer extends NanoHTTPD {
105
107
  } else if (method == Method.POST && uri.equals("/batch")) {
106
108
  return addCorsHeaders(handleBatch(session, db));
107
109
  } else if (method == Method.POST && uri.equals("/transaction/begin")) {
108
- return addCorsHeaders(handleBeginTransaction(db));
110
+ return addCorsHeaders(handleBeginTransaction(session, db));
109
111
  } else if (method == Method.POST && uri.equals("/transaction/commit")) {
110
- return addCorsHeaders(handleCommitTransaction(db));
112
+ return addCorsHeaders(handleCommitTransaction(session, db));
111
113
  } else if (method == Method.POST && uri.equals("/transaction/rollback")) {
112
- return addCorsHeaders(handleRollbackTransaction(db));
114
+ return addCorsHeaders(handleRollbackTransaction(session, db));
113
115
  } else {
114
116
  return addCorsHeaders(newFixedLengthResponse(Response.Status.NOT_FOUND, "text/plain", "Endpoint not found"));
115
117
  }
@@ -204,17 +206,20 @@ public class SQLHTTPServer extends NanoHTTPD {
204
206
  return newFixedLengthResponse(Response.Status.OK, "application/json", results.toString());
205
207
  }
206
208
 
207
- private Response handleBeginTransaction(DatabaseConnection db) throws Exception {
209
+ private Response handleBeginTransaction(IHTTPSession session, DatabaseConnection db) throws Exception {
210
+ readRequestBody(session); // drain any body to keep the connection clean for keep-alive
208
211
  db.beginTransaction();
209
212
  return newFixedLengthResponse(Response.Status.OK, "application/json", "{}");
210
213
  }
211
214
 
212
- private Response handleCommitTransaction(DatabaseConnection db) throws Exception {
215
+ private Response handleCommitTransaction(IHTTPSession session, DatabaseConnection db) throws Exception {
216
+ readRequestBody(session); // drain any body to keep the connection clean for keep-alive
213
217
  db.commitTransaction();
214
218
  return newFixedLengthResponse(Response.Status.OK, "application/json", "{}");
215
219
  }
216
220
 
217
- private Response handleRollbackTransaction(DatabaseConnection db) throws Exception {
221
+ private Response handleRollbackTransaction(IHTTPSession session, DatabaseConnection db) throws Exception {
222
+ readRequestBody(session); // drain any body to keep the connection clean for keep-alive
218
223
  db.rollbackTransaction();
219
224
  return newFixedLengthResponse(Response.Status.OK, "application/json", "{}");
220
225
  }
@@ -222,8 +227,8 @@ public class SQLHTTPServer extends NanoHTTPD {
222
227
  private String readRequestBody(IHTTPSession session) throws IOException {
223
228
  int contentLength = Integer.parseInt(session.getHeaders().get("content-length"));
224
229
  byte[] buffer = new byte[contentLength];
225
- session.getInputStream().read(buffer, 0, contentLength);
226
- return new String(buffer);
230
+ new DataInputStream(session.getInputStream()).readFully(buffer);
231
+ return new String(buffer, StandardCharsets.UTF_8);
227
232
  }
228
233
 
229
234
  private static String generateToken() {
@@ -10,7 +10,7 @@ import SQLite3
10
10
  */
11
11
  @objc(CapgoCapacitorFastSqlPlugin)
12
12
  public class CapgoCapacitorFastSqlPlugin: CAPPlugin, CAPBridgedPlugin {
13
- private let pluginVersion: String = "8.0.26"
13
+ private let pluginVersion: String = "8.0.31"
14
14
  public let identifier = "CapgoCapacitorFastSqlPlugin"
15
15
  public let jsName = "CapgoCapacitorFastSql"
16
16
  public let pluginMethods: [CAPPluginMethod] = [
@@ -270,7 +270,7 @@ extension SQLError: LocalizedError {
270
270
  case .encryptionKeyMissing:
271
271
  return "Encryption key is required when encryption is enabled"
272
272
  case .encryptionUnavailable:
273
- return "Encryption is not available in this build"
273
+ return "Encryption is not available in this build. Add SQLCipher to enable encryption."
274
274
  case .encryptionFailed(let message):
275
275
  return "Failed to set encryption key: \(message)"
276
276
  case .transactionAlreadyActive:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-fast-sql",
3
- "version": "8.0.26",
3
+ "version": "8.0.31",
4
4
  "description": "High-performance native SQLite plugin with custom protocol for efficient sync operations and IndexedDB replacement",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",