@protobase/mobile 0.57.1 → 0.57.3
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/build.gradle +17 -0
- package/android/src/liveupdate/java/net/protobase/mobile/Bounded.java +30 -0
- package/android/src/liveupdate/java/net/protobase/mobile/BundleCheck.java +53 -0
- package/android/src/liveupdate/java/net/protobase/mobile/BundleRefused.java +9 -0
- package/android/src/liveupdate/java/net/protobase/mobile/BundleRemoval.java +33 -0
- package/android/src/liveupdate/java/net/protobase/mobile/GuardedLiveUpdate.java +138 -15
- package/android/src/liveupdate/java/net/protobase/mobile/Hex.java +42 -0
- package/android/src/liveupdate/java/net/protobase/mobile/ReleaseBinary.java +30 -0
- package/android/src/liveupdate/java/net/protobase/mobile/ReleaseDownload.java +128 -0
- package/android/src/liveupdate/java/net/protobase/mobile/ReleaseManifest.java +98 -0
- package/android/src/liveupdate/java/net/protobase/mobile/ReleaseOrder.java +46 -0
- package/android/src/liveupdate/java/net/protobase/mobile/ReleaseStatement.java +124 -0
- package/android/src/liveupdate/java/net/protobase/mobile/Sha256.java +53 -0
- package/ios/Sources/ProtobaseMobile/BundlesFolder.swift +26 -0
- package/ios/Sources/ProtobaseMobile/GuardedLiveUpdatePlugin.swift +95 -0
- package/ios/Sources/ProtobaseMobile/LiveUpdateDownload.swift +39 -0
- package/ios/Sources/ProtobaseMobile/LiveUpdateLoadCheck.swift +21 -0
- package/ios/Sources/ProtobaseMobile/LiveUpdateMethods.swift +15 -0
- package/ios/Sources/ProtobaseMobile/LiveUpdateSettings.swift +25 -0
- package/ios/Sources/ProtobaseMobile/LocalFileGuard.swift +8 -15
- package/ios/Sources/ProtobaseMobile/PageScriptFilter.swift +5 -3
- package/ios/Sources/ProtobaseMobile/RealPath.swift +8 -0
- package/ios/Sources/ProtobaseMobile/Refusal.swift +12 -0
- package/ios/Sources/ProtobaseMobile/ReleasesUrl.swift +13 -0
- package/ios/Sources/ProtobaseMobile/StockLiveUpdate.swift +58 -0
- package/package.json +2 -2
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
/** The app's own releases URL: https, or http to the device itself, where no one sits on the path; a bare origin and path. */
|
|
4
|
+
enum ReleasesUrl {
|
|
5
|
+
private static let loopbackHosts: Set<String> = ["localhost", "127.0.0.1", "::1", "[::1]"]
|
|
6
|
+
|
|
7
|
+
static func isOwnSource(_ text: String?) -> Bool {
|
|
8
|
+
guard let text, let parts = URLComponents(string: text), let host = parts.host, !host.isEmpty else { return false }
|
|
9
|
+
if parts.user != nil || parts.password != nil || parts.query != nil || parts.fragment != nil { return false }
|
|
10
|
+
if parts.scheme == "https" { return true }
|
|
11
|
+
return parts.scheme == "http" && loopbackHosts.contains(host)
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import Capacitor
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The stock live updater's plugin, held by the guard and never registered with the bridge, so page script reaches it by
|
|
5
|
+
* no name: Capacitor dispatches only to registered plugins, and PageScriptFilter refuses a plugin id the bridge has not
|
|
6
|
+
* registered before Capacitor could load it by class name. Looked up by its `@objc` name, so Protobase's package builds
|
|
7
|
+
* without the live updater's.
|
|
8
|
+
*/
|
|
9
|
+
final class StockLiveUpdate {
|
|
10
|
+
private static let className = "LiveUpdatePlugin"
|
|
11
|
+
|
|
12
|
+
let plugin: CAPPlugin & CAPBridgedPlugin
|
|
13
|
+
|
|
14
|
+
init(plugin: CAPPlugin & CAPBridgedPlugin) {
|
|
15
|
+
self.plugin = plugin
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** The stock plugin, not loaded yet, or nil when the app does not include it. */
|
|
19
|
+
static func make() -> StockLiveUpdate? {
|
|
20
|
+
guard let type = NSClassFromString(className) as? CAPPlugin.Type, let plugin = type.init() as? CAPPlugin & CAPBridgedPlugin else { return nil }
|
|
21
|
+
return StockLiveUpdate(plugin: plugin)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var methodNames: [String] {
|
|
25
|
+
plugin.pluginMethods.map(\.name)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
func responds(to method: String) -> Bool {
|
|
29
|
+
plugin.responds(to: Self.selector(method))
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Loads it as the bridge would (Capacitor's CAPPlugin+LoadInstance.swift), on `guarding`'s bridge, config and
|
|
34
|
+
* listeners, so its events reach the listeners page script added to the guard.
|
|
35
|
+
*/
|
|
36
|
+
func load(guardedBy guarding: CAPPlugin & CAPBridgedPlugin) {
|
|
37
|
+
plugin.bridge = guarding.bridge
|
|
38
|
+
plugin.webView = guarding.webView
|
|
39
|
+
plugin.shouldStringifyDatesInCalls = true
|
|
40
|
+
plugin.eventListeners = guarding.eventListeners
|
|
41
|
+
plugin.retainedEventArguments = guarding.retainedEventArguments
|
|
42
|
+
plugin.pluginId = plugin.identifier
|
|
43
|
+
plugin.pluginName = guarding.pluginName
|
|
44
|
+
plugin.load()
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Runs `method` as Capacitor would (CapacitorBridge.swift, handleJSCall), on a new call that holds only `options`. */
|
|
48
|
+
func forward(_ call: CAPPluginCall, _ method: String, options: [String: Any]) {
|
|
49
|
+
guard let forwarded = CAPPluginCall(callbackId: call.callbackId, methodName: method, options: options, success: call.successHandler, error: call.errorHandler) else {
|
|
50
|
+
fatalError("Capacitor made no plugin call")
|
|
51
|
+
}
|
|
52
|
+
plugin.perform(Self.selector(method), with: forwarded)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
private static func selector(_ method: String) -> Selector {
|
|
56
|
+
NSSelectorFromString(method + ":")
|
|
57
|
+
}
|
|
58
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/mobile",
|
|
3
|
-
"version": "0.57.
|
|
3
|
+
"version": "0.57.3",
|
|
4
4
|
"description": "The Capacitor that protobase mobile builds a Protobase app's iOS and Android projects with, at fixed versions, and the native plugins that keep page script away from the session and give the iOS app its bounce; installed by the CLI on first use.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"android/build.gradle",
|
|
23
23
|
"icon"
|
|
24
24
|
],
|
|
25
|
-
"nativeContract":
|
|
25
|
+
"nativeContract": 6,
|
|
26
26
|
"capacitor": {
|
|
27
27
|
"ios": {
|
|
28
28
|
"src": "ios"
|