@capacitor-community/sqlite 4.6.1 → 4.6.2-2

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.
@@ -606,6 +606,34 @@ enum CapacitorSQLiteError: Error {
606
606
  }
607
607
  }
608
608
 
609
+ // MARK: - IsDatabaseEncrypted
610
+
611
+ @objc public func isDatabaseEncrypted(_ dbName: String) throws -> NSNumber {
612
+ if isInit {
613
+ let mDbName = CapacitorSQLite.getDatabaseName(dbName: dbName)
614
+ let isFileExists: Bool = UtilsFile
615
+ .isFileExist(databaseLocation: databaseLocation,
616
+ fileName: mDbName + "SQLite.db")
617
+ if isFileExists {
618
+ let state: State = UtilsSQLCipher
619
+ .getDatabaseState(databaseLocation: databaseLocation,
620
+ databaseName: mDbName + "SQLite.db",
621
+ account: account)
622
+ if state.rawValue == "ENCRYPTEDGLOBALSECRET" || state.rawValue == "ENCRYPTEDSECRET" {
623
+ return 1;
624
+ }
625
+ if state.rawValue == "UNENCRYPTED" {
626
+ return 0;
627
+ }
628
+ throw CapacitorSQLiteError.failed(message: "Database unknown")
629
+ } else {
630
+ throw CapacitorSQLiteError.failed(message: "Database does not exist")
631
+ }
632
+ } else {
633
+ throw CapacitorSQLiteError.failed(message: initMessage)
634
+ }
635
+ }
636
+
609
637
  // MARK: - IsNCDatabase
610
638
 
611
639
  @objc public func isNCDatabase(_ databasePath: String) throws -> NSNumber {
@@ -46,4 +46,7 @@ CAP_PLUGIN(CapacitorSQLitePlugin, "CapacitorSQLite",
46
46
  CAP_PLUGIN_METHOD(clearEncryptionSecret, CAPPluginReturnPromise);
47
47
  CAP_PLUGIN_METHOD(getFromHTTPRequest, CAPPluginReturnPromise);
48
48
  CAP_PLUGIN_METHOD(checkEncryptionSecret, CAPPluginReturnPromise);
49
+ CAP_PLUGIN_METHOD(isInConfigEncryption, CAPPluginReturnPromise);
50
+ CAP_PLUGIN_METHOD(isInConfigBiometricAuth, CAPPluginReturnPromise);
51
+ CAP_PLUGIN_METHOD(isDatabaseEncrypted, CAPPluginReturnPromise);
49
52
  )
@@ -41,6 +41,56 @@ public class CapacitorSQLitePlugin: CAPPlugin {
41
41
  }
42
42
  }
43
43
 
44
+ // MARK: - IsInConfigEncryption
45
+
46
+ @objc func isInConfigEncryption(_ call: CAPPluginCall) {
47
+ var bRes: Bool = false
48
+ if self.config?.iosIsEncryption == 1 {
49
+ bRes = true
50
+ }
51
+
52
+ retHandler.rResult(call: call, ret: bRes)
53
+ }
54
+
55
+ // MARK: - IsInConfigBiometricAuth
56
+
57
+ @objc func isInConfigBiometricAuth(_ call: CAPPluginCall) {
58
+ var bRes: Bool = false
59
+ if self.config?.biometricAuth == 1 {
60
+ bRes = true
61
+ }
62
+
63
+ retHandler.rResult(call: call, ret: bRes)
64
+ }
65
+ // MARK: - IsDatabaseEncrypted
66
+
67
+ @objc func isDatabaseEncrypted(_ call: CAPPluginCall) {
68
+ guard let dbName = call.options["database"] as? String else {
69
+ retHandler.rResult(
70
+ call: call, ret: false,
71
+ message: "isDatabaseEncrypted: Must provide a database name")
72
+ return
73
+ }
74
+ do {
75
+ let res = try implementation?.isDatabaseEncrypted(dbName)
76
+ var bRes: Bool = false
77
+ if res == 1 {
78
+ bRes = true
79
+ }
80
+ retHandler.rResult(call: call, ret: bRes)
81
+ } catch CapacitorSQLiteError.failed(let message) {
82
+ let msg = "isDatabaseEncrypted: \(message)"
83
+ retHandler.rResult(call: call, message: msg)
84
+ return
85
+ } catch let error {
86
+ retHandler.rResult(
87
+ call: call,
88
+ message: "isDatabaseEncrypted: \(error)")
89
+ return
90
+ }
91
+
92
+ }
93
+
44
94
  // MARK: - IsSecretStored
45
95
 
46
96
  @objc func isSecretStored(_ call: CAPPluginCall) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor-community/sqlite",
3
- "version": "4.6.1",
3
+ "version": "4.6.2-2",
4
4
  "description": "Community plugin for native & electron SQLite databases",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -10,6 +10,7 @@
10
10
  "android/src/main/",
11
11
  "android/build.gradle",
12
12
  "dist/",
13
+ "src/",
13
14
  "ios/Plugin/",
14
15
  "electron/",
15
16
  "CapacitorCommunitySqlite.podspec"
@@ -55,10 +56,10 @@
55
56
  "prepublishOnly": "npm run build && npm run build-electron && npm run docgen"
56
57
  },
57
58
  "devDependencies": {
58
- "@capacitor/android": "^4.6.1",
59
- "@capacitor/core": "^4.6.1",
59
+ "@capacitor/android": "^4.6.2",
60
+ "@capacitor/core": "^4.6.2",
60
61
  "@capacitor/docgen": "^0.0.17",
61
- "@capacitor/ios": "^4.6.1",
62
+ "@capacitor/ios": "^4.6.2",
62
63
  "@ionic/eslint-config": "^0.3.0",
63
64
  "@ionic/prettier-config": "^1.0.1",
64
65
  "@ionic/swiftlint-config": "^1.1.2",