@capgo/inappbrowser 6.8.20 → 6.9.2

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/README.md CHANGED
@@ -506,6 +506,7 @@ Reload the current web page.
506
506
  | **`showArrow`** | <code>boolean</code> | showArrow: if true an arrow would be shown instead of cross for closing the window | <code>false</code> | 1.2.5 |
507
507
  | **`ignoreUntrustedSSLError`** | <code>boolean</code> | ignoreUntrustedSSLError: if true, the webview will ignore untrusted SSL errors allowing the user to view the website. | <code>false</code> | 6.1.0 |
508
508
  | **`preShowScript`** | <code><a href="#string">String</a></code> | preShowScript: if isPresentAfterPageLoad is true and this variable is set the plugin will inject a script before showing the browser. This script will be run in an async context. The plugin will wait for the script to finish (max 10 seconds) | | 6.6.0 |
509
+ | **`proxyRequests`** | <code><a href="#string">String</a></code> | proxyRequests is a regex expression. Please see [this pr](https://github.com/Cap-go/capacitor-inappbrowser/pull/222) for more info. (Android only) | | 6.9.0 |
509
510
  | **`buttonNearDone`** | <code>{ ios: { iconType: 'sf-symbol' \| 'asset'; icon: <a href="#string">String</a>; }; android: { iconType: 'asset'; icon: <a href="#string">String</a>; width?: number; height?: number; }; }</code> | buttonNearDone allows for a creation of a custom button. Please see [buttonNearDone.md](/buttonNearDone.md) for more info. | | 6.7.0 |
510
511
 
511
512
 
@@ -28,6 +28,8 @@ import com.getcapacitor.annotation.Permission;
28
28
  import com.getcapacitor.annotation.PermissionCallback;
29
29
  import java.util.ArrayList;
30
30
  import java.util.Iterator;
31
+ import java.util.regex.Pattern;
32
+ import java.util.regex.PatternSyntaxException;
31
33
  import org.json.JSONException;
32
34
  import org.json.JSONObject;
33
35
 
@@ -426,6 +428,18 @@ public class InAppBrowserPlugin
426
428
  Boolean.TRUE.equals(call.getBoolean("ignoreUntrustedSSLError", false))
427
429
  );
428
430
 
431
+ String proxyRequestsStr = call.getString("proxyRequests");
432
+ if (proxyRequestsStr != null) {
433
+ try {
434
+ options.setProxyRequestsPattern(Pattern.compile(proxyRequestsStr));
435
+ } catch (PatternSyntaxException e) {
436
+ Log.e(
437
+ "WebViewDialog",
438
+ String.format("Pattern '%s' is not a valid pattern", proxyRequestsStr)
439
+ );
440
+ }
441
+ }
442
+
429
443
  try {
430
444
  Options.ButtonNearDone buttonNearDone =
431
445
  Options.ButtonNearDone.generateFromPluginCall(
@@ -552,10 +566,11 @@ public class InAppBrowserPlugin
552
566
  getContext(),
553
567
  android.R.style.Theme_NoTitleBar,
554
568
  options,
555
- InAppBrowserPlugin.this
569
+ InAppBrowserPlugin.this,
570
+ getBridge().getWebView()
556
571
  );
557
- webViewDialog.presentWebView();
558
572
  webViewDialog.activity = InAppBrowserPlugin.this.getActivity();
573
+ webViewDialog.presentWebView();
559
574
  }
560
575
  }
561
576
  );
@@ -573,6 +588,7 @@ public class InAppBrowserPlugin
573
588
  call.reject("No event data provided");
574
589
  return;
575
590
  }
591
+
576
592
  Log.d("InAppBrowserPlugin", "Event data: " + eventData.toString());
577
593
  this.getActivity()
578
594
  .runOnUiThread(
@@ -624,6 +640,26 @@ public class InAppBrowserPlugin
624
640
  call.resolve();
625
641
  }
626
642
 
643
+ @PluginMethod
644
+ public void lsuakdchgbbaHandleProxiedRequest(PluginCall call) {
645
+ if (webViewDialog != null) {
646
+ Boolean ok = call.getBoolean("ok", false);
647
+ String id = call.getString("id");
648
+ if (id == null) {
649
+ Log.e("InAppBrowserProxy", "CRITICAL ERROR, proxy id = null");
650
+ return;
651
+ }
652
+ if (Boolean.FALSE.equals(ok)) {
653
+ String result = call.getString("result", "");
654
+ webViewDialog.handleProxyResultError(result, id);
655
+ } else {
656
+ JSONObject object = call.getObject("result");
657
+ webViewDialog.handleProxyResultOk(object, id);
658
+ }
659
+ }
660
+ call.resolve();
661
+ }
662
+
627
663
  @PluginMethod
