@capgo/capacitor-updater 8.0.0 → 8.1.0
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/CapgoCapacitorUpdater.podspec +7 -5
- package/Package.swift +37 -0
- package/README.md +1461 -231
- package/android/build.gradle +29 -12
- package/android/proguard-rules.pro +45 -0
- package/android/src/main/AndroidManifest.xml +0 -1
- package/android/src/main/java/ee/forgr/capacitor_updater/BundleInfo.java +223 -195
- package/android/src/main/java/ee/forgr/capacitor_updater/BundleStatus.java +23 -23
- package/android/src/main/java/ee/forgr/capacitor_updater/Callback.java +13 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +2159 -1234
- package/android/src/main/java/ee/forgr/capacitor_updater/CapgoUpdater.java +1507 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/CryptoCipher.java +330 -121
- package/android/src/main/java/ee/forgr/capacitor_updater/DataManager.java +28 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/DelayCondition.java +43 -49
- package/android/src/main/java/ee/forgr/capacitor_updater/DelayUntilNext.java +4 -4
- package/android/src/main/java/ee/forgr/capacitor_updater/DelayUpdateUtils.java +260 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/DeviceIdHelper.java +221 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/DownloadService.java +808 -117
- package/android/src/main/java/ee/forgr/capacitor_updater/DownloadWorkerManager.java +156 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/InternalUtils.java +32 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/Logger.java +338 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/ShakeDetector.java +72 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/ShakeMenu.java +169 -0
- package/dist/docs.json +2187 -625
- package/dist/esm/definitions.d.ts +1286 -249
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/history.d.ts +1 -0
- package/dist/esm/history.js +283 -0
- package/dist/esm/history.js.map +1 -0
- package/dist/esm/index.d.ts +3 -2
- package/dist/esm/index.js +5 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/web.d.ts +36 -41
- package/dist/esm/web.js +94 -35
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +376 -35
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +376 -35
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/CapacitorUpdaterPlugin/AES.swift +69 -0
- package/ios/Sources/CapacitorUpdaterPlugin/BigInt.swift +55 -0
- package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/BundleInfo.swift +37 -10
- package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/BundleStatus.swift +1 -1
- package/ios/Sources/CapacitorUpdaterPlugin/CapacitorUpdaterPlugin.swift +1605 -0
- package/ios/Sources/CapacitorUpdaterPlugin/CapgoUpdater.swift +1526 -0
- package/ios/Sources/CapacitorUpdaterPlugin/CryptoCipher.swift +267 -0
- package/ios/Sources/CapacitorUpdaterPlugin/DelayUpdateUtils.swift +220 -0
- package/ios/Sources/CapacitorUpdaterPlugin/DeviceIdHelper.swift +120 -0
- package/ios/Sources/CapacitorUpdaterPlugin/InternalUtils.swift +311 -0
- package/ios/Sources/CapacitorUpdaterPlugin/Logger.swift +310 -0
- package/ios/Sources/CapacitorUpdaterPlugin/RSA.swift +274 -0
- package/ios/Sources/CapacitorUpdaterPlugin/ShakeMenu.swift +112 -0
- package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/UserDefaultsExtension.swift +0 -2
- package/package.json +41 -35
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdater.java +0 -1130
- package/ios/Plugin/CapacitorUpdater.swift +0 -858
- package/ios/Plugin/CapacitorUpdaterPlugin.h +0 -10
- package/ios/Plugin/CapacitorUpdaterPlugin.m +0 -27
- package/ios/Plugin/CapacitorUpdaterPlugin.swift +0 -675
- package/ios/Plugin/CryptoCipher.swift +0 -240
- /package/{LICENCE → LICENSE} +0 -0
- /package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/DelayCondition.swift +0 -0
- /package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/DelayUntilNext.swift +0 -0
- /package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/Info.plist +0 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import BigInt
|
|
2
|
+
|
|
3
|
+
// Extension to serialize BigInt to bytes array
|
|
4
|
+
extension BigInt {
|
|
5
|
+
func serializeToBytes() -> [UInt8] {
|
|
6
|
+
let byteCount = (self.bitWidth + 7) / 8
|
|
7
|
+
var bytes = [UInt8](repeating: 0, count: byteCount)
|
|
8
|
+
|
|
9
|
+
var value = self
|
|
10
|
+
for i in 0..<byteCount {
|
|
11
|
+
bytes[byteCount - i - 1] = UInt8(truncatingIfNeeded: value & 0xFF)
|
|
12
|
+
value >>= 8
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return bytes
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Add this custom power function to ensure safer handling of power operations
|
|
20
|
+
|
|
21
|
+
// Manual exponentiation using the square-and-multiply algorithm
|
|
22
|
+
// which is more efficient and avoids using the built-in functions that might handle BigInt differently
|
|
23
|
+
extension BigInt {
|
|
24
|
+
func manualPower(_ exponent: BigInt, modulus: BigInt) -> BigInt {
|
|
25
|
+
// Quick checks
|
|
26
|
+
if modulus == 0 {
|
|
27
|
+
return 0
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if exponent == 0 {
|
|
31
|
+
return 1
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
guard let base = self.magnitude as? BigUInt,
|
|
35
|
+
let exp = exponent.magnitude as? BigUInt,
|
|
36
|
+
let mod = modulus.magnitude as? BigUInt else {
|
|
37
|
+
return 0
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Square and multiply algorithm for modular exponentiation
|
|
41
|
+
var result = BigUInt(1)
|
|
42
|
+
var x = base % mod
|
|
43
|
+
var e = exp
|
|
44
|
+
|
|
45
|
+
while e > 0 {
|
|
46
|
+
if e & 1 == 1 {
|
|
47
|
+
result = (result * x) % mod
|
|
48
|
+
}
|
|
49
|
+
x = (x * x) % mod
|
|
50
|
+
e >>= 1
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return BigInt(result)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -16,21 +16,25 @@ import Foundation
|
|
|
16
16
|
private let version: String
|
|
17
17
|
private let checksum: String
|
|
18
18
|
private let status: BundleStatus
|
|
19
|
+
private let link: String?
|
|
20
|
+
private let comment: String?
|
|
19
21
|
|
|
20
|
-
convenience init(id: String, version: String, status: BundleStatus, downloaded: Date, checksum: String) {
|
|
21
|
-
self.init(id: id, version: version, status: status, downloaded: downloaded.iso8601withFractionalSeconds, checksum: checksum)
|
|
22
|
+
convenience init(id: String, version: String, status: BundleStatus, downloaded: Date, checksum: String, link: String? = nil, comment: String? = nil) {
|
|
23
|
+
self.init(id: id, version: version, status: status, downloaded: downloaded.iso8601withFractionalSeconds, checksum: checksum, link: link, comment: comment)
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
init(id: String, version: String, status: BundleStatus, downloaded: String = BundleInfo.DOWNLOADED_BUILTIN, checksum: String) {
|
|
26
|
+
init(id: String, version: String, status: BundleStatus, downloaded: String = BundleInfo.DOWNLOADED_BUILTIN, checksum: String, link: String? = nil, comment: String? = nil) {
|
|
25
27
|
self.downloaded = downloaded.trim()
|
|
26
28
|
self.id = id
|
|
27
29
|
self.version = version
|
|
28
30
|
self.checksum = checksum
|
|
29
31
|
self.status = status
|
|
32
|
+
self.link = link
|
|
33
|
+
self.comment = comment
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
enum CodingKeys: String, CodingKey {
|
|
33
|
-
case downloaded, id, version, status, checksum
|
|
37
|
+
case downloaded, id, version, status, checksum, link, comment
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
public func isBuiltin() -> Bool {
|
|
@@ -62,11 +66,11 @@ import Foundation
|
|
|
62
66
|
}
|
|
63
67
|
|
|
64
68
|
public func setChecksum(checksum: String) -> BundleInfo {
|
|
65
|
-
return BundleInfo(id: self.id, version: self.version, status: self.status, downloaded: self.downloaded, checksum: checksum)
|
|
69
|
+
return BundleInfo(id: self.id, version: self.version, status: self.status, downloaded: self.downloaded, checksum: checksum, link: self.link, comment: self.comment)
|
|
66
70
|
}
|
|
67
71
|
|
|
68
72
|
public func setDownloaded(downloaded: Date) -> BundleInfo {
|
|
69
|
-
return BundleInfo(id: self.id, version: self.version, status: self.status, downloaded: downloaded, checksum: self.checksum)
|
|
73
|
+
return BundleInfo(id: self.id, version: self.version, status: self.status, downloaded: downloaded, checksum: self.checksum, link: self.link, comment: self.comment)
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
public func getId() -> String {
|
|
@@ -74,7 +78,7 @@ import Foundation
|
|
|
74
78
|
}
|
|
75
79
|
|
|
76
80
|
public func setId(id: String) -> BundleInfo {
|
|
77
|
-
return BundleInfo(id: id, version: self.version, status: self.status, downloaded: self.downloaded, checksum: self.checksum)
|
|
81
|
+
return BundleInfo(id: id, version: self.version, status: self.status, downloaded: self.downloaded, checksum: self.checksum, link: self.link, comment: self.comment)
|
|
78
82
|
}
|
|
79
83
|
|
|
80
84
|
public func getVersionName() -> String {
|
|
@@ -82,7 +86,7 @@ import Foundation
|
|
|
82
86
|
}
|
|
83
87
|
|
|
84
88
|
public func setVersionName(version: String) -> BundleInfo {
|
|
85
|
-
return BundleInfo(id: self.id, version: version, status: self.status, downloaded: self.downloaded, checksum: self.checksum)
|
|
89
|
+
return BundleInfo(id: self.id, version: version, status: self.status, downloaded: self.downloaded, checksum: self.checksum, link: self.link, comment: self.comment)
|
|
86
90
|
}
|
|
87
91
|
|
|
88
92
|
public func getStatus() -> String {
|
|
@@ -90,17 +94,40 @@ import Foundation
|
|
|
90
94
|
}
|
|
91
95
|
|
|
92
96
|
public func setStatus(status: String) -> BundleInfo {
|
|
93
|
-
return BundleInfo(id: self.id, version: self.version, status: BundleStatus(localizedString: status)!, downloaded: self.downloaded, checksum: self.checksum)
|
|
97
|
+
return BundleInfo(id: self.id, version: self.version, status: BundleStatus(localizedString: status)!, downloaded: self.downloaded, checksum: self.checksum, link: self.link, comment: self.comment)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public func getLink() -> String? {
|
|
101
|
+
return self.link
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
public func setLink(link: String?) -> BundleInfo {
|
|
105
|
+
return BundleInfo(id: self.id, version: self.version, status: self.status, downloaded: self.downloaded, checksum: self.checksum, link: link, comment: self.comment)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public func getComment() -> String? {
|
|
109
|
+
return self.comment
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
public func setComment(comment: String?) -> BundleInfo {
|
|
113
|
+
return BundleInfo(id: self.id, version: self.version, status: self.status, downloaded: self.downloaded, checksum: self.checksum, link: self.link, comment: comment)
|
|
94
114
|
}
|
|
95
115
|
|
|
96
116
|
public func toJSON() -> [String: String] {
|
|
97
|
-
|
|
117
|
+
var result: [String: String] = [
|
|
98
118
|
"id": self.getId(),
|
|
99
119
|
"version": self.getVersionName(),
|
|
100
120
|
"downloaded": self.getDownloaded(),
|
|
101
121
|
"checksum": self.getChecksum(),
|
|
102
122
|
"status": self.getStatus()
|
|
103
123
|
]
|
|
124
|
+
if let link = self.link {
|
|
125
|
+
result["link"] = link
|
|
126
|
+
}
|
|
127
|
+
if let comment = self.comment {
|
|
128
|
+
result["comment"] = comment
|
|
129
|
+
}
|
|
130
|
+
return result
|
|
104
131
|
}
|
|
105
132
|
|
|
106
133
|
public static func == (lhs: BundleInfo, rhs: BundleInfo) -> Bool {
|