native-update 3.4.1 → 4.0.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.
Files changed (48) hide show
  1. package/AI-INTEGRATION-GUIDE.md +26 -16
  2. package/NativeUpdate.podspec +2 -2
  3. package/README.md +554 -0
  4. package/android/build.gradle +43 -34
  5. package/android/gradle/wrapper/gradle-wrapper.properties +2 -2
  6. package/android/proguard-rules.pro +0 -3
  7. package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundNotificationManager.kt +45 -49
  8. package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdateManager.kt +12 -10
  9. package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdatePlugin.kt +12 -21
  10. package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdateWorker.kt +3 -34
  11. package/android/src/main/java/com/aoneahsan/nativeupdate/LiveUpdatePlugin.kt +206 -72
  12. package/android/src/main/java/com/aoneahsan/nativeupdate/NativeUpdatePlugin.kt +74 -37
  13. package/android/src/main/java/com/aoneahsan/nativeupdate/SecurityManager.kt +169 -179
  14. package/android/variables.gradle +2 -2
  15. package/cli/.yarn/install-state.gz +0 -0
  16. package/cli/commands/bundle-verify.js +4 -1
  17. package/cli/commands/keys-generate.js +12 -46
  18. package/cli/index.js +4 -7
  19. package/cli/package.json +2 -1
  20. package/dist/esm/core/config.d.ts +3 -0
  21. package/dist/esm/core/config.js +17 -0
  22. package/dist/esm/core/plugin-manager.js +4 -2
  23. package/dist/esm/core/security.js +2 -5
  24. package/dist/esm/core/update-check.d.ts +2 -0
  25. package/dist/esm/core/update-check.js +5 -3
  26. package/dist/esm/definitions.d.ts +43 -2
  27. package/dist/esm/live-update/delta-processor.d.ts +6 -20
  28. package/dist/esm/live-update/delta-processor.js +75 -119
  29. package/dist/esm/plugin.d.ts +0 -3
  30. package/dist/esm/plugin.js +172 -12
  31. package/dist/esm/security/crypto.js +2 -5
  32. package/dist/esm/web.d.ts +1 -9
  33. package/dist/esm/web.js +4 -56
  34. package/dist/plugin.cjs +1 -1
  35. package/dist/plugin.esm.js +1 -1
  36. package/dist/plugin.js +2 -2
  37. package/docs/CHANGELOG.md +66 -0
  38. package/docs/KNOWN_LIMITATIONS.md +4 -3
  39. package/docs/MIGRATION.md +32 -3
  40. package/docs/server-requirements.md +40 -29
  41. package/ios/Plugin/BackgroundUpdate/BackgroundNotificationManager.swift +6 -2
  42. package/ios/Plugin/BackgroundUpdate/BackgroundUpdatePlugin.swift +21 -30
  43. package/ios/Plugin/LiveUpdate/LiveUpdatePlugin.swift +269 -61
  44. package/ios/Plugin/NativeUpdatePlugin.m +8 -1
  45. package/ios/Plugin/NativeUpdatePlugin.swift +71 -34
  46. package/ios/Plugin/Security/SecurityManager.swift +100 -99
  47. package/package.json +27 -15
  48. package/Readme.md +0 -565