628
664
  public void close(PluginCall call) {
629
665
  this.getActivity()
@@ -7,6 +7,7 @@ import com.getcapacitor.PluginCall;
7
7
  import java.io.IOException;
8
8
  import java.io.InputStream;
9
9
  import java.util.Objects;
10
+ import java.util.regex.Pattern;
10
11
 
11
12
  public class Options {
12
13
 
@@ -129,6 +130,15 @@ public class Options {
129
130
  private boolean ShowArrow;
130
131
  private boolean ignoreUntrustedSSLError;
131
132
  private String preShowScript;
133
+ private Pattern proxyRequestsPattern = null;
134
+
135
+ public Pattern getProxyRequestsPattern() {
136
+ return proxyRequestsPattern;
137
+ }
138
+
139
+ public void setProxyRequestsPattern(Pattern proxyRequestsPattern) {
140
+ this.proxyRequestsPattern = proxyRequestsPattern;
141
+ }
132
142
 
133
143
  public PluginCall getPluginCall() {
134
144
  return pluginCall;
@@ -15,11 +15,11 @@ import android.graphics.Picture;
15
15
  import android.graphics.drawable.PictureDrawable;
16
16
  import android.net.Uri;
17
17
  import android.net.http.SslError;
18
+ import android.os.Build;
18
19
  import android.text.TextUtils;
20
+ import android.util.Base64;
19
21
  import android.util.Log;
20
- import android.view.KeyEvent;
21
22
  import android.view.View;
22
- import android.view.ViewGroup.LayoutParams;
23
23
  import android.view.Window;
24
24
  import android.view.WindowManager;
25
25
  import android.webkit.HttpAuthHandler;
@@ -30,39 +30,67 @@ import android.webkit.ValueCallback;
30
30
  import android.webkit.WebChromeClient;
31
31
  import android.webkit.WebResourceError;
32
32
  import android.webkit.WebResourceRequest;
33
+ import android.webkit.WebResourceResponse;
33
34
  import android.webkit.WebView;
34
35
  import android.webkit.WebViewClient;
35
36
  import android.widget.ImageButton;
36
37
  import android.widget.TextView;
37
38
  import android.widget.Toast;
38
39
  import android.widget.Toolbar;
39
- import androidx.annotation.Nullable;
40
+ import androidx.annotation.RequiresApi;
40
41
  import com.caverock.androidsvg.SVG;
41
42
  import com.caverock.androidsvg.SVGParseException;
42
43
  import com.getcapacitor.JSObject;
44
+ import java.io.ByteArrayInputStream;
43
45
  import java.io.IOException;
44
46
  import java.io.InputStream;
47
+ import java.net.CookiePolicy;
45
48
  import java.net.URI;
46
49
  import java.net.URISyntaxException;
50
+ import java.net.URL;
51
+ import java.nio.charset.StandardCharsets;
47
52
  import java.util.Arrays;
48
53
  import java.util.HashMap;
49
54
  import java.util.Iterator;
55
+ import java.util.List;
50
56
  import java.util.Map;
51
57
  import java.util.Objects;
58
+ import java.util.UUID;
52
59
  import java.util.concurrent.ExecutorService;
53
60
  import java.util.concurrent.Executors;
54
61
  import java.util.concurrent.Semaphore;
55
62
  import java.util.concurrent.TimeUnit;
63
+ import java.util.function.Consumer;
64
+ import java.util.regex.Matcher;
65
+ import java.util.regex.Pattern;
66
+ import org.json.JSONException;
56
67
  import org.json.JSONObject;
57
68
 
58
69
  public class WebViewDialog extends Dialog {
59
70
 
71
+ private class ProxiedRequest {
72
+
73
+ private WebResourceResponse response;
74
+ private Semaphore semaphore;
75
+
76
+ public WebResourceResponse getResponse() {
77
+ return response;
78
+ }
79
+
80
+ public ProxiedRequest() {
81
+ this.semaphore = new Semaphore(0);
82
+ this.response = null;
83
+ }
84
+ }
85
+
60
86
  private WebView _webView;
61
87
  private Toolbar _toolbar;
62
88
  private Options _options;
63
89
  private Context _context;
64
90
  public Activity activity;
65
91
  private boolean isInitialized = false;
92
+ private WebView capacitorWebView;
93
+ private HashMap<String, ProxiedRequest> proxiedRequestsHashmap;
66
94
 
67
95
  Semaphore preShowSemaphore = null;
68
96
  String preshowError = null;
@@ -85,13 +113,16 @@ public class WebViewDialog extends Dialog {
85
113
  Context context,
86
114
  int theme,
87
115
  Options options,
88
- PermissionHandler permissionHandler
116
+ PermissionHandler permissionHandler,
117
+ WebView capacitorWebView
89
118
  ) {
90
119
  super(context, theme);
91
120
  this._options = options;
92
121
  this._context = context;
93
122
  this.permissionHandler = permissionHandler;
94
123
  this.isInitialized = false;
124
+ this.capacitorWebView = capacitorWebView;
125
+ this.proxiedRequestsHashmap = new HashMap<>();
95
126
  }
96
127
 
97
128
  public class JavaScriptInterface {
@@ -570,6 +601,91 @@ public class WebViewDialog extends Dialog {
570
601
  }
571
602
  }
572
603
 
604
+ public void handleProxyResultError(String result, String id) {
605
+ Log.i(
606
+ "InAppBrowserProxy",
607
+ String.format(
608
+ "handleProxyResultError: %s, ok: %s id: %s",
609
+ result,
610
+ false,
611
+ id
612
+ )
613
+ );
614
+ ProxiedRequest proxiedRequest = proxiedRequestsHashmap.get(id);
615
+ if (proxiedRequest == null) {
616
+ Log.e("InAppBrowserProxy", "proxiedRequest is null");
617
+ return;
618
+ }
619
+ proxiedRequestsHashmap.remove(id);
620
+ proxiedRequest.semaphore.release();
621
+ }
622
+
623
+ public void handleProxyResultOk(JSONObject result, String id) {
624
+ Log.i(
625
+ "InAppBrowserProxy",
626
+ String.format("handleProxyResultOk: %s, ok: %s, id: %s", result, true, id)
627
+ );
628
+ ProxiedRequest proxiedRequest = proxiedRequestsHashmap.get(id);
629
+ if (proxiedRequest == null) {
630
+ Log.e("InAppBrowserProxy", "proxiedRequest is null");
631
+ return;
632
+ }
633
+ proxiedRequestsHashmap.remove(id);
634
+
635
+ if (result == null) {
636
+ proxiedRequest.semaphore.release();
637
+ return;
638
+ }
639
+
640
+ Map<String, String> responseHeaders = new HashMap<>();
641
+ String body;
642
+ int code;
643
+
644
+ try {
645
+ body = result.getString("body");
646
+ code = result.getInt("code");
647
+ JSONObject headers = result.getJSONObject("headers");
648
+ for (Iterator<String> it = headers.keys(); it.hasNext();) {
649
+ String headerName = it.next();
650
+ String header = headers.getString(headerName);
651
+ responseHeaders.put(headerName, header);
652
+ }
653
+ } catch (JSONException e) {
654
+ Log.e("InAppBrowserProxy", "Cannot parse OK result", e);
655
+ return;
656
+ }
657
+
658
+ String contentType = responseHeaders.get("Content-Type");
659
+ if (contentType == null) {
660
+ contentType = responseHeaders.get("content-type");
661
+ }
662
+ if (contentType == null) {
663
+ Log.e("InAppBrowserProxy", "'Content-Type' header is required");
664
+ return;
665
+ }
666
+
667
+ if (!((100 <= code && code <= 299) || (400 <= code && code <= 599))) {
668
+ Log.e(
669
+ "InAppBrowserProxy",
670
+ String.format("Status code %s outside of the allowed range", code)
671
+ );
672
+ return;
673
+ }
674
+
675
+ WebResourceResponse webResourceResponse = new WebResourceResponse(
676
+ contentType,
677
+ "utf-8",
678
+ new ByteArrayInputStream(body.getBytes(StandardCharsets.UTF_8))
679
+ );
680
+
681
+ webResourceResponse.setStatusCodeAndReasonPhrase(
682
+ code,
683
+ getReasonPhrase(code)
684
+ );
685
+ proxiedRequest.response = webResourceResponse;
686
+ proxiedRequest.semaphore.release();
687
+ }
688
+
573
689
  private void setWebViewClient() {
574
690
  _webView.setWebViewClient(
575
691
  new WebViewClient() {
@@ -578,6 +694,9 @@ public class WebViewDialog extends Dialog {
578
694
  WebView view,
579
695
  WebResourceRequest request
580
696
  ) {
697
+ // HashMap<String, String> map = new HashMap<>();
698
+ // map.put("x-requested-with", null);
699
+ // view.loadUrl(request.getUrl().toString(), map);
581
700
  Context context = view.getContext();
582
701
  String url = request.getUrl().toString();
583
702
 
@@ -602,6 +721,104 @@ public class WebViewDialog extends Dialog {
602
721
  return false;
603
722
  }
604
723
 
724
+ private String randomRequestId() {
725
+ return UUID.randomUUID().toString();
726
+ }
727
+
728
+ private String toBase64(String raw) {
729
+ String s = Base64.encodeToString(raw.getBytes(), Base64.NO_WRAP);
730
+ if (s.endsWith("=")) {
731
+ s = s.substring(0, s.length() - 2);
732
+ }
733
+ return s;
734
+ }
735
+
736
+ //
737
+ // void handleRedirect(String currentUrl, Response response) {
738
+ // String loc = response.header("Location");
739
+ // _webView.evaluateJavascript("");
740
+ // }
741
+ //
742
+ @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
743
+ @Override
744
+ public WebResourceResponse shouldInterceptRequest(
745
+ WebView view,
746
+ WebResourceRequest request
747
+ ) {
748
+ Pattern pattern = _options.getProxyRequestsPattern();
749
+ if (pattern == null) {
750
+ return null;
751
+ }
752
+ Matcher matcher = pattern.matcher(request.getUrl().toString());
753
+ if (!matcher.find()) {
754
+ return null;
755
+ }
756
+
757
+ // Requests matches the regex
758
+ if (Objects.equals(request.getMethod(), "POST")) {
759
+ // Log.e("HTTP", String.format("returned null (ok) %s", request.getUrl().toString()));
760
+ return null;
761
+ }
762
+
763
+ Log.i(
764
+ "InAppBrowserProxy",
765
+ String.format("Proxying request: %s", request.getUrl().toString())
766
+ );
767
+
768
+ // We need to call a JS function
769
+ String requestId = randomRequestId();
770
+ ProxiedRequest proxiedRequest = new ProxiedRequest();
771
+ proxiedRequestsHashmap.put(requestId, proxiedRequest);
772
+
773
+ // lsuakdchgbbaHandleProxiedRequest
774
+ activity.runOnUiThread(
775
+ new Runnable() {
776
+ @Override
777
+ public void run() {
778
+ StringBuilder headers = new StringBuilder();
779
+ Map<String, String> requestHeaders =
780
+ request.getRequestHeaders();
781
+ for (Map.Entry<
782
+ String,
783
+ String
784
+ > header : requestHeaders.entrySet()) {
785
+ headers.append(
786
+ String.format(
787
+ "h[atob('%s')]=atob('%s');",
788
+ toBase64(header.getKey()),
789
+ toBase64(header.getValue())
790
+ )
791
+ );
792
+ }
793
+ String s = String.format(
794
+ "try {function getHeaders() {const h = {}; %s return h}; window.InAppBrowserProxyRequest(new Request(atob('%s'), {headers: getHeaders(), method: '%s'})).then(async (res) => Capacitor.Plugins.InAppBrowser.lsuakdchgbbaHandleProxiedRequest({ok: true, result: (!!res ? {headers: Object.fromEntries(res.headers.entries()), code: res.status, body: (await res.text())} : null), id: '%s'})).catch((e) => Capacitor.Plugins.InAppBrowser.lsuakdchgbbaHandleProxiedRequest({ok: false, result: e.toString(), id: '%s'}))} catch (e) {Capacitor.Plugins.InAppBrowser.lsuakdchgbbaHandleProxiedRequest({ok: false, result: e.toString(), id: '%s'})}",
795
+ headers,
796
+ toBase64(request.getUrl().toString()),
797
+ request.getMethod(),
798
+ requestId,
799
+ requestId,
800
+ requestId
801
+ );
802
+ // Log.i("HTTP", s);
803
+ capacitorWebView.evaluateJavascript(s, null);
804
+ }
805
+ }
806
+ );
807
+
808
+ // 10 seconds wait max
809
+ try {
810
+ if (proxiedRequest.semaphore.tryAcquire(1, 10, TimeUnit.SECONDS)) {
811
+ return proxiedRequest.response;
812
+ } else {
813
+ Log.e("InAppBrowserProxy", "Semaphore timed out");
814
+ proxiedRequestsHashmap.remove(requestId); // prevent mem leak
815
+ }
816
+ } catch (InterruptedException e) {
817
+ Log.e("InAppBrowserProxy", "Semaphore wait error", e);
818
+ }
819
+ return null;
820
+ }
821
+
605
822
  @Override
606
823
  public void onReceivedHttpAuthRequest(
607
824
  WebView view,
@@ -817,4 +1034,101 @@ public class WebViewDialog extends Dialog {
817
1034
  super.onBackPressed();
818
1035
  }
819
1036
  }
1037
+
1038
+ public static String getReasonPhrase(int statusCode) {
1039
+ switch (statusCode) {
1040
+ case (200):
1041
+ return "OK";
1042
+ case (201):
1043
+ return "Created";
1044
+ case (202):
1045
+ return "Accepted";
1046
+ case (203):
1047
+ return "Non Authoritative Information";
1048
+ case (204):
1049
+ return "No Content";
1050
+ case (205):
1051
+ return "Reset Content";
1052
+ case (206):
1053
+ return "Partial Content";
1054
+ case (207):
1055
+ return "Partial Update OK";
1056
+ case (300):
1057
+ return "Mutliple Choices";
1058
+ case (301):
1059
+ return "Moved Permanently";
1060
+ case (302):
1061
+ return "Moved Temporarily";
1062
+ case (303):
1063
+ return "See Other";
1064
+ case (304):
1065
+ return "Not Modified";
1066
+ case (305):
1067
+ return "Use Proxy";
1068
+ case (307):
1069
+ return "Temporary Redirect";
1070
+ case (400):
1071
+ return "Bad Request";
1072
+ case (401):
1073
+ return "Unauthorized";
1074
+ case (402):
1075
+ return "Payment Required";
1076
+ case (403):
1077
+ return "Forbidden";
1078
+ case (404):
1079
+ return "Not Found";
1080
+ case (405):
1081
+ return "Method Not Allowed";
1082
+ case (406):
1083
+ return "Not Acceptable";
1084
+ case (407):
1085
+ return "Proxy Authentication Required";
1086
+ case (408):
1087
+ return "Request Timeout";
1088
+ case (409):
1089
+ return "Conflict";
1090
+ case (410):
1091
+ return "Gone";
1092
+ case (411):
1093
+ return "Length Required";
1094
+ case (412):
1095
+ return "Precondition Failed";
1096
+ case (413):
1097
+ return "Request Entity Too Large";
1098
+ case (414):
1099
+ return "Request-URI Too Long";
1100
+ case (415):
1101
+ return "Unsupported Media Type";
1102
+ case (416):
1103
+ return "Requested Range Not Satisfiable";
1104
+ case (417):
1105
+ return "Expectation Failed";
1106
+ case (418):
1107
+ return "Reauthentication Required";
1108
+ case (419):
1109
+ return "Proxy Reauthentication Required";
1110
+ case (422):
1111
+ return "Unprocessable Entity";
1112
+ case (423):
1113
+ return "Locked";
1114
+ case (424):
1115
+ return "Failed Dependency";
1116
+ case (500):
1117
+ return "Server Error";
1118
+ case (501):
1119
+ return "Not Implemented";
1120
+ case (502):
1121
+ return "Bad Gateway";
1122
+ case (503):
1123
+ return "Service Unavailable";
1124
+ case (504):
1125
+ return "Gateway Timeout";
1126
+ case (505):
1127
+ return "HTTP Version Not Supported";
1128
+ case (507):
1129
+ return "Insufficient Storage";
1130
+ default:
1131
+ return "";
1132
+ }
1133
+ }
820
1134
  }
package/dist/docs.json CHANGED
@@ -938,6 +938,20 @@
938
938
  ],
939
939
  "type": "String"
940
940
  },
941
+ {
942
+ "name": "proxyRequests",
943
+ "tags": [
944
+ {
945
+ "text": "6.9.0",
946
+ "name": "since"
947
+ }
948
+ ],
949
+ "docs": "proxyRequests is a regex expression. Please see [this pr](https://github.com/Cap-go/capacitor-inappbrowser/pull/222) for more info. (Android only)",
950
+ "complexTypes": [
951
+ "String"
952
+ ],
953
+ "type": "String"
954
+ },
941
955
  {
942
956
  "name": "buttonNearDone",
943
957
  "tags": [
@@ -224,6 +224,12 @@ export interface OpenWebViewOptions {
224
224
  * @since 6.6.0
225
225
  */
226
226
  preShowScript?: String;
227
+ /**
228
+ * proxyRequests is a regex expression. Please see [this pr](https://github.com/Cap-go/capacitor-inappbrowser/pull/222) for more info. (Android only)
229
+ *
230
+ * @since 6.9.0
231
+ */
232
+ proxyRequests?: String;
227
233
  /**
228
234
  * buttonNearDone allows for a creation of a custom button. Please see [buttonNearDone.md](/buttonNearDone.md) for more info.
229
235
  *
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAuBA,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,kCAAe,CAAA;IACf,kCAAe,CAAA;AACjB,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AACD,MAAM,CAAN,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,oCAAqB,CAAA;IACrB,wCAAyB,CAAA;IACzB,8BAAe,CAAA;IACf,2BAAY,CAAA;AACd,CAAC,EALW,WAAW,KAAX,WAAW,QAKtB","sourcesContent":["import type { PluginListenerHandle } from \"@capacitor/core\";\n\nexport interface UrlEvent {\n /**\n * Emit when the url changes\n *\n * @since 0.0.1\n */\n url: string;\n}\nexport interface BtnEvent {\n /**\n * Emit when a button is clicked.\n *\n * @since 0.0.1\n */\n url: string;\n}\n\nexport type UrlChangeListener = (state: UrlEvent) => void;\nexport type ConfirmBtnListener = (state: BtnEvent) => void;\nexport type ButtonNearListener = (state: {}) => void;\n\nexport enum BackgroundColor {\n WHITE = \"white\",\n BLACK = \"black\",\n}\nexport enum ToolBarType {\n ACTIVITY = \"activity\",\n NAVIGATION = \"navigation\",\n BLANK = \"blank\",\n DEFAULT = \"\",\n}\n\nexport interface Headers {\n [key: string]: string;\n}\n\nexport interface GetCookieOptions {\n url: string;\n includeHttpOnly?: boolean;\n}\n\nexport interface ClearCookieOptions {\n url: string;\n}\n\nexport interface Credentials {\n username: string;\n password: string;\n}\n\nexport interface OpenOptions {\n /**\n * Target URL to load.\n * @since 0.1.0\n */\n url: string;\n /**\n * Headers to send with the request.\n * @since 0.1.0\n */\n headers?: Headers;\n /**\n * Credentials to send with the request and all subsequent requests for the same host.\n * @since 6.1.0\n */\n credentials?: Credentials;\n /**\n * if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately.\n * @since 0.1.0\n */\n isPresentAfterPageLoad?: boolean;\n preventDeeplink?: boolean;\n}\n\nexport interface DisclaimerOptions {\n title: string;\n message: string;\n confirmBtn: string;\n cancelBtn: string;\n}\n\nexport interface OpenWebViewOptions {\n /**\n * Target URL to load.\n * @since 0.1.0\n */\n url: string;\n /**\n * Headers to send with the request.\n * @since 0.1.0\n */\n headers?: Headers;\n /**\n * Credentials to send with the request and all subsequent requests for the same host.\n * @since 6.1.0\n */\n credentials?: Credentials;\n /**\n * share options\n * @since 0.1.0\n */\n shareDisclaimer?: DisclaimerOptions;\n /**\n * Toolbar type\n * @since 0.1.0\n * @default ToolBarType.DEFAULT\n */\n toolbarType?: ToolBarType;\n /**\n * Share subject\n * @since 0.1.0\n */\n shareSubject?: string;\n /**\n * Title of the browser\n * @since 0.1.0\n * @default 'New Window'\n */\n title?: string;\n /**\n * Background color of the browser, only on IOS\n * @since 0.1.0\n * @default BackgroundColor.BLACK\n */\n backgroundColor?: BackgroundColor;\n /**\n * If true, active the native navigation within the webview, Android only\n *\n * @default false\n */\n activeNativeNavigationForWebview?: boolean;\n /**\n * Disable the possibility to go back on native application,\n * usefull to force user to stay on the webview, Android only\n *\n * @default false\n */\n disableGoBackOnNativeApplication?: boolean;\n /**\n * Open url in a new window fullscreen\n *\n * isPresentAfterPageLoad: if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately.\n * @since 0.1.0\n * @default false\n */\n isPresentAfterPageLoad?: boolean;\n /**\n * Whether the website in the webview is inspectable or not, ios only\n *\n * @default false\n */\n isInspectable?: boolean;\n /**\n * Whether the webview opening is animated or not, ios only\n *\n * @default true\n */\n isAnimated?: boolean;\n /**\n * Shows a reload button that reloads the web page\n * @since 1.0.15\n * @default false\n */\n showReloadButton?: boolean;\n /**\n * CloseModal: if true a confirm will be displayed when user clicks on close button, if false the browser will be closed immediately.\n *\n * @since 1.1.0\n * @default false\n */\n closeModal?: boolean;\n /**\n * CloseModalTitle: title of the confirm when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Close'\n */\n closeModalTitle?: string;\n /**\n * CloseModalDescription: description of the confirm when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Are you sure you want to close this window?'\n */\n closeModalDescription?: string;\n /**\n * CloseModalOk: text of the confirm button when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Close'\n */\n closeModalOk?: string;\n /**\n * CloseModalCancel: text of the cancel button when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Cancel'\n */\n closeModalCancel?: string;\n /**\n * visibleTitle: if true the website title would be shown else shown empty\n *\n * @since 1.2.5\n * @default true\n */\n visibleTitle?: boolean;\n /**\n * toolbarColor: color of the toolbar in hex format\n *\n * @since 1.2.5\n * @default '#ffffff''\n */\n toolbarColor?: string;\n /**\n * showArrow: if true an arrow would be shown instead of cross for closing the window\n *\n * @since 1.2.5\n * @default false\n */\n showArrow?: boolean;\n /**\n * ignoreUntrustedSSLError: if true, the webview will ignore untrusted SSL errors allowing the user to view the website.\n *\n * @since 6.1.0\n * @default false\n */\n ignoreUntrustedSSLError?: boolean;\n /**\n * preShowScript: if isPresentAfterPageLoad is true and this variable is set the plugin will inject a script before showing the browser.\n * This script will be run in an async context. The plugin will wait for the script to finish (max 10 seconds)\n *\n * @since 6.6.0\n */\n preShowScript?: String;\n /**\n * buttonNearDone allows for a creation of a custom button. Please see [buttonNearDone.md](/buttonNearDone.md) for more info.\n *\n * @since 6.7.0\n */\n buttonNearDone?: {\n ios: {\n iconType: \"sf-symbol\" | \"asset\";\n icon: String;\n };\n android: {\n iconType: \"asset\";\n icon: String;\n width?: number;\n height?: number;\n };\n };\n}\n\nexport interface InAppBrowserPlugin {\n /**\n * Open url in a new window fullscreen\n *\n * @since 0.1.0\n */\n open(options: OpenOptions): Promise<any>;\n\n /**\n * Clear cookies of url\n *\n * @since 0.5.0\n */\n clearCookies(options: ClearCookieOptions): Promise<any>;\n /**\n * Clear all cookies\n *\n * @since 6.5.0\n */\n clearAllCookies(): Promise<any>;\n\n /**\n * Clear cache\n *\n * @since 6.5.0\n */\n clearCache(): Promise<any>;\n\n /**\n * Get cookies for a specific URL.\n * @param options The options, including the URL to get cookies for.\n * @returns A promise that resolves with the cookies.\n */\n getCookies(options: GetCookieOptions): Promise<Record<string, string>>;\n /**\n * Close the webview.\n */\n close(): Promise<any>;\n /**\n * Open url in a new webview with toolbars\n *\n * @since 0.1.0\n */\n openWebView(options: OpenWebViewOptions): Promise<any>;\n /**\n * Injects JavaScript code into the InAppBrowser window.\n */\n executeScript({ code }: { code: string }): Promise<void>;\n /**\n * Sends an event to the webview. you can listen to this event with addListener(\"messageFromWebview\", listenerFunc: (event: Record<string, any>) => void)\n * detail is the data you want to send to the webview, it's a requirement of Capacitor we cannot send direct objects\n * Your object has to be serializable to JSON, so no functions or other non-JSON-serializable types are allowed.\n */\n postMessage(options: { detail: Record<string, any> }): Promise<void>;\n /**\n * Sets the URL of the webview.\n */\n setUrl(options: { url: string }): Promise<any>;\n /**\n * Listen for url change, only for openWebView\n *\n * @since 0.0.1\n */\n addListener(\n eventName: \"urlChangeEvent\",\n listenerFunc: UrlChangeListener,\n ): Promise<PluginListenerHandle>;\n\n addListener(\n eventName: \"buttonNearDoneClick\",\n listenerFunc: ButtonNearListener,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for close click only for openWebView\n *\n * @since 0.4.0\n */\n addListener(\n eventName: \"closeEvent\",\n listenerFunc: UrlChangeListener,\n ): Promise<PluginListenerHandle>;\n /**\n * Will be triggered when user clicks on confirm button when disclaimer is required, works only on iOS\n *\n * @since 0.0.1\n */\n addListener(\n eventName: \"confirmBtnClicked\",\n listenerFunc: ConfirmBtnListener,\n ): Promise<PluginListenerHandle>;\n /**\n * Will be triggered when event is sent from webview, to send an event to the webview use window.mobileApp.postMessage({ \"detail\": { \"message\": \"myMessage\" } })\n * detail is the data you want to send to the webview, it's a requirement of Capacitor we cannot send direct objects\n * Your object has to be serializable to JSON, so no functions or other non-JSON-serializable types are allowed.\n *\n * This method is inject at runtime in the webview\n */\n addListener(\n eventName: \"messageFromWebview\",\n listenerFunc: (event: { detail: Record<string, any> }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Will be triggered when page is loaded\n */\n addListener(\n eventName: \"browserPageLoaded\",\n listenerFunc: () => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Will be triggered when page load error\n */\n addListener(\n eventName: \"pageLoadError\",\n listenerFunc: () => void,\n ): Promise<PluginListenerHandle>;\n /**\n * Remove all listeners for this plugin.\n *\n * @since 1.0.0\n */\n removeAllListeners(): Promise<void>;\n\n /**\n * Reload the current web page.\n *\n * @since 1.0.0\n */\n reload(): Promise<any>; // Add this line\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAuBA,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,kCAAe,CAAA;IACf,kCAAe,CAAA;AACjB,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AACD,MAAM,CAAN,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,oCAAqB,CAAA;IACrB,wCAAyB,CAAA;IACzB,8BAAe,CAAA;IACf,2BAAY,CAAA;AACd,CAAC,EALW,WAAW,KAAX,WAAW,QAKtB","sourcesContent":["import type { PluginListenerHandle } from \"@capacitor/core\";\n\nexport interface UrlEvent {\n /**\n * Emit when the url changes\n *\n * @since 0.0.1\n */\n url: string;\n}\nexport interface BtnEvent {\n /**\n * Emit when a button is clicked.\n *\n * @since 0.0.1\n */\n url: string;\n}\n\nexport type UrlChangeListener = (state: UrlEvent) => void;\nexport type ConfirmBtnListener = (state: BtnEvent) => void;\nexport type ButtonNearListener = (state: {}) => void;\n\nexport enum BackgroundColor {\n WHITE = \"white\",\n BLACK = \"black\",\n}\nexport enum ToolBarType {\n ACTIVITY = \"activity\",\n NAVIGATION = \"navigation\",\n BLANK = \"blank\",\n DEFAULT = \"\",\n}\n\nexport interface Headers {\n [key: string]: string;\n}\n\nexport interface GetCookieOptions {\n url: string;\n includeHttpOnly?: boolean;\n}\n\nexport interface ClearCookieOptions {\n url: string;\n}\n\nexport interface Credentials {\n username: string;\n password: string;\n}\n\nexport interface OpenOptions {\n /**\n * Target URL to load.\n * @since 0.1.0\n */\n url: string;\n /**\n * Headers to send with the request.\n * @since 0.1.0\n */\n headers?: Headers;\n /**\n * Credentials to send with the request and all subsequent requests for the same host.\n * @since 6.1.0\n */\n credentials?: Credentials;\n /**\n * if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately.\n * @since 0.1.0\n */\n isPresentAfterPageLoad?: boolean;\n preventDeeplink?: boolean;\n}\n\nexport interface DisclaimerOptions {\n title: string;\n message: string;\n confirmBtn: string;\n cancelBtn: string;\n}\n\nexport interface OpenWebViewOptions {\n /**\n * Target URL to load.\n * @since 0.1.0\n */\n url: string;\n /**\n * Headers to send with the request.\n * @since 0.1.0\n */\n headers?: Headers;\n /**\n * Credentials to send with the request and all subsequent requests for the same host.\n * @since 6.1.0\n */\n credentials?: Credentials;\n /**\n * share options\n * @since 0.1.0\n */\n shareDisclaimer?: DisclaimerOptions;\n /**\n * Toolbar type\n * @since 0.1.0\n * @default ToolBarType.DEFAULT\n */\n toolbarType?: ToolBarType;\n /**\n * Share subject\n * @since 0.1.0\n */\n shareSubject?: string;\n /**\n * Title of the browser\n * @since 0.1.0\n * @default 'New Window'\n */\n title?: string;\n /**\n * Background color of the browser, only on IOS\n * @since 0.1.0\n * @default BackgroundColor.BLACK\n */\n backgroundColor?: BackgroundColor;\n /**\n * If true, active the native navigation within the webview, Android only\n *\n * @default false\n */\n activeNativeNavigationForWebview?: boolean;\n /**\n * Disable the possibility to go back on native application,\n * usefull to force user to stay on the webview, Android only\n *\n * @default false\n */\n disableGoBackOnNativeApplication?: boolean;\n /**\n * Open url in a new window fullscreen\n *\n * isPresentAfterPageLoad: if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately.\n * @since 0.1.0\n * @default false\n */\n isPresentAfterPageLoad?: boolean;\n /**\n * Whether the website in the webview is inspectable or not, ios only\n *\n * @default false\n */\n isInspectable?: boolean;\n /**\n * Whether the webview opening is animated or not, ios only\n *\n * @default true\n */\n isAnimated?: boolean;\n /**\n * Shows a reload button that reloads the web page\n * @since 1.0.15\n * @default false\n */\n showReloadButton?: boolean;\n /**\n * CloseModal: if true a confirm will be displayed when user clicks on close button, if false the browser will be closed immediately.\n *\n * @since 1.1.0\n * @default false\n */\n closeModal?: boolean;\n /**\n * CloseModalTitle: title of the confirm when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Close'\n */\n closeModalTitle?: string;\n /**\n * CloseModalDescription: description of the confirm when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Are you sure you want to close this window?'\n */\n closeModalDescription?: string;\n /**\n * CloseModalOk: text of the confirm button when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Close'\n */\n closeModalOk?: string;\n /**\n * CloseModalCancel: text of the cancel button when user clicks on close button, only on IOS\n *\n * @since 1.1.0\n * @default 'Cancel'\n */\n closeModalCancel?: string;\n /**\n * visibleTitle: if true the website title would be shown else shown empty\n *\n * @since 1.2.5\n * @default true\n */\n visibleTitle?: boolean;\n /**\n * toolbarColor: color of the toolbar in hex format\n *\n * @since 1.2.5\n * @default '#ffffff''\n */\n toolbarColor?: string;\n /**\n * showArrow: if true an arrow would be shown instead of cross for closing the window\n *\n * @since 1.2.5\n * @default false\n */\n showArrow?: boolean;\n /**\n * ignoreUntrustedSSLError: if true, the webview will ignore untrusted SSL errors allowing the user to view the website.\n *\n * @since 6.1.0\n * @default false\n */\n ignoreUntrustedSSLError?: boolean;\n /**\n * preShowScript: if isPresentAfterPageLoad is true and this variable is set the plugin will inject a script before showing the browser.\n * This script will be run in an async context. The plugin will wait for the script to finish (max 10 seconds)\n *\n * @since 6.6.0\n */\n preShowScript?: String;\n /**\n * proxyRequests is a regex expression. Please see [this pr](https://github.com/Cap-go/capacitor-inappbrowser/pull/222) for more info. (Android only)\n *\n * @since 6.9.0\n */\n proxyRequests?: String;\n /**\n * buttonNearDone allows for a creation of a custom button. Please see [buttonNearDone.md](/buttonNearDone.md) for more info.\n *\n * @since 6.7.0\n */\n buttonNearDone?: {\n ios: {\n iconType: \"sf-symbol\" | \"asset\";\n icon: String;\n };\n android: {\n iconType: \"asset\";\n icon: String;\n width?: number;\n height?: number;\n };\n };\n}\n\nexport interface InAppBrowserPlugin {\n /**\n * Open url in a new window fullscreen\n *\n * @since 0.1.0\n */\n open(options: OpenOptions): Promise<any>;\n\n /**\n * Clear cookies of url\n *\n * @since 0.5.0\n */\n clearCookies(options: ClearCookieOptions): Promise<any>;\n /**\n * Clear all cookies\n *\n * @since 6.5.0\n */\n clearAllCookies(): Promise<any>;\n\n /**\n * Clear cache\n *\n * @since 6.5.0\n */\n clearCache(): Promise<any>;\n\n /**\n * Get cookies for a specific URL.\n * @param options The options, including the URL to get cookies for.\n * @returns A promise that resolves with the cookies.\n */\n getCookies(options: GetCookieOptions): Promise<Record<string, string>>;\n /**\n * Close the webview.\n */\n close(): Promise<any>;\n /**\n * Open url in a new webview with toolbars\n *\n * @since 0.1.0\n */\n openWebView(options: OpenWebViewOptions): Promise<any>;\n /**\n * Injects JavaScript code into the InAppBrowser window.\n */\n executeScript({ code }: { code: string }): Promise<void>;\n /**\n * Sends an event to the webview. you can listen to this event with addListener(\"messageFromWebview\", listenerFunc: (event: Record<string, any>) => void)\n * detail is the data you want to send to the webview, it's a requirement of Capacitor we cannot send direct objects\n * Your object has to be serializable to JSON, so no functions or other non-JSON-serializable types are allowed.\n */\n postMessage(options: { detail: Record<string, any> }): Promise<void>;\n /**\n * Sets the URL of the webview.\n */\n setUrl(options: { url: string }): Promise<any>;\n /**\n * Listen for url change, only for openWebView\n *\n * @since 0.0.1\n */\n addListener(\n eventName: \"urlChangeEvent\",\n listenerFunc: UrlChangeListener,\n ): Promise<PluginListenerHandle>;\n\n addListener(\n eventName: \"buttonNearDoneClick\",\n listenerFunc: ButtonNearListener,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for close click only for openWebView\n *\n * @since 0.4.0\n */\n addListener(\n eventName: \"closeEvent\",\n listenerFunc: UrlChangeListener,\n ): Promise<PluginListenerHandle>;\n /**\n * Will be triggered when user clicks on confirm button when disclaimer is required, works only on iOS\n *\n * @since 0.0.1\n */\n addListener(\n eventName: \"confirmBtnClicked\",\n listenerFunc: ConfirmBtnListener,\n ): Promise<PluginListenerHandle>;\n /**\n * Will be triggered when event is sent from webview, to send an event to the webview use window.mobileApp.postMessage({ \"detail\": { \"message\": \"myMessage\" } })\n * detail is the data you want to send to the webview, it's a requirement of Capacitor we cannot send direct objects\n * Your object has to be serializable to JSON, so no functions or other non-JSON-serializable types are allowed.\n *\n * This method is inject at runtime in the webview\n */\n addListener(\n eventName: \"messageFromWebview\",\n listenerFunc: (event: { detail: Record<string, any> }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Will be triggered when page is loaded\n */\n addListener(\n eventName: \"browserPageLoaded\",\n listenerFunc: () => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Will be triggered when page load error\n */\n addListener(\n eventName: \"pageLoadError\",\n listenerFunc: () => void,\n ): Promise<PluginListenerHandle>;\n /**\n * Remove all listeners for this plugin.\n *\n * @since 1.0.0\n */\n removeAllListeners(): Promise<void>;\n\n /**\n * Reload the current web page.\n *\n * @since 1.0.0\n */\n reload(): Promise<any>; // Add this line\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/inappbrowser",
3
- "version": "6.8.20",
3
+ "version": "6.9.2",
4
4
  "description": "Capacitor plugin in app browser",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",