@capacitor-community/sqlite 3.5.1-1 → 3.5.2-dev1
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.
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLite.java +19 -0
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLitePlugin.java +24 -0
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/UtilsJson.java +1 -1
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsSecret.java +21 -0
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsUpgrade.java +1 -1
- package/dist/esm/definitions.d.ts +14 -0
- package/dist/esm/definitions.js +9 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +1 -0
- package/dist/esm/web.js +4 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +13 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +13 -0
- package/dist/plugin.js.map +1 -1
- package/electron/dist/plugin.js +30 -7
- package/electron/dist/plugin.js.map +1 -1
- package/ios/Plugin/CapacitorSQLite.swift +26 -0
- package/ios/Plugin/CapacitorSQLitePlugin.m +1 -0
- package/ios/Plugin/CapacitorSQLitePlugin.swift +20 -0
- package/ios/Plugin/Utils/UtilsJson.swift +2 -2
- package/ios/Plugin/Utils/UtilsSQLCipher.swift +5 -1
- package/ios/Plugin/Utils/UtilsSecret.swift +20 -1
- package/package.json +3 -3
|
@@ -231,6 +231,32 @@ enum CapacitorSQLiteError: Error {
|
|
|
231
231
|
// swiftlint:enable no_space_in_method_call
|
|
232
232
|
// swiftlint:enable function_body_length
|
|
233
233
|
|
|
234
|
+
// MARK: - ClearEncryptionSecret
|
|
235
|
+
|
|
236
|
+
@objc public func clearEncryptionSecret() throws {
|
|
237
|
+
if isInit {
|
|
238
|
+
if isEncryption {
|
|
239
|
+
do {
|
|
240
|
+
// close all connections
|
|
241
|
+
try closeAllConnections()
|
|
242
|
+
// set encryption secret
|
|
243
|
+
try UtilsSecret
|
|
244
|
+
.clearEncryptionSecret(prefix: prefixKeychain,
|
|
245
|
+
databaseLocation: databaseLocation)
|
|
246
|
+
return
|
|
247
|
+
} catch UtilsSecretError.clearEncryptionSecret(let message) {
|
|
248
|
+
throw CapacitorSQLiteError.failed(message: message)
|
|
249
|
+
} catch let error {
|
|
250
|
+
throw CapacitorSQLiteError.failed(message: "\(error)")
|
|
251
|
+
}
|
|
252
|
+
} else {
|
|
253
|
+
throw CapacitorSQLiteError.failed(message: "No Encryption set in capacitor.config")
|
|
254
|
+
}
|
|
255
|
+
} else {
|
|
256
|
+
throw CapacitorSQLiteError.failed(message: initMessage)
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
234
260
|
// MARK: - getNCDatabasePath
|
|
235
261
|
|
|
236
262
|
@objc public func getNCDatabasePath(_ folderPath: String, dbName: String ) throws -> String {
|
|
@@ -42,4 +42,5 @@ CAP_PLUGIN(CapacitorSQLitePlugin, "CapacitorSQLite",
|
|
|
42
42
|
CAP_PLUGIN_METHOD(isSecretStored, CAPPluginReturnPromise);
|
|
43
43
|
CAP_PLUGIN_METHOD(setEncryptionSecret, CAPPluginReturnPromise);
|
|
44
44
|
CAP_PLUGIN_METHOD(changeEncryptionSecret, CAPPluginReturnPromise);
|
|
45
|
+
CAP_PLUGIN_METHOD(clearEncryptionSecret, CAPPluginReturnPromise);
|
|
45
46
|
)
|
|
@@ -123,6 +123,26 @@ public class CapacitorSQLitePlugin: CAPPlugin {
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
+
// MARK: - ClearEncryptionSecret
|
|
127
|
+
|
|
128
|
+
@objc func clearEncryptionSecret(_ call: CAPPluginCall) {
|
|
129
|
+
|
|
130
|
+
do {
|
|
131
|
+
try implementation?.clearEncryptionSecret()
|
|
132
|
+
retHandler.rResult(call: call)
|
|
133
|
+
return
|
|
134
|
+
} catch CapacitorSQLiteError.failed(let message) {
|
|
135
|
+
let msg = "ClearEncryptionSecret: \(message)"
|
|
136
|
+
retHandler.rResult(call: call, message: msg)
|
|
137
|
+
return
|
|
138
|
+
} catch let error {
|
|
139
|
+
retHandler.rResult(
|
|
140
|
+
call: call,
|
|
141
|
+
message: "ClearEncryptionSecret: \(error)")
|
|
142
|
+
return
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
126
146
|
// MARK: - CreateConnection
|
|
127
147
|
|
|
128
148
|
@objc func createConnection(_ call: CAPPluginCall) {
|
|
@@ -145,9 +145,9 @@ class UtilsJson {
|
|
|
145
145
|
throws -> JsonNamesTypes {
|
|
146
146
|
var ret: JsonNamesTypes = JsonNamesTypes(names: [], types: [])
|
|
147
147
|
var msg: String = "Error: getTableColumnNamesTypes "
|
|
148
|
-
var query: String = "PRAGMA table_info("
|
|
148
|
+
var query: String = "PRAGMA table_info('"
|
|
149
149
|
query.append(tableName)
|
|
150
|
-
query.append(");")
|
|
150
|
+
query.append("');")
|
|
151
151
|
do {
|
|
152
152
|
var resQuery = try mDB.selectSQL(sql: query, values: [])
|
|
153
153
|
if resQuery.count > 0 {
|
|
@@ -487,7 +487,9 @@ class UtilsSQLCipher {
|
|
|
487
487
|
var sqlStmt = sql
|
|
488
488
|
do {
|
|
489
489
|
let isLast: Bool = try UtilsJson.isLastModified(mDB: mDB)
|
|
490
|
-
|
|
490
|
+
let isDel: Bool = try UtilsJson.isSqlDeleted(mDB: mDB)
|
|
491
|
+
if isLast && isDel {
|
|
492
|
+
// Replace DELETE by UPDATE and set sql_deleted to 1
|
|
491
493
|
if let range: Range<String.Index> = sql
|
|
492
494
|
.range(of: "WHERE", options: .caseInsensitive) {
|
|
493
495
|
let index: Int = sql
|
|
@@ -515,6 +517,8 @@ class UtilsSQLCipher {
|
|
|
515
517
|
throw UtilsSQLCipherError.deleteSQL(message: message)
|
|
516
518
|
} catch UtilsJsonError.isLastModified(let message) {
|
|
517
519
|
throw UtilsSQLCipherError.deleteSQL(message: message)
|
|
520
|
+
} catch UtilsJsonError.isSqlDeleted(let message) {
|
|
521
|
+
throw UtilsSQLCipherError.deleteSQL(message: message)
|
|
518
522
|
}
|
|
519
523
|
}
|
|
520
524
|
|
|
@@ -13,7 +13,8 @@ enum UtilsSecretError: Error {
|
|
|
13
13
|
case setPassphrase(message: String)
|
|
14
14
|
case changePassphrase(message: String)
|
|
15
15
|
case setEncryptionSecret(message: String)
|
|
16
|
-
case
|
|
16
|
+
case changeEncryptionSecret(message: String)
|
|
17
|
+
case clearEncryptionSecret(message: String)
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
let oldAccount: String = "CapacitorSQLitePlugin"
|
|
@@ -240,4 +241,22 @@ class UtilsSecret {
|
|
|
240
241
|
}
|
|
241
242
|
// swiftlint:enable function_body_length
|
|
242
243
|
|
|
244
|
+
// MARK: - ClearEncryptionSecret
|
|
245
|
+
|
|
246
|
+
class func clearEncryptionSecret(prefix: String, databaseLocation: String) throws {
|
|
247
|
+
do {
|
|
248
|
+
if prefix.isEmpty {
|
|
249
|
+
let msg: String = "keychain prefix must not be empty"
|
|
250
|
+
throw UtilsSecretError.setEncryptionSecret(message: msg)
|
|
251
|
+
}
|
|
252
|
+
// clear encrypted passphrase
|
|
253
|
+
let account = "\(prefix)_\(oldAccount)"
|
|
254
|
+
if !getPassphrase(account: account).isEmpty {
|
|
255
|
+
try setPassphrase(account: account, passphrase: "")
|
|
256
|
+
}
|
|
257
|
+
} catch UtilsSecretError.setPassphrase(let message) {
|
|
258
|
+
throw UtilsSecretError.clearEncryptionSecret(message: message)
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
}
|
|
243
262
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor-community/sqlite",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.2-dev1",
|
|
4
4
|
"description": "Community plugin for native & electron SQLite databases",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"@ionic/swiftlint-config": "^1.1.2",
|
|
65
65
|
"@rollup/plugin-commonjs": "^20.0.0",
|
|
66
66
|
"@rollup/plugin-node-resolve": "^13.0.4",
|
|
67
|
-
"electron": "^
|
|
67
|
+
"electron": "^15.5.5",
|
|
68
68
|
"eslint": "^7.11.0",
|
|
69
69
|
"prettier": "~2.2.0",
|
|
70
70
|
"prettier-plugin-java": "~1.0.0",
|
|
@@ -93,6 +93,6 @@
|
|
|
93
93
|
}
|
|
94
94
|
},
|
|
95
95
|
"dependencies": {
|
|
96
|
-
"jeep-sqlite": "^1.5.
|
|
96
|
+
"jeep-sqlite": "^1.5.4-dev1"
|
|
97
97
|
}
|
|
98
98
|
}
|