@protobase/mobile 0.73.5 → 0.75.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.
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package net.protobase.mobile;
|
|
2
|
+
|
|
3
|
+
import java.net.URI;
|
|
4
|
+
import java.net.URISyntaxException;
|
|
5
|
+
import java.util.Locale;
|
|
6
|
+
import java.util.regex.Pattern;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Whether ProtobaseExternal may open a URL, as the server's tapUrl and the shell check it: at most 2048 characters with
|
|
10
|
+
* no whitespace or control character, parsed as an absolute `http` or `https` URL with a host.
|
|
11
|
+
*/
|
|
12
|
+
final class ExternalUrl {
|
|
13
|
+
|
|
14
|
+
private static final Pattern PLAIN = Pattern.compile("^[^\\s\\u0000-\\u001f\\u007f-\\u009f]+$");
|
|
15
|
+
|
|
16
|
+
private ExternalUrl() {}
|
|
17
|
+
|
|
18
|
+
static boolean allowed(String url) {
|
|
19
|
+
if (url == null || url.length() > 2048 || !PLAIN.matcher(url).matches()) return false;
|
|
20
|
+
URI uri;
|
|
21
|
+
try {
|
|
22
|
+
uri = new URI(url);
|
|
23
|
+
} catch (URISyntaxException e) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
String scheme = uri.getScheme() == null ? "" : uri.getScheme().toLowerCase(Locale.ROOT);
|
|
27
|
+
return (scheme.equals("https") || scheme.equals("http")) && uri.getHost() != null && !uri.getHost().isEmpty();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
package net.protobase.mobile;
|
|
2
|
+
|
|
3
|
+
import android.content.ActivityNotFoundException;
|
|
4
|
+
import android.content.Intent;
|
|
5
|
+
import android.net.Uri;
|
|
6
|
+
import com.getcapacitor.Plugin;
|
|
7
|
+
import com.getcapacitor.PluginCall;
|
|
8
|
+
import com.getcapacitor.PluginMethod;
|
|
9
|
+
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Opens an `http` or `https` URL outside the app, in the app the phone opens links with, such as a notification's url
|
|
13
|
+
* on another origin. Never a navigation of the WebView: Capacitor sends a navigation outside the WebView only for
|
|
14
|
+
* another host or scheme (Bridge.java launchIntent), so another port of the WebView's own host would load inside it.
|
|
15
|
+
*/
|
|
16
|
+
@CapacitorPlugin(name = "ProtobaseExternal")
|
|
17
|
+
public class ProtobaseExternal extends Plugin {
|
|
18
|
+
|
|
19
|
+
@PluginMethod
|
|
20
|
+
public void open(PluginCall call) {
|
|
21
|
+
String url = call.getString("url");
|
|
22
|
+
if (!ExternalUrl.allowed(url)) {
|
|
23
|
+
call.reject("ProtobaseExternal opens an absolute http or https URL only");
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
|
27
|
+
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
|
28
|
+
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
29
|
+
try {
|
|
30
|
+
getContext().startActivity(intent);
|
|
31
|
+
} catch (ActivityNotFoundException e) {
|
|
32
|
+
call.reject("No app opens " + Uri.parse(url).getScheme() + " links", "NO_BROWSER", e);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
call.resolve();
|
|
36
|
+
}
|
|
37
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/mobile",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.75.0",
|
|
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": 9,
|
|
26
26
|
"capacitor": {
|
|
27
27
|
"ios": {
|
|
28
28
|
"src": "ios"
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"@capacitor/core": "8.5.3",
|
|
42
42
|
"@capacitor/ios": "8.5.3",
|
|
43
43
|
"@capacitor/keyboard": "8.0.6",
|
|
44
|
+
"@capacitor/push-notifications": "8.1.3",
|
|
44
45
|
"@capacitor/splash-screen": "8.0.2",
|
|
45
46
|
"@capawesome/capacitor-live-update": "8.7.1"
|
|
46
47
|
}
|