@@ -19,6 +19,12 @@ public class NativeUpdatePlugin: CAPPlugin {
19
19
  appReviewPlugin = AppReviewPlugin(plugin: self)
20
20
  backgroundUpdatePlugin = BackgroundUpdatePlugin()
21
21
  securityManager = SecurityManager()
22
+ backgroundUpdatePlugin.load()
23
+ backgroundUpdatePlugin.configureProviders(
24
+ appUpdate: { [weak self] in await self?.appUpdatePlugin.getAppUpdateInfoAsync() },
25
+ liveUpdate: { [weak self] in await self?.liveUpdatePlugin.getLatestVersionAsync() },
26
+ eventListener: { [weak self] event, data in self?.notifyListeners(event, data: data) }
27
+ )
22
28
 
23
29
  // Set up listeners
24
30
  liveUpdatePlugin.setProgressListener { [weak self] progress in
@@ -45,15 +51,15 @@ public class NativeUpdatePlugin: CAPPlugin {
45
51
 
46
52
  @objc func initialize(_ call: CAPPluginCall) {
47
53
  do {
48
- // Initialize with filesystem and preferences if provided
49
- // In iOS, we typically don't need these as we use native APIs
50
-
51
- // Apply configuration. Both the wrapped ({ config: {...} }) and
52
- // the flat PluginInitConfig shapes are accepted — configure()
53
- // normalizes them (v3.1.3: the flat initialize() used to be
54
- // rejected here, so native never received serverUrl/apiKey).
55
- configure(call)
56
-
54
+ guard !isInitialized else {
55
+ call.reject("Configuration is locked after initialization; call reset() first")
56
+ return
57
+ }
58
+ guard let config = configuration(from: call) else {
59
+ call.reject("Configuration object is required")
60
+ return
61
+ }
62
+ try applyConfiguration(config)
57
63
  isInitialized = true
58
64
  call.resolve()
59
65
  } catch {
@@ -91,41 +97,36 @@ public class NativeUpdatePlugin: CAPPlugin {
91
97
  // configure(UpdateConfig) — nested sections
92
98
  // Before this fix only the wrapped shape reached native, so the
93
99
  // flat initialize() every consumer uses configured NOTHING here.
94
- let wrapped = call.getObject("config").map { $0 as [String: Any] }
95
- guard let config = wrapped ?? (call.options as? [String: Any]) else {
100
+ guard !isInitialized else {
101
+ call.reject("Configuration is locked after initialization; call reset() first")
102
+ return
103
+ }
104
+ guard let config = configuration(from: call) else {
96
105
  call.reject("Configuration object is required")
97
106
  return
98
107
  }
99
108
 
100
109
  do {
101
- // Validate security settings
102
- if let securityConfig = config["security"] as? [String: Any] {
103
- try securityManager.configure(securityConfig)
104
- }
105
-
106
- // Configure sub-plugins
107
- if let liveUpdateConfig = (config["liveUpdate"] as? [String: Any]) ?? Self.buildFlatLiveUpdateConfig(from: config) {
108
- try liveUpdatePlugin.configure(liveUpdateConfig)
109
- }
110
-
111
- if let appUpdateConfig = config["appUpdate"] as? [String: Any] {
112
- try appUpdatePlugin.configure(appUpdateConfig)
113
- }
114
-
115
- if let appReviewConfig = config["appReview"] as? [String: Any] {
116
- try appReviewPlugin.configure(appReviewConfig)
117
- }
118
-
119
- if let backgroundUpdateConfig = config["backgroundUpdate"] as? [String: Any] {
120
- try backgroundUpdatePlugin.configure(backgroundUpdateConfig)
121
- }
122
-
110
+ try applyConfiguration(config)
111
+ isInitialized = true
123
112
  call.resolve()
124
113
  } catch {
125
114
  call.reject("Configuration failed", error.localizedDescription)
126
115
  }
127
116
  }
128
117
 
118
+ private func configuration(from call: CAPPluginCall) -> [String: Any]? {
119
+ call.getObject("config").map { $0 as [String: Any] } ?? (call.options as? [String: Any])
120
+ }
121
+
122
+ private func applyConfiguration(_ config: [String: Any]) throws {
123
+ try securityManager.configure(config)
124
+ if let live = Self.normalizeLiveUpdateConfig(from: config) { try liveUpdatePlugin.configure(live) }
125
+ if let value = config["appUpdate"] as? [String: Any] { try appUpdatePlugin.configure(value) }
126
+ if let value = config["appReview"] as? [String: Any] { try appReviewPlugin.configure(value) }
127
+ if let value = config["backgroundUpdate"] as? [String: Any] { try backgroundUpdatePlugin.configure(value) }
128
+ }
129
+
129
130
  /// Normalize a flat PluginInitConfig (serverUrl/baseUrl, apiKey, appId,
130
131
  /// channel, publicKey at the top level) into the liveUpdate config shape
131
132
  /// the sub-plugin reads. Returns nil when the payload carries no
@@ -143,10 +144,41 @@ public class NativeUpdatePlugin: CAPPlugin {
143
144
  if let appId = config["appId"] as? String { liveUpdate["appId"] = appId }
144
145
  if let channel = config["channel"] as? String { liveUpdate["channel"] = channel }
145
146
  if let publicKey = config["publicKey"] as? String { liveUpdate["publicKey"] = publicKey }
147
+ if let requireSignature = config["requireSignature"] as? Bool { liveUpdate["requireSignature"] = requireSignature }
148
+ if let allowUnsigned = config["allowUnsignedDevelopmentUpdates"] as? Bool {
149
+ liveUpdate["allowUnsignedDevelopmentUpdates"] = allowUnsigned
150
+ }
151
+ if let maxBundleSize = config["maxBundleSize"] as? NSNumber { liveUpdate["maxBundleSize"] = maxBundleSize }
152
+ if let maxUncompressedBundleSize = config["maxUncompressedBundleSize"] as? NSNumber {
153
+ liveUpdate["maxUncompressedBundleSize"] = maxUncompressedBundleSize
154
+ }
155
+ if let enableDeltaUpdates = config["enableDeltaUpdates"] as? Bool {
156
+ liveUpdate["enableDeltaUpdates"] = enableDeltaUpdates
157
+ }
158
+ if let allowedHosts = config["allowedHosts"] as? [String] { liveUpdate["allowedHosts"] = allowedHosts }
146
159
  if let security = config["security"] as? [String: Any] { liveUpdate["security"] = security }
147
160
  return liveUpdate
148
161
  }
149
162
 
163
+ private static func normalizeLiveUpdateConfig(from config: [String: Any]) -> [String: Any]? {
164
+ guard var liveUpdate = (config["liveUpdate"] as? [String: Any]) ?? buildFlatLiveUpdateConfig(from: config) else {
165
+ return nil
166
+ }
167
+ if liveUpdate["security"] == nil { liveUpdate["security"] = config["security"] }
168
+ if liveUpdate["publicKey"] == nil { liveUpdate["publicKey"] = config["publicKey"] }
169
+ if liveUpdate["requireSignature"] == nil { liveUpdate["requireSignature"] = config["requireSignature"] }
170
+ if liveUpdate["allowUnsignedDevelopmentUpdates"] == nil {
171
+ liveUpdate["allowUnsignedDevelopmentUpdates"] = config["allowUnsignedDevelopmentUpdates"]
172
+ }
173
+ if liveUpdate["maxUncompressedBundleSize"] == nil {
174
+ liveUpdate["maxUncompressedBundleSize"] = config["maxUncompressedBundleSize"]
175
+ }
176
+ if liveUpdate["enableDeltaUpdates"] == nil {
177
+ liveUpdate["enableDeltaUpdates"] = config["enableDeltaUpdates"]
178
+ }
179
+ return liveUpdate
180
+ }
181
+
150
182
  @objc func getSecurityInfo(_ call: CAPPluginCall) {
151
183
  call.resolve(securityManager.getSecurityInfo())
152
184
  }
@@ -209,6 +241,11 @@ public class NativeUpdatePlugin: CAPPlugin {
209
241
  @objc func validateUpdate(_ call: CAPPluginCall) {
210
242
  liveUpdatePlugin.validateUpdate(call)
211
243
  }
244
+
245
+ @objc func cancelDownload(_ call: CAPPluginCall) { liveUpdatePlugin.cancelDownload(call) }
246
+ @objc func cancelAllDownloads(_ call: CAPPluginCall) { liveUpdatePlugin.cancelAllDownloads(call) }
247
+ @objc func isDownloading(_ call: CAPPluginCall) { liveUpdatePlugin.isDownloading(call) }
248
+ @objc func getActiveDownloadCount(_ call: CAPPluginCall) { liveUpdatePlugin.getActiveDownloadCount(call) }
212
249
 
213
250
  // MARK: - App Update Methods
214
251
 
@@ -275,4 +312,4 @@ public class NativeUpdatePlugin: CAPPlugin {
275
312
  @objc func requestNotificationPermissions(_ call: CAPPluginCall) {
276
313
  backgroundUpdatePlugin.requestNotificationPermissions(call)
277
314
  }
278
- }
315
+ }
@@ -1,6 +1,5 @@
1
1
  import Foundation
2
2
  import Security
3
- import CommonCrypto
4
3
  import CryptoKit
5
4
 
6
5
  class SecurityManager {
@@ -9,29 +8,48 @@ class SecurityManager {
9
8
 
10
9
  func configure(_ config: [String: Any]) throws {
11
10
  self.config = config
12
-
13
- // Validate security configuration
14
- let enforceHttps = config["enforceHttps"] as? Bool ?? true
15
- if !enforceHttps {
16
- print("⚠️ SecurityManager: HTTPS enforcement is disabled. This is not recommended for production.")
11
+ let security = securityConfig
12
+ guard security["enforceHttps"] as? Bool != false else {
13
+ throw NSError(domain: "NativeUpdateSecurity", code: 1, userInfo: [
14
+ NSLocalizedDescriptionKey: "HTTPS enforcement cannot be disabled"
15
+ ])
16
+ }
17
+ if let pinning = security["certificatePinning"] as? [String: Any],
18
+ pinning["enabled"] as? Bool == true {
19
+ guard let pins = pinning["pins"] as? [[String: Any]], !pins.isEmpty else {
20
+ throw NSError(domain: "NativeUpdateSecurity", code: 2, userInfo: [
21
+ NSLocalizedDescriptionKey: "Certificate pinning requires at least one host pin"
22
+ ])
23
+ }
24
+ let pinPattern = try NSRegularExpression(pattern: "^sha256/[A-Za-z0-9+/]{43}=$")
25
+ for pin in pins {
26
+ guard let hostname = pin["hostname"] as? String, !hostname.isEmpty,
27
+ let hashes = pin["sha256"] as? [String], !hashes.isEmpty,
28
+ hashes.allSatisfy({ pinPattern.firstMatch(in: $0, range: NSRange($0.startIndex..., in: $0)) != nil }) else {
29
+ throw NSError(domain: "NativeUpdateSecurity", code: 3, userInfo: [
30
+ NSLocalizedDescriptionKey: "Certificate pins require a hostname and sha256/<base64> hashes"
31
+ ])
32
+ }
33
+ }
17
34
  }
18
35
  }
19
36
 
20
37
  func getSecurityInfo() -> [String: Any] {
21
38
  return [
22
- "enforceHttps": config?["enforceHttps"] as? Bool ?? true,
39
+ "enforceHttps": true,
23
40
  "certificatePinning": [
24
- "enabled": (config?["certificatePinning"] as? [String: Any])?["enabled"] as? Bool ?? false,
41
+ "enabled": (securityConfig["certificatePinning"] as? [String: Any])?["enabled"] as? Bool ?? false,
25
42
  "pins": getCertificatePins()
26
43
  ],
27
- "validateInputs": config?["validateInputs"] as? Bool ?? true,
44
+ "validateInputs": securityConfig["validateInputs"] as? Bool ?? true,
28
45
  // Hard-coded true since v2 — secure storage is no longer opt-out.
29
- "secureStorage": true
46
+ "secureStorage": true,
47
+ "signatureAlgorithm": "RSA-SHA256"
30
48
  ]
31
49
  }
32
50
 
33
51
  func getCertificatePins() -> [String: [String]] {
34
- guard let pinningConfig = config?["certificatePinning"] as? [String: Any],
52
+ guard let pinningConfig = securityConfig["certificatePinning"] as? [String: Any],
35
53
  pinningConfig["enabled"] as? Bool == true,
36
54
  let pins = pinningConfig["pins"] as? [[String: Any]] else {
37
55
  return [:]
@@ -44,7 +62,7 @@ class SecurityManager {
44
62
  let sha256Pins = pin["sha256"] as? [String] else {
45
63
  continue
46
64
  }
47
-
65
+
48
66
  hostPins[hostname] = sha256Pins
49
67
  }
50
68
 
@@ -52,81 +70,62 @@ class SecurityManager {
52
70
  }
53
71
 
54
72
  func validateUrl(_ url: String) -> Bool {
55
- if !url.hasPrefix("https://") && isHttpsEnforced() {
56
- return false
57
- }
58
-
59
- // Check against allowed hosts if configured
60
- if let allowedHosts = getAllowedHosts(), !allowedHosts.isEmpty {
61
- guard let urlComponents = URLComponents(string: url),
62
- let host = urlComponents.host else {
63
- return false
64
- }
65
- return allowedHosts.contains(host)
66
- }
67
-
68
- return true
73
+ guard let components = URLComponents(string: url),
74
+ components.scheme?.lowercased() == "https",
75
+ let host = components.host?.lowercased(), !host.isEmpty,
76
+ components.user == nil, components.password == nil else { return false }
77
+ let allowedHosts = getAllowedHosts() ?? []
78
+ return allowedHosts.isEmpty || allowedHosts.map { $0.lowercased() }.contains(host)
69
79
  }
70
80
 
71
81
  func verifySignature(data: Data, signature: String, publicKeyString: String) -> Bool {
72
- // Handle PEM format or base64 encoded public key
73
- let publicKeyData: Data
74
- if publicKeyString.contains("-----BEGIN PUBLIC KEY-----") {
75
- // Convert PEM to base64
76
- let base64String = publicKeyString
77
- .replacingOccurrences(of: "-----BEGIN PUBLIC KEY-----", with: "")
78
- .replacingOccurrences(of: "-----END PUBLIC KEY-----", with: "")
79
- .replacingOccurrences(of: "\n", with: "")
80
- .replacingOccurrences(of: "\r", with: "")
81
- .trimmingCharacters(in: .whitespacesAndNewlines)
82
-
83
- guard let data = Data(base64Encoded: base64String) else {
84
- print("Failed to decode PEM public key")
85
- return false
86
- }
87
- publicKeyData = data
88
- } else {
89
- // Already base64 encoded
90
- guard let data = Data(base64Encoded: publicKeyString) else {
91
- print("Failed to decode base64 public key")
92
- return false
93
- }
94
- publicKeyData = data
95
- }
96
-
97
- guard let signatureData = Data(base64Encoded: signature) else {
98
- print("Failed to decode signature")
99
- return false
100
- }
101
-
102
- do {
103
- // Create SecKey from public key data
104
- let attributes: [String: Any] = [
105
- kSecAttrKeyType as String: kSecAttrKeyTypeRSA,
106
- kSecAttrKeyClass as String: kSecAttrKeyClassPublic,
107
- kSecAttrKeySizeInBits as String: 2048
108
- ]
109
-
110
- guard let secKey = SecKeyCreateWithData(publicKeyData as CFData, attributes as CFDictionary, nil) else {
111
- print("Failed to create SecKey from public key data")
112
- return false
113
- }
114
-
115
- // Verify signature using RSA-PSS (matching web implementation)
116
- let algorithm = SecKeyAlgorithm.rsaSignatureMessagePSSSHA256
117
- let result = SecKeyVerifySignature(secKey, algorithm, data as CFData, signatureData as CFData, nil)
118
-
119
- if !result {
120
- print("Signature verification failed")
121
- }
122
-
123
- return result
124
- } catch {
125
- print("Signature verification error: \(error)")
126
- return false
82
+ guard let secKey = decodePublicKey(publicKeyString),
83
+ let signatureData = Data(base64Encoded: signature) else { return false }
84
+
85
+ // Backend contract: RSA-SHA256 with PKCS#1 v1.5 padding.
86
+ let algorithm = SecKeyAlgorithm.rsaSignatureMessagePKCS1v15SHA256
87
+ guard SecKeyIsAlgorithmSupported(secKey, .verify, algorithm) else { return false }
88
+ return SecKeyVerifySignature(secKey, algorithm, data as CFData, signatureData as CFData, nil)
89
+ }
90
+
91
+ /** Verify a large bundle without materializing the entire ZIP in memory. */
92
+ func verifySignature(fileURL: URL, signature: String, publicKeyString: String) -> Bool {
93
+ guard let secKey = decodePublicKey(publicKeyString),
94
+ let signatureData = Data(base64Encoded: signature),
95
+ let stream = InputStream(url: fileURL) else { return false }
96
+
97
+ stream.open()
98
+ defer { stream.close() }
99
+ var hasher = SHA256()
100
+ let buffer = UnsafeMutablePointer<UInt8>.allocate(capacity: 64 * 1024)
101
+ defer { buffer.deallocate() }
102
+ while stream.hasBytesAvailable {
103
+ let count = stream.read(buffer, maxLength: 64 * 1024)
104
+ if count < 0 { return false }
105
+ if count == 0 { break }
106
+ hasher.update(data: Data(bytes: buffer, count: count))
127
107
  }
108
+
109
+ let digest = Data(hasher.finalize())
110
+ let algorithm = SecKeyAlgorithm.rsaSignatureDigestPKCS1v15SHA256
111
+ guard SecKeyIsAlgorithmSupported(secKey, .verify, algorithm) else { return false }
112
+ return SecKeyVerifySignature(secKey, algorithm, digest as CFData, signatureData as CFData, nil)
128
113
  }
129
-
114
+
115
+ private func decodePublicKey(_ publicKeyString: String) -> SecKey? {
116
+ let normalized = publicKeyString
117
+ .replacingOccurrences(of: "-----BEGIN PUBLIC KEY-----", with: "")
118
+ .replacingOccurrences(of: "-----END PUBLIC KEY-----", with: "")
119
+ .components(separatedBy: .whitespacesAndNewlines)
120
+ .joined()
121
+ guard let publicKeyData = Data(base64Encoded: normalized) else { return nil }
122
+ let attributes: [String: Any] = [
123
+ kSecAttrKeyType as String: kSecAttrKeyTypeRSA,
124
+ kSecAttrKeyClass as String: kSecAttrKeyClassPublic
125
+ ]
126
+ return SecKeyCreateWithData(publicKeyData as CFData, attributes as CFDictionary, nil)
127
+ }
128
+
130
129
  func calculateChecksum(for data: Data, algorithm: String = "SHA-256") -> String {
131
130
  let digest: Data
132
131
 
@@ -171,9 +170,9 @@ class SecurityManager {
171
170
  let cachesPath = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first!.path
172
171
  let tempPath = NSTemporaryDirectory()
173
172
 
174
- return standardizedPath.hasPrefix(documentsPath) ||
175
- standardizedPath.hasPrefix(cachesPath) ||
176
- standardizedPath.hasPrefix(tempPath)
173
+ return isWithin(standardizedPath, root: documentsPath) ||
174
+ isWithin(standardizedPath, root: cachesPath) ||
175
+ isWithin(standardizedPath, root: tempPath)
177
176
  }
178
177
 
179
178
  func sanitizeInput(_ input: String) -> String {
@@ -183,7 +182,7 @@ class SecurityManager {
183
182
  }
184
183
 
185
184
  func isHttpsEnforced() -> Bool {
186
- return config?["enforceHttps"] as? Bool ?? true
185
+ return true
187
186
  }
188
187
 
189
188
  /// Unconditionally true since v2. Kept so `getSecurityInfo()` still
@@ -193,11 +192,11 @@ class SecurityManager {
193
192
  }
194
193
 
195
194
  func isInputValidationEnabled() -> Bool {
196
- return config?["validateInputs"] as? Bool ?? true
195
+ return securityConfig["validateInputs"] as? Bool ?? true
197
196
  }
198
197
 
199
198
  func logSecurityEvent(_ event: String, details: String? = nil) {
200
- guard config?["logSecurityEvents"] as? Bool == true else { return }
199
+ guard securityConfig["logSecurityEvents"] as? Bool == true else { return }
201
200
 
202
201
  let message = "Security Event: \(event) \(details ?? "")"
203
202
  print("🔒 \(message)")
@@ -209,20 +208,21 @@ class SecurityManager {
209
208
  var hosts: [String] = []
210
209
 
211
210
  // Add hosts from live update config
212
- if let liveUpdateConfig = config?["liveUpdate"] as? [String: Any],
213
- let allowedHosts = liveUpdateConfig["allowedHosts"] as? [String] {
211
+ if let allowedHosts = config?["allowedHosts"] as? [String] {
214
212
  hosts.append(contentsOf: allowedHosts)
215
213
  }
216
214
 
217
- // Add host from server URL
218
- if let serverUrl = config?["serverUrl"] as? String,
219
- let urlComponents = URLComponents(string: serverUrl),
220
- let host = urlComponents.host {
221
- hosts.append(host)
222
- }
223
-
224
215
  return hosts.isEmpty ? nil : Array(Set(hosts))
225
216
  }
217
+
218
+ private var securityConfig: [String: Any] {
219
+ (config?["security"] as? [String: Any]) ?? config ?? [:]
220
+ }
221
+
222
+ private func isWithin(_ path: String, root: String) -> Bool {
223
+ let normalizedRoot = URL(fileURLWithPath: root).standardizedFileURL.path
224
+ return path == normalizedRoot || path.hasPrefix(normalizedRoot + "/")
225
+ }
226
226
  }
227
227
 
228
228
  // MARK: - Keychain Wrapper
@@ -237,7 +237,8 @@ private class KeychainWrapper {
237
237
  kSecClass as String: kSecClassGenericPassword,
238
238
  kSecAttrService as String: serviceName,
239
239
  kSecAttrAccount as String: key,
240
- kSecValueData as String: data
240
+ kSecValueData as String: data,
241
+ kSecAttrAccessible as String: kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly
241
242
  ]
242
243
 
243
244
  // Delete any existing item
@@ -285,4 +286,4 @@ extension Digest {
285
286
  var data: Data {
286
287
  Data(self)
287
288
  }
288
- }
289
+ }
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "native-update",
3
- "version": "3.4.1",
3
+ "version": "4.0.0",
4
+ "packageManager": "yarn@4.17.0",
4
5
  "engines": {
5
6
  "node": ">=24.16.0"
6
7
  },
7
- "description": "Capacitor update plugin with live updates, app update checks, and app reviews. v3 ships an HTTP-only backend contract (Laravel + Nova reference implementation) and is paired with the hosted Native Update SaaS for release delivery.",
8
+ "description": "Over-the-air updates, app-store update flows, and in-app reviews for Capacitor apps.",
8
9
  "type": "module",
9
10
  "main": "dist/plugin.cjs",
10
11
  "module": "dist/esm/index.js",
@@ -39,6 +40,8 @@
39
40
  "docs/KNOWN_LIMITATIONS.md",
40
41
  "cli/",
41
42
  "AI-INTEGRATION-GUIDE.md",
43
+ "!**/node_modules/**",
44
+ "!**/yarn.lock",
42
45
  "!**/CLAUDE.md",
43
46
  "!**/AGENTS.md"
44
47
  ],
@@ -50,12 +53,13 @@
50
53
  "license": "MIT",
51
54
  "repository": {
52
55
  "type": "git",
53
- "url": "git+https://github.com/aoneahsan/native-update.git"
56
+ "url": "https://github.com/aoneahsan/native-update.git"
54
57
  },
55
58
  "bugs": {
56
59
  "url": "https://nativeupdate.aoneahsan.com/contact"
57
60
  },
58
61
  "homepage": "https://nativeupdate.aoneahsan.com",
62
+ "funding": "https://aoneahsan.com/payment?project-id=native-update&project-identifier=native-update",
59
63
  "keywords": [
60
64
  "capacitor",
61
65
  "plugin",
@@ -78,8 +82,9 @@
78
82
  "build:prod": "rimraf ./dist && tsc && NODE_ENV=production rollup -c rollup.config.js",
79
83
  "clean": "rimraf ./dist",
80
84
  "tsc": "tsc",
85
+ "test": "vitest run tests",
81
86
  "watch": "tsc --watch",
82
- "lint": "eslint .",
87
+ "lint": "eslint . --max-warnings 0",
83
88
  "prettier": "prettier --write .",
84
89
  "prepublishOnly": "yarn build:prod",
85
90
  "swiftlint": "cd ios && swiftlint lint --fix --format --path Plugin --verbose"
@@ -89,25 +94,26 @@
89
94
  "chalk": "^5.6.2",
90
95
  "commander": "^15.0.0",
91
96
  "express": "^5.2.1",
92
- "ora": "^9.4.0",
97
+ "ora": "^9.4.1",
93
98
  "prompts": "^2.4.2"
94
99
  },
95
100
  "devDependencies": {
96
- "@capacitor/app": "^8.1.0",
97
- "@capacitor/core": "^8.4.1",
98
- "@capacitor/device": "^8.0.2",
101
+ "@capacitor/app": "^8.1.1",
102
+ "@capacitor/core": "^8.5.0",
103
+ "@capacitor/device": "^8.0.3",
99
104
  "@capacitor/filesystem": "^8.1.2",
100
105
  "@capacitor/preferences": "^8.0.1",
101
106
  "@rollup/plugin-node-resolve": "^16.0.3",
102
107
  "@rollup/plugin-terser": "^1.0.0",
103
- "@types/node": "^26.0.0",
104
- "@typescript-eslint/eslint-plugin": "^8.61.1",
105
- "@typescript-eslint/parser": "^8.61.1",
106
- "eslint": "^10.5.0",
107
- "prettier": "^3.8.4",
108
+ "@types/node": "^26.1.2",
109
+ "@typescript-eslint/eslint-plugin": "^8.66.0",
110
+ "@typescript-eslint/parser": "^8.66.0",
111
+ "eslint": "^10.8.0",
112
+ "prettier": "^3.9.6",
108
113
  "rimraf": "^6.1.3",
109
- "rollup": "^4.62.0",
110
- "typescript": "^6.0.3"
114
+ "rollup": "^4.62.4",
115
+ "typescript": "^6.0.3",
116
+ "vitest": "^4.1.10"
111
117
  },
112
118
  "peerDependencies": {
113
119
  "@capacitor/core": "^8.0.1",
@@ -121,5 +127,11 @@
121
127
  "android": {
122
128
  "src": "android"
123
129
  }
130
+ },
131
+ "resolutions": {
132
+ "brace-expansion": "5.0.9",
133
+ "node-gyp": "13.0.1",
134
+ "tar": "7.5.22",
135
+ "undici": "8.10.0"
124
136
  }
125
137
  }