@capgo/capacitor-updater 7.13.16 → 7.14.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 +1 -0
- package/README.md +51 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +30 -1
- package/dist/docs.json +107 -0
- package/dist/esm/definitions.d.ts +31 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +6 -0
- package/dist/esm/web.js +8 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +8 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +8 -0
- 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/Sources/CapacitorUpdaterPlugin/BundleInfo.swift +113 -0
- package/ios/Sources/CapacitorUpdaterPlugin/BundleStatus.swift +48 -0
- package/ios/Sources/CapacitorUpdaterPlugin/CapacitorUpdaterPlugin.swift +1203 -0
- package/ios/Sources/CapacitorUpdaterPlugin/CapgoUpdater.swift +1301 -0
- package/ios/Sources/CapacitorUpdaterPlugin/CryptoCipher.swift +187 -0
- package/ios/Sources/CapacitorUpdaterPlugin/DelayCondition.swift +74 -0
- package/ios/Sources/CapacitorUpdaterPlugin/DelayUntilNext.swift +30 -0
- package/ios/Sources/CapacitorUpdaterPlugin/DelayUpdateUtils.swift +222 -0
- package/ios/Sources/CapacitorUpdaterPlugin/Info.plist +28 -0
- package/ios/Sources/CapacitorUpdaterPlugin/InternalUtils.swift +303 -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/Sources/CapacitorUpdaterPlugin/UserDefaultsExtension.swift +46 -0
- package/package.json +2 -2
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["/*\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n */\nimport { registerPlugin } from '@capacitor/core';\nconst CapacitorUpdater = registerPlugin('CapacitorUpdater', {\n web: () => import('./web').then((m) => new m.CapacitorUpdaterWeb()),\n});\nexport * from './definitions';\nexport { CapacitorUpdater };\n//# sourceMappingURL=index.js.map","/*\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n */\nimport { WebPlugin } from '@capacitor/core';\nconst BUNDLE_BUILTIN = {\n status: 'success',\n version: '',\n downloaded: '1970-01-01T00:00:00.000Z',\n id: 'builtin',\n checksum: '',\n};\nexport class CapacitorUpdaterWeb extends WebPlugin {\n async setStatsUrl(options) {\n console.warn('Cannot setStatsUrl in web', options);\n return;\n }\n async setUpdateUrl(options) {\n console.warn('Cannot setUpdateUrl in web', options);\n return;\n }\n async setChannelUrl(options) {\n console.warn('Cannot setChannelUrl in web', options);\n return;\n }\n async download(options) {\n console.warn('Cannot download version in web', options);\n return BUNDLE_BUILTIN;\n }\n async next(options) {\n console.warn('Cannot set next version in web', options);\n return BUNDLE_BUILTIN;\n }\n async isAutoUpdateEnabled() {\n console.warn('Cannot get isAutoUpdateEnabled in web');\n return { enabled: false };\n }\n async set(options) {\n console.warn('Cannot set active bundle in web', options);\n return;\n }\n async getDeviceId() {\n console.warn('Cannot get ID in web');\n return { deviceId: 'default' };\n }\n async getBuiltinVersion() {\n console.warn('Cannot get version in web');\n return { version: 'default' };\n }\n async getPluginVersion() {\n console.warn('Cannot get plugin version in web');\n return { version: 'default' };\n }\n async delete(options) {\n console.warn('Cannot delete bundle in web', options);\n }\n async list() {\n console.warn('Cannot list bundles in web');\n return { bundles: [] };\n }\n async reset(options) {\n console.warn('Cannot reset version in web', options);\n }\n async current() {\n console.warn('Cannot get current bundle in web');\n return { bundle: BUNDLE_BUILTIN, native: '0.0.0' };\n }\n async reload() {\n console.warn('Cannot reload current bundle in web');\n return;\n }\n async getLatest() {\n console.warn('Cannot getLatest current bundle in web');\n return {\n version: '0.0.0',\n message: 'Cannot getLatest current bundle in web',\n };\n }\n async setChannel(options) {\n console.warn('Cannot setChannel in web', options);\n return {\n status: 'error',\n error: 'Cannot setChannel in web',\n };\n }\n async unsetChannel(options) {\n console.warn('Cannot unsetChannel in web', options);\n return;\n }\n async setCustomId(options) {\n console.warn('Cannot setCustomId in web', options);\n return;\n }\n async getChannel() {\n console.warn('Cannot getChannel in web');\n return {\n status: 'error',\n error: 'Cannot getChannel in web',\n };\n }\n async listChannels() {\n console.warn('Cannot listChannels in web');\n throw {\n message: 'Cannot listChannels in web',\n error: 'platform_not_supported',\n };\n }\n async notifyAppReady() {\n console.warn('Cannot notify App Ready in web');\n return { bundle: BUNDLE_BUILTIN };\n }\n async setMultiDelay(options) {\n console.warn('Cannot setMultiDelay in web', options === null || options === void 0 ? void 0 : options.delayConditions);\n return;\n }\n async setDelay(option) {\n console.warn('Cannot setDelay in web', option);\n return;\n }\n async cancelDelay() {\n console.warn('Cannot cancelDelay in web');\n return;\n }\n async isAutoUpdateAvailable() {\n console.warn('Cannot isAutoUpdateAvailable in web');\n return { available: false };\n }\n async getCurrentBundle() {\n console.warn('Cannot get current bundle in web');\n return BUNDLE_BUILTIN;\n }\n async getNextBundle() {\n return Promise.resolve(null);\n }\n async setShakeMenu(_options) {\n throw this.unimplemented('Shake menu not available on web platform');\n }\n async isShakeMenuEnabled() {\n return Promise.resolve({ enabled: false });\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;IAAA;IACA;IACA;IACA;IACA;AAEK,UAAC,gBAA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,OAAO,EAAE;IACjC,QAAQ,OAAO,CAAC,IAAI,CAAC,6BAA6B,EAAE,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAC9H,QAAQ;IACR,IAAI;IACJ,IAAI,MAAM,QAAQ,CAAC,MAAM,EAAE;IAC3B,QAAQ,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,MAAM,CAAC;IACtD,QAAQ;IACR,IAAI;IACJ,IAAI,MAAM,WAAW,GAAG;IACxB,QAAQ,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC;IACjD,QAAQ;IACR,IAAI;IACJ,IAAI,MAAM,qBAAqB,GAAG;IAClC,QAAQ,OAAO,CAAC,IAAI,CAAC,qCAAqC,CAAC;IAC3D,QAAQ,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE;IACnC,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC;IACxD,QAAQ,OAAO,cAAc;IAC7B,IAAI;IACJ,IAAI,MAAM,aAAa,GAAG;IAC1B,QAAQ,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;IACpC,IAAI;IACJ,IAAI,MAAM,YAAY,CAAC,QAAQ,EAAE;IACjC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,0CAA0C,CAAC;IAC5E,IAAI;IACJ,IAAI,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAClD,IAAI;IACJ;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["/*\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n */\nimport { registerPlugin } from '@capacitor/core';\nconst CapacitorUpdater = registerPlugin('CapacitorUpdater', {\n web: () => import('./web').then((m) => new m.CapacitorUpdaterWeb()),\n});\nexport * from './definitions';\nexport { CapacitorUpdater };\n//# sourceMappingURL=index.js.map","/*\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n */\nimport { WebPlugin } from '@capacitor/core';\nconst BUNDLE_BUILTIN = {\n status: 'success',\n version: '',\n downloaded: '1970-01-01T00:00:00.000Z',\n id: 'builtin',\n checksum: '',\n};\nexport class CapacitorUpdaterWeb extends WebPlugin {\n async setStatsUrl(options) {\n console.warn('Cannot setStatsUrl in web', options);\n return;\n }\n async setUpdateUrl(options) {\n console.warn('Cannot setUpdateUrl in web', options);\n return;\n }\n async setChannelUrl(options) {\n console.warn('Cannot setChannelUrl in web', options);\n return;\n }\n async download(options) {\n console.warn('Cannot download version in web', options);\n return BUNDLE_BUILTIN;\n }\n async next(options) {\n console.warn('Cannot set next version in web', options);\n return BUNDLE_BUILTIN;\n }\n async isAutoUpdateEnabled() {\n console.warn('Cannot get isAutoUpdateEnabled in web');\n return { enabled: false };\n }\n async set(options) {\n console.warn('Cannot set active bundle in web', options);\n return;\n }\n async getDeviceId() {\n console.warn('Cannot get ID in web');\n return { deviceId: 'default' };\n }\n async getBuiltinVersion() {\n console.warn('Cannot get version in web');\n return { version: 'default' };\n }\n async getPluginVersion() {\n console.warn('Cannot get plugin version in web');\n return { version: 'default' };\n }\n async delete(options) {\n console.warn('Cannot delete bundle in web', options);\n }\n async list() {\n console.warn('Cannot list bundles in web');\n return { bundles: [] };\n }\n async reset(options) {\n console.warn('Cannot reset version in web', options);\n }\n async current() {\n console.warn('Cannot get current bundle in web');\n return { bundle: BUNDLE_BUILTIN, native: '0.0.0' };\n }\n async reload() {\n console.warn('Cannot reload current bundle in web');\n return;\n }\n async getLatest() {\n console.warn('Cannot getLatest current bundle in web');\n return {\n version: '0.0.0',\n message: 'Cannot getLatest current bundle in web',\n };\n }\n async setChannel(options) {\n console.warn('Cannot setChannel in web', options);\n return {\n status: 'error',\n error: 'Cannot setChannel in web',\n };\n }\n async unsetChannel(options) {\n console.warn('Cannot unsetChannel in web', options);\n return;\n }\n async setCustomId(options) {\n console.warn('Cannot setCustomId in web', options);\n return;\n }\n async getChannel() {\n console.warn('Cannot getChannel in web');\n return {\n status: 'error',\n error: 'Cannot getChannel in web',\n };\n }\n async listChannels() {\n console.warn('Cannot listChannels in web');\n throw {\n message: 'Cannot listChannels in web',\n error: 'platform_not_supported',\n };\n }\n async notifyAppReady() {\n console.warn('Cannot notify App Ready in web');\n return { bundle: BUNDLE_BUILTIN };\n }\n async setMultiDelay(options) {\n console.warn('Cannot setMultiDelay in web', options === null || options === void 0 ? void 0 : options.delayConditions);\n return;\n }\n async setDelay(option) {\n console.warn('Cannot setDelay in web', option);\n return;\n }\n async cancelDelay() {\n console.warn('Cannot cancelDelay in web');\n return;\n }\n async isAutoUpdateAvailable() {\n console.warn('Cannot isAutoUpdateAvailable in web');\n return { available: false };\n }\n async getCurrentBundle() {\n console.warn('Cannot get current bundle in web');\n return BUNDLE_BUILTIN;\n }\n async getNextBundle() {\n return Promise.resolve(null);\n }\n async setShakeMenu(_options) {\n throw this.unimplemented('Shake menu not available on web platform');\n }\n async isShakeMenuEnabled() {\n return Promise.resolve({ enabled: false });\n }\n async getAppId() {\n console.warn('Cannot getAppId in web');\n return { appId: 'default' };\n }\n async setAppId(options) {\n console.warn('Cannot setAppId in web', options);\n return;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;IAAA;IACA;IACA;IACA;IACA;AAEK,UAAC,gBAAgB,GAAGA,mBAAc,CAAC,kBAAkB,EAAE;IAC5D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,mBAAmB,EAAE,CAAC;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import Foundation
|
|
3
|
+
import CommonCrypto
|
|
4
|
+
import CryptoKit
|
|
5
|
+
|
|
6
|
+
///
|
|
7
|
+
/// Constants
|
|
8
|
+
///
|
|
9
|
+
private enum AESConstants {
|
|
10
|
+
static let aesAlgorithm: CCAlgorithm = CCAlgorithm(kCCAlgorithmAES)
|
|
11
|
+
static let aesOptions: CCOptions = CCOptions(kCCOptionPKCS7Padding)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// We do all this stuff because ios is shit and open source libraries allow to do decryption with public key
|
|
15
|
+
// So we have to do it manually, while in nodejs or Java it's ok and done at language level.
|
|
16
|
+
|
|
17
|
+
///
|
|
18
|
+
/// The AES key. Contains both the initialization vector and secret key.
|
|
19
|
+
///
|
|
20
|
+
public struct AES128Key {
|
|
21
|
+
/// Initialization vector
|
|
22
|
+
private let iv: Data
|
|
23
|
+
private let logger: Logger
|
|
24
|
+
private let aes128Key: Data
|
|
25
|
+
#if DEBUG
|
|
26
|
+
public var __debug_iv: Data { iv }
|
|
27
|
+
public var __debug_aes128Key: Data { aes128Key }
|
|
28
|
+
#endif
|
|
29
|
+
init(iv: Data, aes128Key: Data, logger: Logger) {
|
|
30
|
+
self.iv = iv
|
|
31
|
+
self.aes128Key = aes128Key
|
|
32
|
+
self.logger = logger
|
|
33
|
+
}
|
|
34
|
+
///
|
|
35
|
+
/// Takes the data and uses the private key to decrypt it. Will call `CCCrypt` in CommonCrypto
|
|
36
|
+
/// and provide it `ivData` for the initialization vector. Will use cipher block chaining (CBC) as
|
|
37
|
+
/// the mode of operation.
|
|
38
|
+
///
|
|
39
|
+
/// Returns the decrypted data.
|
|
40
|
+
///
|
|
41
|
+
public func decrypt(data: Data) -> Data? {
|
|
42
|
+
let encryptedData: UnsafePointer<UInt8> = (data as NSData).bytes.bindMemory(to: UInt8.self, capacity: data.count)
|
|
43
|
+
let encryptedDataLength: Int = data.count
|
|
44
|
+
|
|
45
|
+
if let result: NSMutableData = NSMutableData(length: encryptedDataLength) {
|
|
46
|
+
let keyData: UnsafePointer<UInt8> = (self.aes128Key as NSData).bytes.bindMemory(to: UInt8.self, capacity: self.aes128Key.count)
|
|
47
|
+
let keyLength: size_t = size_t(self.aes128Key.count)
|
|
48
|
+
let ivData: UnsafePointer<UInt8> = (iv as NSData).bytes.bindMemory(to: UInt8.self, capacity: self.iv.count)
|
|
49
|
+
|
|
50
|
+
let decryptedData: UnsafeMutablePointer<UInt8> = UnsafeMutablePointer<UInt8>(result.mutableBytes.assumingMemoryBound(to: UInt8.self))
|
|
51
|
+
let decryptedDataLength: size_t = size_t(result.length)
|
|
52
|
+
|
|
53
|
+
var decryptedLength: size_t = 0
|
|
54
|
+
|
|
55
|
+
let status: CCCryptorStatus = CCCrypt(CCOperation(kCCDecrypt), AESConstants.aesAlgorithm, AESConstants.aesOptions, keyData, keyLength, ivData, encryptedData, encryptedDataLength, decryptedData, decryptedDataLength, &decryptedLength)
|
|
56
|
+
|
|
57
|
+
if Int32(status) == Int32(kCCSuccess) {
|
|
58
|
+
result.length = Int(decryptedLength)
|
|
59
|
+
return result as Data
|
|
60
|
+
} else {
|
|
61
|
+
logger.error("AES decryption failed with status: \(status)")
|
|
62
|
+
return nil
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
logger.error("Failed to allocate memory for AES decryption")
|
|
66
|
+
return nil
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import Foundation
|
|
8
|
+
|
|
9
|
+
@objc public class BundleInfo: NSObject, Decodable, Encodable {
|
|
10
|
+
public static let ID_BUILTIN: String = "builtin"
|
|
11
|
+
public static let VERSION_UNKNOWN: String = "unknown"
|
|
12
|
+
public static let DOWNLOADED_BUILTIN: String = "1970-01-01T00:00:00.000Z"
|
|
13
|
+
|
|
14
|
+
private let downloaded: String
|
|
15
|
+
private let id: String
|
|
16
|
+
private let version: String
|
|
17
|
+
private let checksum: String
|
|
18
|
+
private let status: BundleStatus
|
|
19
|
+
|
|
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
|
+
}
|
|
23
|
+
|
|
24
|
+
init(id: String, version: String, status: BundleStatus, downloaded: String = BundleInfo.DOWNLOADED_BUILTIN, checksum: String) {
|
|
25
|
+
self.downloaded = downloaded.trim()
|
|
26
|
+
self.id = id
|
|
27
|
+
self.version = version
|
|
28
|
+
self.checksum = checksum
|
|
29
|
+
self.status = status
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
enum CodingKeys: String, CodingKey {
|
|
33
|
+
case downloaded, id, version, status, checksum
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public func isBuiltin() -> Bool {
|
|
37
|
+
return BundleInfo.ID_BUILTIN == self.id
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public func isUnknown() -> Bool {
|
|
41
|
+
return BundleInfo.VERSION_UNKNOWN == self.id
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public func isErrorStatus() -> Bool {
|
|
45
|
+
return BundleStatus.ERROR == self.status
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public func isDeleted() -> Bool {
|
|
49
|
+
return BundleStatus.DELETED == self.status
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public func isDownloaded() -> Bool {
|
|
53
|
+
return !self.isBuiltin() && self.downloaded != "" && self.downloaded != BundleInfo.DOWNLOADED_BUILTIN && !self.isDeleted()
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public func getDownloaded() -> String {
|
|
57
|
+
return self.isBuiltin() ? BundleInfo.DOWNLOADED_BUILTIN : self.downloaded
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public func getChecksum() -> String {
|
|
61
|
+
return self.isBuiltin() ? "" : self.checksum
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public func setChecksum(checksum: String) -> BundleInfo {
|
|
65
|
+
return BundleInfo(id: self.id, version: self.version, status: self.status, downloaded: self.downloaded, checksum: checksum)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public func setDownloaded(downloaded: Date) -> BundleInfo {
|
|
69
|
+
return BundleInfo(id: self.id, version: self.version, status: self.status, downloaded: downloaded, checksum: self.checksum)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public func getId() -> String {
|
|
73
|
+
return self.isBuiltin() ? BundleInfo.ID_BUILTIN : self.id
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public func setId(id: String) -> BundleInfo {
|
|
77
|
+
return BundleInfo(id: id, version: self.version, status: self.status, downloaded: self.downloaded, checksum: self.checksum)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public func getVersionName() -> String {
|
|
81
|
+
return self.version.isEmpty ? BundleInfo.ID_BUILTIN : self.version
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public func setVersionName(version: String) -> BundleInfo {
|
|
85
|
+
return BundleInfo(id: self.id, version: version, status: self.status, downloaded: self.downloaded, checksum: self.checksum)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
public func getStatus() -> String {
|
|
89
|
+
return self.isBuiltin() ? BundleStatus.SUCCESS.localizedString : self.status.localizedString
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
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)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public func toJSON() -> [String: String] {
|
|
97
|
+
return [
|
|
98
|
+
"id": self.getId(),
|
|
99
|
+
"version": self.getVersionName(),
|
|
100
|
+
"downloaded": self.getDownloaded(),
|
|
101
|
+
"checksum": self.getChecksum(),
|
|
102
|
+
"status": self.getStatus()
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
public static func == (lhs: BundleInfo, rhs: BundleInfo) -> Bool {
|
|
107
|
+
return lhs.getVersionName() == rhs.getVersionName()
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
public func toString() -> String {
|
|
111
|
+
return "{ \"id\": \"\(self.getId())\", \"version\": \"\(self.getVersionName())\", \"downloaded\": \"\(self.getDownloaded())\", \"checksum\": \"\(self.getChecksum())\", \"status\": \"\(self.getStatus())\"}"
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import Foundation
|
|
8
|
+
|
|
9
|
+
struct LocalizedString: ExpressibleByStringLiteral, Equatable {
|
|
10
|
+
|
|
11
|
+
let v: String
|
|
12
|
+
|
|
13
|
+
init(key: String) {
|
|
14
|
+
self.v = NSLocalizedString(key, comment: "")
|
|
15
|
+
}
|
|
16
|
+
init(localized: String) {
|
|
17
|
+
self.v = localized
|
|
18
|
+
}
|
|
19
|
+
init(stringLiteral value: String) {
|
|
20
|
+
self.init(key: value)
|
|
21
|
+
}
|
|
22
|
+
init(extendedGraphemeClusterLiteral value: String) {
|
|
23
|
+
self.init(key: value)
|
|
24
|
+
}
|
|
25
|
+
init(unicodeScalarLiteral value: String) {
|
|
26
|
+
self.init(key: value)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
func == (lhs: LocalizedString, rhs: LocalizedString) -> Bool {
|
|
31
|
+
return lhs.v == rhs.v
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
enum BundleStatus: LocalizedString, Decodable, Encodable {
|
|
35
|
+
case SUCCESS = "success"
|
|
36
|
+
case ERROR = "error"
|
|
37
|
+
case PENDING = "pending"
|
|
38
|
+
case DELETED = "deleted"
|
|
39
|
+
case DOWNLOADING = "downloading"
|
|
40
|
+
|
|
41
|
+
var localizedString: String {
|
|
42
|
+
return self.rawValue.v
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
init?(localizedString: String) {
|
|
46
|
+
self.init(rawValue: LocalizedString(localized: localizedString))
|
|
47
|
+
}
|
|
48
|
+
}
|