@capgo/inappbrowser 7.17.0 → 7.19.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/README.md CHANGED
@@ -268,7 +268,7 @@ Open url in a new webview with toolbars, and enhanced capabilities, like camera
268
268
  JavaScript Interface:
269
269
  When you open a webview with this method, a JavaScript interface is automatically injected that provides:
270
270
  - `window.mobileApp.close()`: Closes the webview from JavaScript
271
- - `window.mobileApp.postMessage({detail: {message: 'myMessage'}})`: Sends a message from the webview to the app, detail object is the data you want to send to the webview
271
+ - `window.mobileApp.postMessage({detail: {message: "myMessage"}})`: Sends a message from the webview to the app, detail object is the data you want to send to the webview
272
272
 
273
273
  | Param | Type |
274
274
  | ------------- | ----------------------------------------------------------------- |
@@ -392,7 +392,8 @@ Listen for close click only for openWebView
392
392
  addListener(eventName: "confirmBtnClicked", listenerFunc: ConfirmBtnListener) => Promise<PluginListenerHandle>
393
393
  ```
394
394
 
395
- Will be triggered when user clicks on confirm button when disclaimer is required
395
+ Will be triggered when user clicks on confirm button when disclaimer is required,
396
+ works with openWebView shareDisclaimer and closeModal
396
397
 
397
398
  | Param | Type |
398
399
  | ------------------ | ----------------------------------------------------------------- |
@@ -540,7 +541,7 @@ Reload the current web page.
540
541
  | **`shareDisclaimer`** | <code><a href="#disclaimeroptions">DisclaimerOptions</a></code> | Share options for the webview. When provided, shows a disclaimer dialog before sharing content. This is useful for: - Warning users about sharing sensitive information - Getting user consent before sharing - Explaining what will be shared - Complying with privacy regulations Note: shareSubject is required when using shareDisclaimer | | 0.1.0 |
541
542
  | **`toolbarType`** | <code><a href="#toolbartype">ToolBarType</a></code> | Toolbar type determines the appearance and behavior of the browser's toolbar - "activity": Shows a simple toolbar with just a close button and share button - "navigation": Shows a full navigation toolbar with back/forward buttons - "blank": Shows no toolbar - "": Default toolbar with close button | <code>ToolBarType.DEFAULT</code> | 0.1.0 |
542
543
  | **`shareSubject`** | <code>string</code> | Subject text for sharing. Required when using shareDisclaimer. This text will be used as the subject line when sharing content. | | 0.1.0 |
543
- | **`title`** | <code>string</code> | Title of the browser | <code>'New Window'</code> | 0.1.0 |
544
+ | **`title`** | <code>string</code> | Title of the browser | <code>"New Window"</code> | 0.1.0 |
544
545
  | **`backgroundColor`** | <code><a href="#backgroundcolor">BackgroundColor</a></code> | Background color of the browser | <code>BackgroundColor.BLACK</code> | 0.1.0 |
545
546
  | **`activeNativeNavigationForWebview`** | <code>boolean</code> | If true, active the native navigation within the webview, Android only | <code>false</code> | |
546
547
  | **`disableGoBackOnNativeApplication`** | <code>boolean</code> | Disable the possibility to go back on native application, useful to force user to stay on the webview, Android only | <code>false</code> | |
@@ -549,12 +550,12 @@ Reload the current web page.
549
550
  | **`isAnimated`** | <code>boolean</code> | Whether the webview opening is animated or not, ios only | <code>true</code> | |
550
551
  | **`showReloadButton`** | <code>boolean</code> | Shows a reload button that reloads the web page | <code>false</code> | 1.0.15 |
551
552
  | **`closeModal`** | <code>boolean</code> | CloseModal: if true a confirm will be displayed when user clicks on close button, if false the browser will be closed immediately. | <code>false</code> | 1.1.0 |
552
- | **`closeModalTitle`** | <code>string</code> | CloseModalTitle: title of the confirm when user clicks on close button | <code>'Close'</code> | 1.1.0 |
553
- | **`closeModalDescription`** | <code>string</code> | CloseModalDescription: description of the confirm when user clicks on close button | <code>'Are you sure you want to close this window?'</code> | 1.1.0 |
554
- | **`closeModalOk`** | <code>string</code> | CloseModalOk: text of the confirm button when user clicks on close button | <code>'Close'</code> | 1.1.0 |
555
- | **`closeModalCancel`** | <code>string</code> | CloseModalCancel: text of the cancel button when user clicks on close button | <code>'Cancel'</code> | 1.1.0 |
553
+ | **`closeModalTitle`** | <code>string</code> | CloseModalTitle: title of the confirm when user clicks on close button | <code>"Close"</code> | 1.1.0 |
554
+ | **`closeModalDescription`** | <code>string</code> | CloseModalDescription: description of the confirm when user clicks on close button | <code>"Are you sure you want to close this window?"</code> | 1.1.0 |
555
+ | **`closeModalOk`** | <code>string</code> | CloseModalOk: text of the confirm button when user clicks on close button | <code>"Close"</code> | 1.1.0 |
556
+ | **`closeModalCancel`** | <code>string</code> | CloseModalCancel: text of the cancel button when user clicks on close button | <code>"Cancel"</code> | 1.1.0 |
556
557
  | **`visibleTitle`** | <code>boolean</code> | visibleTitle: if true the website title would be shown else shown empty | <code>true</code> | 1.2.5 |
557
- | **`toolbarColor`** | <code>string</code> | toolbarColor: color of the toolbar in hex format | <code>'#ffffff'</code> | 1.2.5 |
558
+ | **`toolbarColor`** | <code>string</code> | toolbarColor: color of the toolbar in hex format | <code>"#ffffff"</code> | 1.2.5 |
558
559
  | **`toolbarTextColor`** | <code>string</code> | toolbarTextColor: color of the buttons and title in the toolbar in hex format When set, it overrides the automatic light/dark mode detection for text color | <code>calculated based on toolbarColor brightness</code> | 6.10.0 |
559
560
  | **`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 |
560
561
  | **`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 |
@@ -566,6 +567,7 @@ Reload the current web page.
566
567
  | **`authorizedAppLinks`** | <code>string[]</code> | List of URL base patterns that should be treated as authorized App Links, Android only. Only links starting with any of these base URLs will be opened in the InAppBrowser. | <code>[]</code> | 7.12.0 |
567
568
  | **`enabledSafeBottomMargin`** | <code>boolean</code> | If true, the webView will not take the full height and will have a 20px margin at the bottom. This creates a safe margin area outside the browser view. | <code>false</code> | 7.13.0 |
568
569
  | **`enableGooglePaySupport`** | <code>boolean</code> | enableGooglePaySupport: if true, enables support for Google Pay popups and Payment Request API. This fixes OR_BIBED_15 errors by allowing popup windows and configuring Cross-Origin-Opener-Policy. Only enable this if you need Google Pay functionality as it allows popup windows. When enabled: - Allows popup windows for Google Pay authentication - Sets proper CORS headers for Payment Request API - Enables multiple window support in WebView - Configures secure context for payment processing | <code>false</code> | 7.13.0 |
570
+ | **`blockedHosts`** | <code>string[]</code> | blockedHosts: List of host patterns that should be blocked from loading in the InAppBrowser's internal navigations. Any request inside WebView to a URL with a host matching any of these patterns will be blocked. Supports wildcard patterns like: - "*.example.com" to block all subdomains - "www.example.*" to block wildcard domain extensions | <code>[]</code> | 7.17.0 |
569
571
 
570
572
 
571
573
  #### Headers
@@ -688,8 +688,8 @@ public class InAppBrowserPlugin
688
688
  }
689
689
 
690
690
  @Override
691
- public void confirmBtnClicked() {
692
- notifyListeners("confirmBtnClicked", new JSObject());
691
+ public void confirmBtnClicked(String url) {
692
+ notifyListeners("confirmBtnClicked", new JSObject().put("url", url));
693
693
  }
694
694
 
695
695
  @Override
@@ -757,6 +757,29 @@ public class InAppBrowserPlugin
757
757
  Log.d("InAppBrowserPlugin", "No authorized app links provided.");
758
758
  }
759
759
 
760
+ JSArray blockedHostsRaw = call.getArray("blockedHosts");
761
+ if (blockedHostsRaw != null && blockedHostsRaw.length() > 0) {
762
+ List<String> blockedHosts = new ArrayList<>();
763
+ for (int i = 0; i < blockedHostsRaw.length(); i++) {
764
+ try {
765
+ String host = blockedHostsRaw.getString(i);
766
+ if (host != null && !host.trim().isEmpty()) {
767
+ blockedHosts.add(host);
768
+ }
769
+ } catch (Exception e) {
770
+ Log.w(
771
+ "InAppBrowserPlugin",
772
+ "Error reading blocked host at index " + i,
773
+ e
774
+ );
775
+ }
776
+ }
777
+ Log.d("InAppBrowserPlugin", "Parsed blocked hosts: " + blockedHosts);
778
+ options.setBlockedHosts(blockedHosts);
779
+ } else {
780
+ Log.d("InAppBrowserPlugin", "No blocked hosts provided.");
781
+ }
782
+
760
783
  // Set Google Pay support option
761
784
  options.setEnableGooglePaySupport(
762
785
  Boolean.TRUE.equals(call.getBoolean("enableGooglePaySupport", false))
@@ -182,6 +182,7 @@ public class Options {
182
182
  private List<String> authorizedAppLinks = new ArrayList<>();
183
183
  private boolean enabledSafeBottomMargin = false;
184
184
  private boolean enableGooglePaySupport = false;
185
+ private List<String> blockedHosts = new ArrayList<>();
185
186
 
186
187
  public int getTextZoom() {
187
188
  return textZoom;
@@ -452,4 +453,15 @@ public class Options {
452
453
  public void setEnableGooglePaySupport(boolean enableGooglePaySupport) {
453
454
  this.enableGooglePaySupport = enableGooglePaySupport;
454
455
  }
456
+
457
+ public List<String> getBlockedHosts() {
458
+ if (blockedHosts != null) {
459
+ return blockedHosts;
460
+ }
461
+ return new ArrayList<>();
462
+ }
463
+
464
+ public void setBlockedHosts(List<String> blockedHosts) {
465
+ this.blockedHosts = blockedHosts;
466
+ }
455
467
  }
@@ -13,5 +13,5 @@ public interface WebViewCallbacks {
13
13
 
14
14
  public void buttonNearDoneClicked();
15
15
 
16
- public void confirmBtnClicked();
16
+ public void confirmBtnClicked(String url);
17
17
  }
@@ -1140,7 +1140,7 @@ public class WebViewDialog extends Dialog {
1140
1140
  }
1141
1141
 
1142
1142
  // These stay the same for all Android versions
1143
- mlp.topMargin = 0;
1143
+ mlp.topMargin = insets.top;
1144
1144
  mlp.leftMargin = insets.left;
1145
1145
  mlp.rightMargin = insets.right;
1146
1146
  v.setLayoutParams(mlp);
@@ -1870,6 +1870,8 @@ public class WebViewDialog extends Dialog {
1870
1870
  String currentUrl = getUrl();
1871
1871
  dismiss();
1872
1872
  if (_options != null && _options.getCallbacks() != null) {
1873
+ // Notify that confirm was clicked
1874
+ _options.getCallbacks().confirmBtnClicked(currentUrl);
1873
1875
  _options.getCallbacks().closeEvent(currentUrl);
1874
1876
  }
1875
1877
  }
@@ -2201,7 +2203,9 @@ public class WebViewDialog extends Dialog {
2201
2203
  .setPositiveButton(
2202
2204
  shareDisclaimer.getString("confirmBtn", "Confirm"),
2203
2205
  (dialog, which) -> {
2204
- _options.getCallbacks().confirmBtnClicked();
2206
+ // Notify that confirm was clicked
2207
+ String currentUrl = getUrl();
2208
+ _options.getCallbacks().confirmBtnClicked(currentUrl);
2205
2209
  shareUrl();
2206
2210
  }
2207
2211
  )
@@ -2394,6 +2398,124 @@ public class WebViewDialog extends Dialog {
2394
2398
  return false;
2395
2399
  }
2396
2400
 
2401
+ /**
2402
+ * Checks if a host should be blocked based on the configured blocked hosts patterns
2403
+ * @param url The URL to check
2404
+ * @param blockedHosts The list of blocked hosts patterns
2405
+ * @return true if the host should be blocked, false otherwise
2406
+ */
2407
+ private boolean shouldBlockHost(String url, List<String> blockedHosts) {
2408
+ Uri uri = Uri.parse(url);
2409
+ String host = uri.getHost();
2410
+
2411
+ if (host == null || host.isEmpty()) {
2412
+ return false;
2413
+ }
2414
+
2415
+ if (blockedHosts == null || blockedHosts.isEmpty()) {
2416
+ return false;
2417
+ }
2418
+
2419
+ String normalizedHost = host.toLowerCase();
2420
+
2421
+ for (String blockPattern : blockedHosts) {
2422
+ if (
2423
+ blockPattern != null &&
2424
+ matchesBlockPattern(normalizedHost, blockPattern.toLowerCase())
2425
+ ) {
2426
+ Log.d("InAppBrowser", "Blocked host detected: " + host);
2427
+ return true;
2428
+ }
2429
+ }
2430
+
2431
+ return false;
2432
+ }
2433
+
2434
+ /**
2435
+ * Matches a host against a blocking pattern (supports wildcards)
2436
+ * @param host The normalized host to check
2437
+ * @param pattern The normalized blocking pattern
2438
+ * @return true if the host matches the pattern
2439
+ */
2440
+ private boolean matchesBlockPattern(String host, String pattern) {
2441
+ if (pattern == null || pattern.isEmpty()) {
2442
+ return false;
2443
+ }
2444
+
2445
+ // Exact match - fastest check first
2446
+ if (host.equals(pattern)) {
2447
+ return true;
2448
+ }
2449
+
2450
+ // No wildcards - already checked exact match above
2451
+ if (!pattern.contains("*")) {
2452
+ return false;
2453
+ }
2454
+
2455
+ // Handle wildcard patterns
2456
+ if (pattern.startsWith("*.")) {
2457
+ return matchesWildcardDomain(host, pattern);
2458
+ } else if (pattern.contains("*")) {
2459
+ return matchesRegexPattern(host, pattern);
2460
+ }
2461
+
2462
+ return false;
2463
+ }
2464
+
2465
+ /**
2466
+ * Handles simple subdomain wildcard patterns like "*.example.com"
2467
+ * @param host The host to check
2468
+ * @param pattern The wildcard pattern starting with "*."
2469
+ * @return true if the host matches the wildcard domain
2470
+ */
2471
+ private boolean matchesWildcardDomain(String host, String pattern) {
2472
+ String domain = pattern.substring(2); // Remove "*."
2473
+
2474
+ if (domain.isEmpty()) {
2475
+ return false;
2476
+ }
2477
+
2478
+ // Match exact domain or any subdomain
2479
+ return host.equals(domain) || host.endsWith("." + domain);
2480
+ }
2481
+
2482
+ /**
2483
+ * Handles complex regex patterns with multiple wildcards
2484
+ * @param host The host to check
2485
+ * @param pattern The pattern with wildcards to convert to regex
2486
+ * @return true if the host matches the regex pattern
2487
+ */
2488
+ private boolean matchesRegexPattern(String host, String pattern) {
2489
+ try {
2490
+ // Escape special regex characters except *
2491
+ String escapedPattern = pattern
2492
+ .replace("\\", "\\\\") // Must escape backslashes first
2493
+ .replace(".", "\\.")
2494
+ .replace("+", "\\+")
2495
+ .replace("?", "\\?")
2496
+ .replace("^", "\\^")
2497
+ .replace("$", "\\$")
2498
+ .replace("(", "\\(")
2499
+ .replace(")", "\\)")
2500
+ .replace("[", "\\[")
2501
+ .replace("]", "\\]")
2502
+ .replace("{", "\\{")
2503
+ .replace("}", "\\}")
2504
+ .replace("|", "\\|");
2505
+
2506
+ // Convert wildcards to regex
2507
+ String regexPattern = "^" + escapedPattern.replace("*", ".*") + "$";
2508
+
2509
+ return Pattern.matches(regexPattern, host);
2510
+ } catch (Exception e) {
2511
+ Log.e(
2512
+ "InAppBrowser",
2513
+ "Invalid regex pattern '" + pattern + "': " + e.getMessage()
2514
+ );
2515
+ return false;
2516
+ }
2517
+ }
2518
+
2397
2519
  @Override
2398
2520
  public boolean shouldOverrideUrlLoading(
2399
2521
  WebView view,
@@ -2463,6 +2585,25 @@ public class WebViewDialog extends Dialog {
2463
2585
  // Do nothing
2464
2586
  }
2465
2587
  }
2588
+
2589
+ // Check for blocked hosts (main-frame only) using the extracted function
2590
+ List<String> blockedHosts = _options.getBlockedHosts();
2591
+ if (
2592
+ blockedHosts != null &&
2593
+ !blockedHosts.isEmpty() &&
2594
+ request.isForMainFrame()
2595
+ ) {
2596
+ Log.d("InAppBrowser", "Checking for blocked hosts (on main frame)");
2597
+ if (shouldBlockHost(url, blockedHosts)) {
2598
+ // Make sure to notify that a URL has changed even when it was blocked
2599
+ if (_options.getCallbacks() != null) {
2600
+ _options.getCallbacks().urlChangeEvent(url);
2601
+ }
2602
+ Log.d("InAppBrowser", "Navigation blocked for URL: " + url);
2603
+ return true; // Block the navigation
2604
+ }
2605
+ }
2606
+
2466
2607
  return false;
2467
2608
  }
2468
2609
 
package/dist/docs.json CHANGED
@@ -136,7 +136,7 @@
136
136
  "text": "0.1.0"
137
137
  }
138
138
  ],
139
- "docs": "Open url in a new webview with toolbars, and enhanced capabilities, like camera access, file access, listen events, inject javascript, bi directional communication, etc.\n\nJavaScript Interface:\nWhen you open a webview with this method, a JavaScript interface is automatically injected that provides:\n- `window.mobileApp.close()`: Closes the webview from JavaScript\n- `window.mobileApp.postMessage({detail: {message: 'myMessage'}})`: Sends a message from the webview to the app, detail object is the data you want to send to the webview",
139
+ "docs": "Open url in a new webview with toolbars, and enhanced capabilities, like camera access, file access, listen events, inject javascript, bi directional communication, etc.\n\nJavaScript Interface:\nWhen you open a webview with this method, a JavaScript interface is automatically injected that provides:\n- `window.mobileApp.close()`: Closes the webview from JavaScript\n- `window.mobileApp.postMessage({detail: {message: \"myMessage\"}})`: Sends a message from the webview to the app, detail object is the data you want to send to the webview",
140
140
  "complexTypes": [
141
141
  "OpenWebViewOptions"
142
142
  ],
@@ -296,7 +296,7 @@
296
296
  "text": "0.0.1"
297
297
  }
298
298
  ],
299
- "docs": "Will be triggered when user clicks on confirm button when disclaimer is required",
299
+ "docs": "Will be triggered when user clicks on confirm button when disclaimer is required,\nworks with openWebView shareDisclaimer and closeModal",
300
300
  "complexTypes": [
301
301
  "PluginListenerHandle",
302
302
  "ConfirmBtnListener"
@@ -552,7 +552,7 @@
552
552
  "name": "since"
553
553
  },
554
554
  {
555
- "text": "headers: {\n 'Custom-Header': 'test-value',\n 'Authorization': 'Bearer test-token'\n}\nTest URL: https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending/",
555
+ "text": "headers: {\n \"Custom-Header\": \"test-value\",\n \"Authorization\": \"Bearer test-token\"\n}\nTest URL: https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending/",
556
556
  "name": "example"
557
557
  }
558
558
  ],
@@ -570,7 +570,7 @@
570
570
  "name": "since"
571
571
  },
572
572
  {
573
- "text": "credentials: {\n username: 'test-user',\n password: 'test-pass'\n}\nTest URL: https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending/",
573
+ "text": "credentials: {\n username: \"test-user\",\n password: \"test-pass\"\n}\nTest URL: https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending/",
574
574
  "name": "example"
575
575
  }
576
576
  ],
@@ -604,7 +604,7 @@
604
604
  "name": "jsInterface",
605
605
  "tags": [
606
606
  {
607
- "text": "// In your webpage loaded in the webview:\ndocument.getElementById('closeBtn').addEventListener('click', () => {\n window.mobileApp.close();\n});\n\n// Send data to the app\nwindow.mobileApp.postMessage({ action: 'login', data: { user: 'test' }});",
607
+ "text": "// In your webpage loaded in the webview:\ndocument.getElementById(\"closeBtn\").addEventListener(\"click\", () => {\n window.mobileApp.close();\n});\n\n// Send data to the app\nwindow.mobileApp.postMessage({ action: \"login\", data: { user: \"test\" }});",
608
608
  "name": "example"
609
609
  },
610
610
  {
@@ -624,7 +624,7 @@
624
624
  "name": "since"
625
625
  },
626
626
  {
627
- "text": "shareDisclaimer: {\n title: 'Disclaimer',\n message: 'This is a test disclaimer',\n confirmBtn: 'Accept',\n cancelBtn: 'Decline'\n}\nTest URL: https://capgo.app",
627
+ "text": "shareDisclaimer: {\n title: \"Disclaimer\",\n message: \"This is a test disclaimer\",\n confirmBtn: \"Accept\",\n cancelBtn: \"Decline\"\n}\nTest URL: https://capgo.app",
628
628
  "name": "example"
629
629
  }
630
630
  ],
@@ -646,7 +646,7 @@
646
646
  "name": "default"
647
647
  },
648
648
  {
649
- "text": "toolbarType: ToolBarType.ACTIVITY,\ntitle: 'Activity Toolbar Test'\nTest URL: https://capgo.app",
649
+ "text": "toolbarType: ToolBarType.ACTIVITY,\ntitle: \"Activity Toolbar Test\"\nTest URL: https://capgo.app",
650
650
  "name": "example"
651
651
  }
652
652
  ],
@@ -680,7 +680,7 @@
680
680
  "name": "since"
681
681
  },
682
682
  {
683
- "text": "'New Window'",
683
+ "text": "\"New Window\"",
684
684
  "name": "default"
685
685
  },
686
686
  {
@@ -818,7 +818,7 @@
818
818
  "name": "default"
819
819
  },
820
820
  {
821
- "text": "closeModal: true,\ncloseModalTitle: 'Close Window',\ncloseModalDescription: 'Are you sure you want to close?',\ncloseModalOk: 'Yes, close',\ncloseModalCancel: 'No, stay'\nTest URL: https://capgo.app",
821
+ "text": "closeModal: true,\ncloseModalTitle: \"Close Window\",\ncloseModalDescription: \"Are you sure you want to close?\",\ncloseModalOk: \"Yes, close\",\ncloseModalCancel: \"No, stay\"\nTest URL: https://capgo.app",
822
822
  "name": "example"
823
823
  }
824
824
  ],
@@ -834,7 +834,7 @@
834
834
  "name": "since"
835
835
  },
836
836
  {
837
- "text": "'Close'",
837
+ "text": "\"Close\"",
838
838
  "name": "default"
839
839
  }
840
840
  ],
@@ -850,7 +850,7 @@
850
850
  "name": "since"
851
851
  },
852
852
  {
853
- "text": "'Are you sure you want to close this window?'",
853
+ "text": "\"Are you sure you want to close this window?\"",
854
854
  "name": "default"
855
855
  }
856
856
  ],
@@ -866,7 +866,7 @@
866
866
  "name": "since"
867
867
  },
868
868
  {
869
- "text": "'Close'",
869
+ "text": "\"Close\"",
870
870
  "name": "default"
871
871
  }
872
872
  ],
@@ -882,7 +882,7 @@
882
882
  "name": "since"
883
883
  },
884
884
  {
885
- "text": "'Cancel'",
885
+ "text": "\"Cancel\"",
886
886
  "name": "default"
887
887
  }
888
888
  ],
@@ -914,11 +914,11 @@
914
914
  "name": "since"
915
915
  },
916
916
  {
917
- "text": "'#ffffff'",
917
+ "text": "\"#ffffff\"",
918
918
  "name": "default"
919
919
  },
920
920
  {
921
- "text": "toolbarColor: '#FF5733'\nTest URL: https://capgo.app",
921
+ "text": "toolbarColor: \"#FF5733\"\nTest URL: https://capgo.app",
922
922
  "name": "example"
923
923
  }
924
924
  ],
@@ -938,7 +938,7 @@
938
938
  "name": "default"
939
939
  },
940
940
  {
941
- "text": "toolbarTextColor: '#FFFFFF'\nTest URL: https://capgo.app",
941
+ "text": "toolbarTextColor: \"#FFFFFF\"\nTest URL: https://capgo.app",
942
942
  "name": "example"
943
943
  }
944
944
  ],
@@ -1018,7 +1018,7 @@
1018
1018
  "name": "since"
1019
1019
  },
1020
1020
  {
1021
- "text": "buttonNearDone: {\n ios: {\n iconType: 'sf-symbol',\n icon: 'star.fill'\n },\n android: {\n iconType: 'asset',\n icon: 'public/monkey.svg',\n width: 24,\n height: 24\n }\n}\nTest URL: https://capgo.app",
1021
+ "text": "buttonNearDone: {\n ios: {\n iconType: \"sf-symbol\",\n icon: \"star.fill\"\n },\n android: {\n iconType: \"asset\",\n icon: \"public/monkey.svg\",\n width: 24,\n height: 24\n }\n}\nTest URL: https://capgo.app",
1022
1022
  "name": "example"
1023
1023
  }
1024
1024
  ],
@@ -1121,6 +1121,26 @@
1121
1121
  "docs": "enableGooglePaySupport: if true, enables support for Google Pay popups and Payment Request API.\nThis fixes OR_BIBED_15 errors by allowing popup windows and configuring Cross-Origin-Opener-Policy.\nOnly enable this if you need Google Pay functionality as it allows popup windows.\n\nWhen enabled:\n- Allows popup windows for Google Pay authentication\n- Sets proper CORS headers for Payment Request API\n- Enables multiple window support in WebView\n- Configures secure context for payment processing",
1122
1122
  "complexTypes": [],
1123
1123
  "type": "boolean | undefined"
1124
+ },
1125
+ {
1126
+ "name": "blockedHosts",
1127
+ "tags": [
1128
+ {
1129
+ "text": "7.17.0",
1130
+ "name": "since"
1131
+ },
1132
+ {
1133
+ "text": "[]",
1134
+ "name": "default"
1135
+ },
1136
+ {
1137
+ "text": "blockedHosts: [\"*.tracking.com\", \"ads.example.com\"]",
1138
+ "name": "example"
1139
+ }
1140
+ ],
1141
+ "docs": "blockedHosts: List of host patterns that should be blocked from loading in the InAppBrowser's internal navigations.\nAny request inside WebView to a URL with a host matching any of these patterns will be blocked.\nSupports wildcard patterns like:\n- \"*.example.com\" to block all subdomains\n- \"www.example.*\" to block wildcard domain extensions",
1142
+ "complexTypes": [],
1143
+ "type": "string[] | undefined"
1124
1144
  }
1125
1145
  ]
1126
1146
  },
@@ -109,8 +109,8 @@ export interface OpenWebViewOptions {
109
109
  * @since 0.1.0
110
110
  * @example
111
111
  * headers: {
112
- * 'Custom-Header': 'test-value',
113
- * 'Authorization': 'Bearer test-token'
112
+ * "Custom-Header": "test-value",
113
+ * "Authorization": "Bearer test-token"
114
114
  * }
115
115
  * Test URL: https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending/
116
116
  */
@@ -120,8 +120,8 @@ export interface OpenWebViewOptions {
120
120
  * @since 6.1.0
121
121
  * @example
122
122
  * credentials: {
123
- * username: 'test-user',
124
- * password: 'test-pass'
123
+ * username: "test-user",
124
+ * password: "test-pass"
125
125
  * }
126
126
  * Test URL: https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending/
127
127
  */
@@ -144,12 +144,12 @@ export interface OpenWebViewOptions {
144
144
  *
145
145
  * @example
146
146
  * // In your webpage loaded in the webview:
147
- * document.getElementById('closeBtn').addEventListener('click', () => {
147
+ * document.getElementById("closeBtn").addEventListener("click", () => {
148
148
  * window.mobileApp.close();
149
149
  * });
150
150
  *
151
151
  * // Send data to the app
152
- * window.mobileApp.postMessage({ action: 'login', data: { user: 'test' }});
152
+ * window.mobileApp.postMessage({ action: "login", data: { user: "test" }});
153
153
  *
154
154
  * @since 6.10.0
155
155
  */
@@ -166,10 +166,10 @@ export interface OpenWebViewOptions {
166
166
  * @since 0.1.0
167
167
  * @example
168
168
  * shareDisclaimer: {
169
- * title: 'Disclaimer',
170
- * message: 'This is a test disclaimer',
171
- * confirmBtn: 'Accept',
172
- * cancelBtn: 'Decline'
169
+ * title: "Disclaimer",
170
+ * message: "This is a test disclaimer",
171
+ * confirmBtn: "Accept",
172
+ * cancelBtn: "Decline"
173
173
  * }
174
174
  * Test URL: https://capgo.app
175
175
  */
@@ -184,7 +184,7 @@ export interface OpenWebViewOptions {
184
184
  * @default ToolBarType.DEFAULT
185
185
  * @example
186
186
  * toolbarType: ToolBarType.ACTIVITY,
187
- * title: 'Activity Toolbar Test'
187
+ * title: "Activity Toolbar Test"
188
188
  * Test URL: https://capgo.app
189
189
  */
190
190
  toolbarType?: ToolBarType;
@@ -198,7 +198,7 @@ export interface OpenWebViewOptions {
198
198
  /**
199
199
  * Title of the browser
200
200
  * @since 0.1.0
201
- * @default 'New Window'
201
+ * @default "New Window"
202
202
  * @example "Camera Test"
203
203
  */
204
204
  title?: string;
@@ -262,35 +262,35 @@ export interface OpenWebViewOptions {
262
262
  * @default false
263
263
  * @example
264
264
  * closeModal: true,
265
- * closeModalTitle: 'Close Window',
266
- * closeModalDescription: 'Are you sure you want to close?',
267
- * closeModalOk: 'Yes, close',
268
- * closeModalCancel: 'No, stay'
265
+ * closeModalTitle: "Close Window",
266
+ * closeModalDescription: "Are you sure you want to close?",
267
+ * closeModalOk: "Yes, close",
268
+ * closeModalCancel: "No, stay"
269
269
  * Test URL: https://capgo.app
270
270
  */
271
271
  closeModal?: boolean;
272
272
  /**
273
273
  * CloseModalTitle: title of the confirm when user clicks on close button
274
274
  * @since 1.1.0
275
- * @default 'Close'
275
+ * @default "Close"
276
276
  */
277
277
  closeModalTitle?: string;
278
278
  /**
279
279
  * CloseModalDescription: description of the confirm when user clicks on close button
280
280
  * @since 1.1.0
281
- * @default 'Are you sure you want to close this window?'
281
+ * @default "Are you sure you want to close this window?"
282
282
  */
283
283
  closeModalDescription?: string;
284
284
  /**
285
285
  * CloseModalOk: text of the confirm button when user clicks on close button
286
286
  * @since 1.1.0
287
- * @default 'Close'
287
+ * @default "Close"
288
288
  */
289
289
  closeModalOk?: string;
290
290
  /**
291
291
  * CloseModalCancel: text of the cancel button when user clicks on close button
292
292
  * @since 1.1.0
293
- * @default 'Cancel'
293
+ * @default "Cancel"
294
294
  */
295
295
  closeModalCancel?: string;
296
296
  /**
@@ -302,9 +302,9 @@ export interface OpenWebViewOptions {
302
302
  /**
303
303
  * toolbarColor: color of the toolbar in hex format
304
304
  * @since 1.2.5
305
- * @default '#ffffff'
305
+ * @default "#ffffff"
306
306
  * @example
307
- * toolbarColor: '#FF5733'
307
+ * toolbarColor: "#FF5733"
308
308
  * Test URL: https://capgo.app
309
309
  */
310
310
  toolbarColor?: string;
@@ -314,7 +314,7 @@ export interface OpenWebViewOptions {
314
314
  * @since 6.10.0
315
315
  * @default calculated based on toolbarColor brightness
316
316
  * @example
317
- * toolbarTextColor: '#FFFFFF'
317
+ * toolbarTextColor: "#FFFFFF"
318
318
  * Test URL: https://capgo.app
319
319
  */
320
320
  toolbarTextColor?: string;
@@ -365,12 +365,12 @@ export interface OpenWebViewOptions {
365
365
  * @example
366
366
  * buttonNearDone: {
367
367
  * ios: {
368
- * iconType: 'sf-symbol',
369
- * icon: 'star.fill'
368
+ * iconType: "sf-symbol",
369
+ * icon: "star.fill"
370
370
  * },
371
371
  * android: {
372
- * iconType: 'asset',
373
- * icon: 'public/monkey.svg',
372
+ * iconType: "asset",
373
+ * icon: "public/monkey.svg",
374
374
  * width: 24,
375
375
  * height: 24
376
376
  * }
@@ -443,6 +443,19 @@ export interface OpenWebViewOptions {
443
443
  * Test URL: https://developers.google.com/pay/api/web/guides/tutorial
444
444
  */
445
445
  enableGooglePaySupport?: boolean;
446
+ /**
447
+ * blockedHosts: List of host patterns that should be blocked from loading in the InAppBrowser's internal navigations.
448
+ * Any request inside WebView to a URL with a host matching any of these patterns will be blocked.
449
+ * Supports wildcard patterns like:
450
+ * - "*.example.com" to block all subdomains
451
+ * - "www.example.*" to block wildcard domain extensions
452
+ *
453
+ * @since 7.17.0
454
+ * @default []
455
+ * @example
456
+ * blockedHosts: ["*.tracking.com", "ads.example.com"]
457
+ */
458
+ blockedHosts?: string[];
446
459
  }
447
460
  export interface InAppBrowserPlugin {
448
461
  /**
@@ -485,7 +498,7 @@ export interface InAppBrowserPlugin {
485
498
  * JavaScript Interface:
486
499
  * When you open a webview with this method, a JavaScript interface is automatically injected that provides:
487
500
  * - `window.mobileApp.close()`: Closes the webview from JavaScript
488
- * - `window.mobileApp.postMessage({detail: {message: 'myMessage'}})`: Sends a message from the webview to the app, detail object is the data you want to send to the webview
501
+ * - `window.mobileApp.postMessage({detail: {message: "myMessage"}})`: Sends a message from the webview to the app, detail object is the data you want to send to the webview
489
502
  *
490
503
  * @since 0.1.0
491
504
  */
@@ -524,7 +537,8 @@ export interface InAppBrowserPlugin {
524
537
  */
525
538
  addListener(eventName: "closeEvent", listenerFunc: UrlChangeListener): Promise<PluginListenerHandle>;
526
539
  /**
527
- * Will be triggered when user clicks on confirm button when disclaimer is required
540
+ * Will be triggered when user clicks on confirm button when disclaimer is required,
541
+ * works with openWebView shareDisclaimer and closeModal
528
542
  *
529
543
  * @since 0.0.1
530
544
  */
@@ -570,7 +584,7 @@ export interface InAppBrowserPlugin {
570
584
  * window.mobileApp.close();
571
585
  *
572
586
  * // Sending a message from webview to the native app
573
- * window.mobileApp.postMessage({ key: 'value' });
587
+ * window.mobileApp.postMessage({ key: "value" });
574
588
  *
575
589
  * @since 6.10.0
576
590
  */
@@ -584,9 +598,9 @@ export interface InAppBrowserWebViewAPIs {
584
598
  *
585
599
  * @example
586
600
  * // Add a button to close the webview
587
- * const closeButton = document.createElement('button');
588
- * closeButton.textContent = 'Close WebView';
589
- * closeButton.addEventListener('click', () => {
601
+ * const closeButton = document.createElement("button");
602
+ * closeButton.textContent = "Close WebView";
603
+ * closeButton.addEventListener("click", () => {
590
604
  * window.mobileApp.close();
591
605
  * });
592
606
  * document.body.appendChild(closeButton);
@@ -602,8 +616,8 @@ export interface InAppBrowserWebViewAPIs {
602
616
  * @example
603
617
  * // Send data to native app
604
618
  * window.mobileApp.postMessage({
605
- * action: 'dataSubmitted',
606
- * data: { username: 'test', email: 'test@example.com' }
619
+ * action: "dataSubmitted",
620
+ * data: { username: "test", email: "test@example.com" }
607
621
  * });
608
622
  *
609
623
  * @since 6.10.0
@@ -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,WAqBX;AArBD,WAAY,WAAW;IACrB;;;OAGG;IACH,oCAAqB,CAAA;IACrB;;;OAGG;IACH,kCAAmB,CAAA;IACnB;;;OAGG;IACH,wCAAyB,CAAA;IACzB;;;OAGG;IACH,8BAAe,CAAA;AACjB,CAAC,EArBW,WAAW,KAAX,WAAW,QAqBtB","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: object) => void;\n\nexport enum BackgroundColor {\n WHITE = \"white\",\n BLACK = \"black\",\n}\nexport enum ToolBarType {\n /**\n * Shows a simple toolbar with just a close button and share button\n * @since 0.1.0\n */\n ACTIVITY = \"activity\",\n /**\n * Shows a simple toolbar with just a close button\n * @since 7.6.8\n */\n COMPACT = \"compact\",\n /**\n * Shows a full navigation toolbar with back/forward buttons\n * @since 0.1.0\n */\n NAVIGATION = \"navigation\",\n /**\n * Shows no toolbar\n * @since 0.1.0\n */\n BLANK = \"blank\",\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 * 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 /**\n * if true the deeplink will not be opened, if false the deeplink will be opened when clicked on the link\n * @since 0.1.0\n */\n preventDeeplink?: boolean;\n}\n\nexport interface DisclaimerOptions {\n /**\n * Title of the disclaimer dialog\n * @default \"Title\"\n */\n title: string;\n /**\n * Message shown in the disclaimer dialog\n * @default \"Message\"\n */\n message: string;\n /**\n * Text for the confirm button\n * @default \"Confirm\"\n */\n confirmBtn: string;\n /**\n * Text for the cancel button\n * @default \"Cancel\"\n */\n cancelBtn: string;\n}\n\nexport interface OpenWebViewOptions {\n /**\n * Target URL to load.\n * @since 0.1.0\n * @example \"https://capgo.app\"\n */\n url: string;\n /**\n * Headers to send with the request.\n * @since 0.1.0\n * @example\n * headers: {\n * 'Custom-Header': 'test-value',\n * 'Authorization': 'Bearer test-token'\n * }\n * Test URL: https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending/\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 * @example\n * credentials: {\n * username: 'test-user',\n * password: 'test-pass'\n * }\n * Test URL: https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending/\n */\n credentials?: Credentials;\n /**\n * materialPicker: if true, uses Material Design theme for date and time pickers on Android.\n * This improves the appearance of HTML date inputs to use modern Material Design UI instead of the old style pickers.\n * @since 7.4.1\n * @default false\n * @example\n * materialPicker: true\n * Test URL: https://show-picker.glitch.me/demo.html\n */\n materialPicker?: boolean;\n /**\n * JavaScript Interface:\n * The webview automatically injects a JavaScript interface providing:\n * - `window.mobileApp.close()`: Closes the webview from JavaScript\n * - `window.mobileApp.postMessage(obj)`: Sends a message to the app (listen via \"messageFromWebview\" event)\n *\n * @example\n * // In your webpage loaded in the webview:\n * document.getElementById('closeBtn').addEventListener('click', () => {\n * window.mobileApp.close();\n * });\n *\n * // Send data to the app\n * window.mobileApp.postMessage({ action: 'login', data: { user: 'test' }});\n *\n * @since 6.10.0\n */\n jsInterface?: never; // This property doesn't exist, it's just for documentation\n /**\n * Share options for the webview. When provided, shows a disclaimer dialog before sharing content.\n * This is useful for:\n * - Warning users about sharing sensitive information\n * - Getting user consent before sharing\n * - Explaining what will be shared\n * - Complying with privacy regulations\n *\n * Note: shareSubject is required when using shareDisclaimer\n * @since 0.1.0\n * @example\n * shareDisclaimer: {\n * title: 'Disclaimer',\n * message: 'This is a test disclaimer',\n * confirmBtn: 'Accept',\n * cancelBtn: 'Decline'\n * }\n * Test URL: https://capgo.app\n */\n shareDisclaimer?: DisclaimerOptions;\n /**\n * Toolbar type determines the appearance and behavior of the browser's toolbar\n * - \"activity\": Shows a simple toolbar with just a close button and share button\n * - \"navigation\": Shows a full navigation toolbar with back/forward buttons\n * - \"blank\": Shows no toolbar\n * - \"\": Default toolbar with close button\n * @since 0.1.0\n * @default ToolBarType.DEFAULT\n * @example\n * toolbarType: ToolBarType.ACTIVITY,\n * title: 'Activity Toolbar Test'\n * Test URL: https://capgo.app\n */\n toolbarType?: ToolBarType;\n /**\n * Subject text for sharing. Required when using shareDisclaimer.\n * This text will be used as the subject line when sharing content.\n * @since 0.1.0\n * @example \"Share this page\"\n */\n shareSubject?: string;\n /**\n * Title of the browser\n * @since 0.1.0\n * @default 'New Window'\n * @example \"Camera Test\"\n */\n title?: string;\n /**\n * Background color of the browser\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 * @default false\n * @example\n * activeNativeNavigationForWebview: true,\n * disableGoBackOnNativeApplication: true\n * Test URL: https://capgo.app\n */\n activeNativeNavigationForWebview?: boolean;\n /**\n * Disable the possibility to go back on native application,\n * useful to force user to stay on the webview, Android only\n * @default false\n * @example\n * disableGoBackOnNativeApplication: true\n * Test URL: https://capgo.app\n */\n disableGoBackOnNativeApplication?: boolean;\n /**\n * Open url in a new window fullscreen\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 * @example\n * isPresentAfterPageLoad: true,\n * preShowScript: \"await import('https://unpkg.com/darkreader@4.9.89/darkreader.js');\\nDarkReader.enable({ brightness: 100, contrast: 90, sepia: 10 });\"\n * Test URL: https://capgo.app\n */\n isPresentAfterPageLoad?: boolean;\n /**\n * Whether the website in the webview is inspectable or not, ios only\n * @default false\n */\n isInspectable?: boolean;\n /**\n * Whether the webview opening is animated or not, ios only\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 * @example\n * showReloadButton: true\n * Test URL: https://capgo.app\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 * @since 1.1.0\n * @default false\n * @example\n * closeModal: true,\n * closeModalTitle: 'Close Window',\n * closeModalDescription: 'Are you sure you want to close?',\n * closeModalOk: 'Yes, close',\n * closeModalCancel: 'No, stay'\n * Test URL: https://capgo.app\n */\n closeModal?: boolean;\n /**\n * CloseModalTitle: title of the confirm when user clicks on close button\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\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\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\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 * @since 1.2.5\n * @default true\n */\n visibleTitle?: boolean;\n /**\n * toolbarColor: color of the toolbar in hex format\n * @since 1.2.5\n * @default '#ffffff'\n * @example\n * toolbarColor: '#FF5733'\n * Test URL: https://capgo.app\n */\n toolbarColor?: string;\n /**\n * toolbarTextColor: color of the buttons and title in the toolbar in hex format\n * When set, it overrides the automatic light/dark mode detection for text color\n * @since 6.10.0\n * @default calculated based on toolbarColor brightness\n * @example\n * toolbarTextColor: '#FFFFFF'\n * Test URL: https://capgo.app\n */\n toolbarTextColor?: string;\n /**\n * showArrow: if true an arrow would be shown instead of cross for closing the window\n * @since 1.2.5\n * @default false\n * @example\n * showArrow: true\n * Test URL: https://capgo.app\n */\n showArrow?: boolean;\n /**\n * ignoreUntrustedSSLError: if true, the webview will ignore untrusted SSL errors allowing the user to view the website.\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 * @since 6.6.0\n * @example\n * preShowScript: \"await import('https://unpkg.com/darkreader@4.9.89/darkreader.js');\\nDarkReader.enable({ brightness: 100, contrast: 90, sepia: 10 });\"\n * Test URL: https://capgo.app\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 * @since 6.9.0\n */\n proxyRequests?: string;\n /**\n * buttonNearDone allows for a creation of a custom button near the done/close button.\n * The button is only shown when toolbarType is not \"activity\", \"navigation\", or \"blank\".\n *\n * For Android:\n * - iconType must be \"asset\"\n * - icon path should be in the public folder (e.g. \"monkey.svg\")\n * - width and height are optional, defaults to 48dp\n * - button is positioned at the end of toolbar with 8dp margin\n *\n * For iOS:\n * - iconType can be \"sf-symbol\" or \"asset\"\n * - for sf-symbol, icon should be the symbol name\n * - for asset, icon should be the asset name\n * @since 6.7.0\n * @example\n * buttonNearDone: {\n * ios: {\n * iconType: 'sf-symbol',\n * icon: 'star.fill'\n * },\n * android: {\n * iconType: 'asset',\n * icon: 'public/monkey.svg',\n * width: 24,\n * height: 24\n * }\n * }\n * Test URL: https://capgo.app\n */\n buttonNearDone?: {\n ios: {\n iconType: \"sf-symbol\" | \"asset\";\n icon: string;\n };\n android: {\n iconType: \"asset\" | \"vector\";\n icon: string;\n width?: number;\n height?: number;\n };\n };\n /**\n * textZoom: sets the text zoom of the page in percent.\n * Allows users to increase or decrease the text size for better readability.\n * @since 7.6.0\n * @default 100\n * @example\n * textZoom: 120\n * Test URL: https://capgo.app\n */\n textZoom?: number;\n /**\n * preventDeeplink: if true, the deeplink will not be opened, if false the deeplink will be opened when clicked on the link. on IOS each schema need to be added to info.plist file under LSApplicationQueriesSchemes when false to make it work.\n * @since 0.1.0\n * @default false\n * @example\n * preventDeeplink: true\n * Test URL: https://aasa-tester.capgo.app/\n */\n preventDeeplink?: boolean;\n\n /**\n * List of URL base patterns that should be treated as authorized App Links, Android only.\n * Only links starting with any of these base URLs will be opened in the InAppBrowser.\n *\n * @since 7.12.0\n * @default []\n */\n authorizedAppLinks?: string[];\n\n /**\n * If true, the webView will not take the full height and will have a 20px margin at the bottom.\n * This creates a safe margin area outside the browser view.\n * @since 7.13.0\n * @default false\n * @example\n * enabledSafeBottomMargin: true\n */\n enabledSafeBottomMargin?: boolean;\n\n /**\n * enableGooglePaySupport: if true, enables support for Google Pay popups and Payment Request API.\n * This fixes OR_BIBED_15 errors by allowing popup windows and configuring Cross-Origin-Opener-Policy.\n * Only enable this if you need Google Pay functionality as it allows popup windows.\n *\n * When enabled:\n * - Allows popup windows for Google Pay authentication\n * - Sets proper CORS headers for Payment Request API\n * - Enables multiple window support in WebView\n * - Configures secure context for payment processing\n *\n * @since 7.13.0\n * @default false\n * @example\n * enableGooglePaySupport: true\n * Test URL: https://developers.google.com/pay/api/web/guides/tutorial\n */\n enableGooglePaySupport?: boolean;\n}\n\nexport interface InAppBrowserPlugin {\n /**\n * Open url in a new window fullscreen, on android it use chrome custom tabs, on ios it use SFSafariViewController\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, and enhanced capabilities, like camera access, file access, listen events, inject javascript, bi directional communication, etc.\n *\n * JavaScript Interface:\n * When you open a webview with this method, a JavaScript interface is automatically injected that provides:\n * - `window.mobileApp.close()`: Closes the webview from JavaScript\n * - `window.mobileApp.postMessage({detail: {message: 'myMessage'}})`: Sends a message from the webview to the app, detail object is the data you want to send to the webview\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(inappbrowser). you can listen to this event in the inappbrowser JS with window.addEventListener(\"messageFromNative\", 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\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(inappbrowser), to send an event to the main app use window.mobileApp.postMessage({ \"detail\": { \"message\": \"myMessage\" } })\n * detail is the data you want to send to the main app, it's a requirement of Capacitor we cannot send direct objects\n * Your object has to be serializable to JSON, 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>;\n}\n\n/**\n * JavaScript APIs available in the InAppBrowser WebView.\n *\n * These APIs are automatically injected into all webpages loaded in the InAppBrowser WebView.\n *\n * @example\n * // Closing the webview from JavaScript\n * window.mobileApp.close();\n *\n * // Sending a message from webview to the native app\n * window.mobileApp.postMessage({ key: 'value' });\n *\n * @since 6.10.0\n */\nexport interface InAppBrowserWebViewAPIs {\n /**\n * mobileApp - Global object injected into the WebView providing communication with the native app\n */\n mobileApp: {\n /**\n * Close the WebView from JavaScript\n *\n * @example\n * // Add a button to close the webview\n * const closeButton = document.createElement('button');\n * closeButton.textContent = 'Close WebView';\n * closeButton.addEventListener('click', () => {\n * window.mobileApp.close();\n * });\n * document.body.appendChild(closeButton);\n *\n * @since 6.10.0\n */\n close(): void;\n\n /**\n * Send a message from the WebView to the native app\n * The native app can listen for these messages with the \"messageFromWebview\" event\n *\n * @param message Object to send to the native app\n * @example\n * // Send data to native app\n * window.mobileApp.postMessage({\n * action: 'dataSubmitted',\n * data: { username: 'test', email: 'test@example.com' }\n * });\n *\n * @since 6.10.0\n */\n postMessage(message: Record<string, any>): void;\n };\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,WAqBX;AArBD,WAAY,WAAW;IACrB;;;OAGG;IACH,oCAAqB,CAAA;IACrB;;;OAGG;IACH,kCAAmB,CAAA;IACnB;;;OAGG;IACH,wCAAyB,CAAA;IACzB;;;OAGG;IACH,8BAAe,CAAA;AACjB,CAAC,EArBW,WAAW,KAAX,WAAW,QAqBtB","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: object) => void;\n\nexport enum BackgroundColor {\n WHITE = \"white\",\n BLACK = \"black\",\n}\nexport enum ToolBarType {\n /**\n * Shows a simple toolbar with just a close button and share button\n * @since 0.1.0\n */\n ACTIVITY = \"activity\",\n /**\n * Shows a simple toolbar with just a close button\n * @since 7.6.8\n */\n COMPACT = \"compact\",\n /**\n * Shows a full navigation toolbar with back/forward buttons\n * @since 0.1.0\n */\n NAVIGATION = \"navigation\",\n /**\n * Shows no toolbar\n * @since 0.1.0\n */\n BLANK = \"blank\",\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 * 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 /**\n * if true the deeplink will not be opened, if false the deeplink will be opened when clicked on the link\n * @since 0.1.0\n */\n preventDeeplink?: boolean;\n}\n\nexport interface DisclaimerOptions {\n /**\n * Title of the disclaimer dialog\n * @default \"Title\"\n */\n title: string;\n /**\n * Message shown in the disclaimer dialog\n * @default \"Message\"\n */\n message: string;\n /**\n * Text for the confirm button\n * @default \"Confirm\"\n */\n confirmBtn: string;\n /**\n * Text for the cancel button\n * @default \"Cancel\"\n */\n cancelBtn: string;\n}\n\nexport interface OpenWebViewOptions {\n /**\n * Target URL to load.\n * @since 0.1.0\n * @example \"https://capgo.app\"\n */\n url: string;\n /**\n * Headers to send with the request.\n * @since 0.1.0\n * @example\n * headers: {\n * \"Custom-Header\": \"test-value\",\n * \"Authorization\": \"Bearer test-token\"\n * }\n * Test URL: https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending/\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 * @example\n * credentials: {\n * username: \"test-user\",\n * password: \"test-pass\"\n * }\n * Test URL: https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending/\n */\n credentials?: Credentials;\n /**\n * materialPicker: if true, uses Material Design theme for date and time pickers on Android.\n * This improves the appearance of HTML date inputs to use modern Material Design UI instead of the old style pickers.\n * @since 7.4.1\n * @default false\n * @example\n * materialPicker: true\n * Test URL: https://show-picker.glitch.me/demo.html\n */\n materialPicker?: boolean;\n /**\n * JavaScript Interface:\n * The webview automatically injects a JavaScript interface providing:\n * - `window.mobileApp.close()`: Closes the webview from JavaScript\n * - `window.mobileApp.postMessage(obj)`: Sends a message to the app (listen via \"messageFromWebview\" event)\n *\n * @example\n * // In your webpage loaded in the webview:\n * document.getElementById(\"closeBtn\").addEventListener(\"click\", () => {\n * window.mobileApp.close();\n * });\n *\n * // Send data to the app\n * window.mobileApp.postMessage({ action: \"login\", data: { user: \"test\" }});\n *\n * @since 6.10.0\n */\n jsInterface?: never; // This property doesn't exist, it's just for documentation\n /**\n * Share options for the webview. When provided, shows a disclaimer dialog before sharing content.\n * This is useful for:\n * - Warning users about sharing sensitive information\n * - Getting user consent before sharing\n * - Explaining what will be shared\n * - Complying with privacy regulations\n *\n * Note: shareSubject is required when using shareDisclaimer\n * @since 0.1.0\n * @example\n * shareDisclaimer: {\n * title: \"Disclaimer\",\n * message: \"This is a test disclaimer\",\n * confirmBtn: \"Accept\",\n * cancelBtn: \"Decline\"\n * }\n * Test URL: https://capgo.app\n */\n shareDisclaimer?: DisclaimerOptions;\n /**\n * Toolbar type determines the appearance and behavior of the browser's toolbar\n * - \"activity\": Shows a simple toolbar with just a close button and share button\n * - \"navigation\": Shows a full navigation toolbar with back/forward buttons\n * - \"blank\": Shows no toolbar\n * - \"\": Default toolbar with close button\n * @since 0.1.0\n * @default ToolBarType.DEFAULT\n * @example\n * toolbarType: ToolBarType.ACTIVITY,\n * title: \"Activity Toolbar Test\"\n * Test URL: https://capgo.app\n */\n toolbarType?: ToolBarType;\n /**\n * Subject text for sharing. Required when using shareDisclaimer.\n * This text will be used as the subject line when sharing content.\n * @since 0.1.0\n * @example \"Share this page\"\n */\n shareSubject?: string;\n /**\n * Title of the browser\n * @since 0.1.0\n * @default \"New Window\"\n * @example \"Camera Test\"\n */\n title?: string;\n /**\n * Background color of the browser\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 * @default false\n * @example\n * activeNativeNavigationForWebview: true,\n * disableGoBackOnNativeApplication: true\n * Test URL: https://capgo.app\n */\n activeNativeNavigationForWebview?: boolean;\n /**\n * Disable the possibility to go back on native application,\n * useful to force user to stay on the webview, Android only\n * @default false\n * @example\n * disableGoBackOnNativeApplication: true\n * Test URL: https://capgo.app\n */\n disableGoBackOnNativeApplication?: boolean;\n /**\n * Open url in a new window fullscreen\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 * @example\n * isPresentAfterPageLoad: true,\n * preShowScript: \"await import('https://unpkg.com/darkreader@4.9.89/darkreader.js');\\nDarkReader.enable({ brightness: 100, contrast: 90, sepia: 10 });\"\n * Test URL: https://capgo.app\n */\n isPresentAfterPageLoad?: boolean;\n /**\n * Whether the website in the webview is inspectable or not, ios only\n * @default false\n */\n isInspectable?: boolean;\n /**\n * Whether the webview opening is animated or not, ios only\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 * @example\n * showReloadButton: true\n * Test URL: https://capgo.app\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 * @since 1.1.0\n * @default false\n * @example\n * closeModal: true,\n * closeModalTitle: \"Close Window\",\n * closeModalDescription: \"Are you sure you want to close?\",\n * closeModalOk: \"Yes, close\",\n * closeModalCancel: \"No, stay\"\n * Test URL: https://capgo.app\n */\n closeModal?: boolean;\n /**\n * CloseModalTitle: title of the confirm when user clicks on close button\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\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\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\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 * @since 1.2.5\n * @default true\n */\n visibleTitle?: boolean;\n /**\n * toolbarColor: color of the toolbar in hex format\n * @since 1.2.5\n * @default \"#ffffff\"\n * @example\n * toolbarColor: \"#FF5733\"\n * Test URL: https://capgo.app\n */\n toolbarColor?: string;\n /**\n * toolbarTextColor: color of the buttons and title in the toolbar in hex format\n * When set, it overrides the automatic light/dark mode detection for text color\n * @since 6.10.0\n * @default calculated based on toolbarColor brightness\n * @example\n * toolbarTextColor: \"#FFFFFF\"\n * Test URL: https://capgo.app\n */\n toolbarTextColor?: string;\n /**\n * showArrow: if true an arrow would be shown instead of cross for closing the window\n * @since 1.2.5\n * @default false\n * @example\n * showArrow: true\n * Test URL: https://capgo.app\n */\n showArrow?: boolean;\n /**\n * ignoreUntrustedSSLError: if true, the webview will ignore untrusted SSL errors allowing the user to view the website.\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 * @since 6.6.0\n * @example\n * preShowScript: \"await import('https://unpkg.com/darkreader@4.9.89/darkreader.js');\\nDarkReader.enable({ brightness: 100, contrast: 90, sepia: 10 });\"\n * Test URL: https://capgo.app\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 * @since 6.9.0\n */\n proxyRequests?: string;\n /**\n * buttonNearDone allows for a creation of a custom button near the done/close button.\n * The button is only shown when toolbarType is not \"activity\", \"navigation\", or \"blank\".\n *\n * For Android:\n * - iconType must be \"asset\"\n * - icon path should be in the public folder (e.g. \"monkey.svg\")\n * - width and height are optional, defaults to 48dp\n * - button is positioned at the end of toolbar with 8dp margin\n *\n * For iOS:\n * - iconType can be \"sf-symbol\" or \"asset\"\n * - for sf-symbol, icon should be the symbol name\n * - for asset, icon should be the asset name\n * @since 6.7.0\n * @example\n * buttonNearDone: {\n * ios: {\n * iconType: \"sf-symbol\",\n * icon: \"star.fill\"\n * },\n * android: {\n * iconType: \"asset\",\n * icon: \"public/monkey.svg\",\n * width: 24,\n * height: 24\n * }\n * }\n * Test URL: https://capgo.app\n */\n buttonNearDone?: {\n ios: {\n iconType: \"sf-symbol\" | \"asset\";\n icon: string;\n };\n android: {\n iconType: \"asset\" | \"vector\";\n icon: string;\n width?: number;\n height?: number;\n };\n };\n /**\n * textZoom: sets the text zoom of the page in percent.\n * Allows users to increase or decrease the text size for better readability.\n * @since 7.6.0\n * @default 100\n * @example\n * textZoom: 120\n * Test URL: https://capgo.app\n */\n textZoom?: number;\n /**\n * preventDeeplink: if true, the deeplink will not be opened, if false the deeplink will be opened when clicked on the link. on IOS each schema need to be added to info.plist file under LSApplicationQueriesSchemes when false to make it work.\n * @since 0.1.0\n * @default false\n * @example\n * preventDeeplink: true\n * Test URL: https://aasa-tester.capgo.app/\n */\n preventDeeplink?: boolean;\n\n /**\n * List of URL base patterns that should be treated as authorized App Links, Android only.\n * Only links starting with any of these base URLs will be opened in the InAppBrowser.\n *\n * @since 7.12.0\n * @default []\n */\n authorizedAppLinks?: string[];\n\n /**\n * If true, the webView will not take the full height and will have a 20px margin at the bottom.\n * This creates a safe margin area outside the browser view.\n * @since 7.13.0\n * @default false\n * @example\n * enabledSafeBottomMargin: true\n */\n enabledSafeBottomMargin?: boolean;\n\n /**\n * enableGooglePaySupport: if true, enables support for Google Pay popups and Payment Request API.\n * This fixes OR_BIBED_15 errors by allowing popup windows and configuring Cross-Origin-Opener-Policy.\n * Only enable this if you need Google Pay functionality as it allows popup windows.\n *\n * When enabled:\n * - Allows popup windows for Google Pay authentication\n * - Sets proper CORS headers for Payment Request API\n * - Enables multiple window support in WebView\n * - Configures secure context for payment processing\n *\n * @since 7.13.0\n * @default false\n * @example\n * enableGooglePaySupport: true\n * Test URL: https://developers.google.com/pay/api/web/guides/tutorial\n */\n enableGooglePaySupport?: boolean;\n\n /**\n * blockedHosts: List of host patterns that should be blocked from loading in the InAppBrowser's internal navigations.\n * Any request inside WebView to a URL with a host matching any of these patterns will be blocked.\n * Supports wildcard patterns like:\n * - \"*.example.com\" to block all subdomains\n * - \"www.example.*\" to block wildcard domain extensions\n *\n * @since 7.17.0\n * @default []\n * @example\n * blockedHosts: [\"*.tracking.com\", \"ads.example.com\"]\n */\n blockedHosts?: string[];\n}\n\nexport interface InAppBrowserPlugin {\n /**\n * Open url in a new window fullscreen, on android it use chrome custom tabs, on ios it use SFSafariViewController\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, and enhanced capabilities, like camera access, file access, listen events, inject javascript, bi directional communication, etc.\n *\n * JavaScript Interface:\n * When you open a webview with this method, a JavaScript interface is automatically injected that provides:\n * - `window.mobileApp.close()`: Closes the webview from JavaScript\n * - `window.mobileApp.postMessage({detail: {message: \"myMessage\"}})`: Sends a message from the webview to the app, detail object is the data you want to send to the webview\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(inappbrowser). you can listen to this event in the inappbrowser JS with window.addEventListener(\"messageFromNative\", 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,\n * works with openWebView shareDisclaimer and closeModal\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(inappbrowser), to send an event to the main app use window.mobileApp.postMessage({ \"detail\": { \"message\": \"myMessage\" } })\n * detail is the data you want to send to the main app, it's a requirement of Capacitor we cannot send direct objects\n * Your object has to be serializable to JSON, 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>;\n}\n\n/**\n * JavaScript APIs available in the InAppBrowser WebView.\n *\n * These APIs are automatically injected into all webpages loaded in the InAppBrowser WebView.\n *\n * @example\n * // Closing the webview from JavaScript\n * window.mobileApp.close();\n *\n * // Sending a message from webview to the native app\n * window.mobileApp.postMessage({ key: \"value\" });\n *\n * @since 6.10.0\n */\nexport interface InAppBrowserWebViewAPIs {\n /**\n * mobileApp - Global object injected into the WebView providing communication with the native app\n */\n mobileApp: {\n /**\n * Close the WebView from JavaScript\n *\n * @example\n * // Add a button to close the webview\n * const closeButton = document.createElement(\"button\");\n * closeButton.textContent = \"Close WebView\";\n * closeButton.addEventListener(\"click\", () => {\n * window.mobileApp.close();\n * });\n * document.body.appendChild(closeButton);\n *\n * @since 6.10.0\n */\n close(): void;\n\n /**\n * Send a message from the WebView to the native app\n * The native app can listen for these messages with the \"messageFromWebview\" event\n *\n * @param message Object to send to the native app\n * @example\n * // Send data to native app\n * window.mobileApp.postMessage({\n * action: \"dataSubmitted\",\n * data: { username: \"test\", email: \"test@example.com\" }\n * });\n *\n * @since 6.10.0\n */\n postMessage(message: Record<string, any>): void;\n };\n}\n"]}
@@ -355,6 +355,9 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
355
355
  self.isPresentAfterPageLoad = call.getBool("isPresentAfterPageLoad", false)
356
356
  let showReloadButton = call.getBool("showReloadButton", false)
357
357
 
358
+ let blockedHostsRaw = call.getArray("blockedHosts", [])
359
+ let blockedHosts = blockedHostsRaw.compactMap { $0 as? String }
360
+
358
361
  let credentials = self.readCredentials(call)
359
362
 
360
363
  DispatchQueue.main.async {
@@ -363,7 +366,16 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
363
366
  return
364
367
  }
365
368
 
366
- self.webViewController = WKWebViewController.init(url: url, headers: headers, isInspectable: isInspectable, credentials: credentials, preventDeeplink: preventDeeplink, blankNavigationTab: toolbarType == "blank", enabledSafeBottomMargin: enabledSafeBottomMargin)
369
+ self.webViewController = WKWebViewController.init(
370
+ url: url,
371
+ headers: headers,
372
+ isInspectable: isInspectable,
373
+ credentials: credentials,
374
+ preventDeeplink: preventDeeplink,
375
+ blankNavigationTab: toolbarType == "blank",
376
+ enabledSafeBottomMargin: enabledSafeBottomMargin,
377
+ blockedHosts: blockedHosts
378
+ )
367
379
 
368
380
  guard let webViewController = self.webViewController else {
369
381
  call.reject("Failed to initialize WebViewController")
@@ -87,6 +87,18 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
87
87
  self.initWebview(isInspectable: isInspectable)
88
88
  }
89
89
 
90
+ public init(url: URL, headers: [String: String], isInspectable: Bool, credentials: WKWebViewCredentials? = nil, preventDeeplink: Bool, blankNavigationTab: Bool, enabledSafeBottomMargin: Bool, blockedHosts: [String]) {
91
+ super.init(nibName: nil, bundle: nil)
92
+ self.blankNavigationTab = blankNavigationTab
93
+ self.enabledSafeBottomMargin = enabledSafeBottomMargin
94
+ self.source = .remote(url)
95
+ self.credentials = credentials
96
+ self.setHeaders(headers: headers)
97
+ self.setPreventDeeplink(preventDeeplink: preventDeeplink)
98
+ self.setBlockedHosts(blockedHosts: blockedHosts)
99
+ self.initWebview(isInspectable: isInspectable)
100
+ }
101
+
90
102
  open var hasDynamicTitle = false
91
103
  open var source: WKWebSource?
92
104
  /// use `source` instead
@@ -116,6 +128,7 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
116
128
  var blankNavigationTab: Bool = false
117
129
  var capacitorStatusBar: UIView?
118
130
  var enabledSafeBottomMargin: Bool = false
131
+ var blockedHosts: [String] = []
119
132
 
120
133
  internal var preShowSemaphore: DispatchSemaphore?
121
134
  internal var preShowError: String?
@@ -136,6 +149,10 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
136
149
  self.preventDeeplink = preventDeeplink
137
150
  }
138
151
 
152
+ func setBlockedHosts(blockedHosts: [String]) {
153
+ self.blockedHosts = blockedHosts
154
+ }
155
+
139
156
  internal var customUserAgent: String? {
140
157
  didSet {
141
158
  guard let agent = userAgent else {
@@ -1269,6 +1286,7 @@ fileprivate extension WKWebViewController {
1269
1286
  title: disclaimer["title"] as? String ?? "Title",
1270
1287
  message: disclaimer["message"] as? String ?? "Message",
1271
1288
  preferredStyle: UIAlertController.Style.alert)
1289
+ let currentUrl = self.webView?.url?.absoluteString ?? ""
1272
1290
 
1273
1291
  // Add confirm button that continues with sharing
1274
1292
  alert.addAction(UIAlertAction(
@@ -1276,7 +1294,7 @@ fileprivate extension WKWebViewController {
1276
1294
  style: UIAlertAction.Style.default,
1277
1295
  handler: { _ in
1278
1296
  // Notify that confirm was clicked
1279
- self.capBrowserPlugin?.notifyListeners("confirmBtnClicked", data: nil)
1297
+ self.capBrowserPlugin?.notifyListeners("confirmBtnClicked", data: ["url": currentUrl])
1280
1298
 
1281
1299
  // Show the share dialog
1282
1300
  self.showShareSheet(items: items, sender: sender)
@@ -1322,8 +1340,11 @@ fileprivate extension WKWebViewController {
1322
1340
  @objc func doneDidClick(sender: AnyObject) {
1323
1341
  // check if closeModal is true, if true display alert before close
1324
1342
  if self.closeModal {
1343
+ let currentUrl = webView?.url?.absoluteString ?? ""
1325
1344
  let alert = UIAlertController(title: self.closeModalTitle, message: self.closeModalDescription, preferredStyle: UIAlertController.Style.alert)
1326
1345
  alert.addAction(UIAlertAction(title: self.closeModalOk, style: UIAlertAction.Style.default, handler: { _ in
1346
+ // Notify that confirm was clicked
1347
+ self.capBrowserPlugin?.notifyListeners("confirmBtnClicked", data: ["url": currentUrl])
1327
1348
  self.closeView()
1328
1349
  }))
1329
1350
  alert.addAction(UIAlertAction(title: self.closeModalCancel, style: UIAlertAction.Style.default, handler: nil))
@@ -1417,6 +1438,86 @@ extension WKWebViewController: WKUIDelegate {
1417
1438
  }
1418
1439
  }
1419
1440
 
1441
+ // MARK: - Host Blocking Utilities
1442
+ extension WKWebViewController {
1443
+
1444
+ /// Checks if a host should be blocked based on the configured blocked hosts patterns
1445
+ /// - Parameter host: The host to check
1446
+ /// - Returns: true if the host should be blocked, false otherwise
1447
+ private func shouldBlockHost(_ host: String) -> Bool {
1448
+ guard !host.isEmpty else { return false }
1449
+
1450
+ let normalizedHost = host.lowercased()
1451
+
1452
+ return blockedHosts.contains { blockPattern in
1453
+ return matchesBlockPattern(host: normalizedHost, pattern: blockPattern.lowercased())
1454
+ }
1455
+ }
1456
+
1457
+ /// Matches a host against a blocking pattern (supports wildcards)
1458
+ /// - Parameters:
1459
+ /// - host: The normalized host to check
1460
+ /// - pattern: The normalized blocking pattern
1461
+ /// - Returns: true if the host matches the pattern
1462
+ private func matchesBlockPattern(host: String, pattern: String) -> Bool {
1463
+ guard !pattern.isEmpty else { return false }
1464
+
1465
+ // Exact match - fastest check first
1466
+ if host == pattern {
1467
+ return true
1468
+ }
1469
+
1470
+ // No wildcards - already checked exact match above
1471
+ guard pattern.contains("*") else {
1472
+ return false
1473
+ }
1474
+
1475
+ // Handle wildcard patterns
1476
+ if pattern.hasPrefix("*.") {
1477
+ return matchesWildcardDomain(host: host, pattern: pattern)
1478
+ } else if pattern.contains("*") {
1479
+ return matchesRegexPattern(host: host, pattern: pattern)
1480
+ }
1481
+
1482
+ return false
1483
+ }
1484
+
1485
+ /// Handles simple subdomain wildcard patterns like "*.example.com"
1486
+ /// - Parameters:
1487
+ /// - host: The host to check
1488
+ /// - pattern: The wildcard pattern starting with "*."
1489
+ /// - Returns: true if the host matches the wildcard domain
1490
+ private func matchesWildcardDomain(host: String, pattern: String) -> Bool {
1491
+ let domain = String(pattern.dropFirst(2)) // Remove "*."
1492
+
1493
+ guard !domain.isEmpty else { return false }
1494
+
1495
+ // Match exact domain or any subdomain
1496
+ return host == domain || host.hasSuffix("." + domain)
1497
+ }
1498
+
1499
+ /// Handles complex regex patterns with multiple wildcards
1500
+ /// - Parameters:
1501
+ /// - host: The host to check
1502
+ /// - pattern: The pattern with wildcards to convert to regex
1503
+ /// - Returns: true if the host matches the regex pattern
1504
+ private func matchesRegexPattern(host: String, pattern: String) -> Bool {
1505
+ // Escape everything, then re-enable '*' as a wildcard
1506
+ let escaped = NSRegularExpression.escapedPattern(for: pattern)
1507
+ let wildcardEnabled = escaped.replacingOccurrences(of: "\\*", with: ".*")
1508
+ let regexPattern = "^\(wildcardEnabled)$"
1509
+
1510
+ do {
1511
+ let regex = try NSRegularExpression(pattern: regexPattern, options: [])
1512
+ let range = NSRange(location: 0, length: host.utf16.count)
1513
+ return regex.firstMatch(in: host, options: [], range: range) != nil
1514
+ } catch {
1515
+ print("[InAppBrowser] Invalid regex pattern '\(regexPattern)': \(error)")
1516
+ return false
1517
+ }
1518
+ }
1519
+ }
1520
+
1420
1521
  // MARK: - WKNavigationDelegate
1421
1522
  extension WKWebViewController: WKNavigationDelegate {
1422
1523
  internal func injectPreShowScript() {
@@ -1593,6 +1694,14 @@ extension WKWebViewController: WKNavigationDelegate {
1593
1694
  if let navigationType = NavigationType(rawValue: navigationAction.navigationType.rawValue), let result = delegate?.webViewController?(self, decidePolicy: u, navigationType: navigationType) {
1594
1695
  actionPolicy = result ? .allow : .cancel
1595
1696
  }
1697
+
1698
+ // Check for blocked hosts using the extracted function
1699
+ if let host = u.host, shouldBlockHost(host) {
1700
+ print("[InAppBrowser] Blocked host detected: \(host)")
1701
+ self.capBrowserPlugin?.notifyListeners("urlChangeEvent", data: ["url": u.absoluteString])
1702
+ actionPolicy = .cancel
1703
+ }
1704
+
1596
1705
  self.injectJavaScriptInterface()
1597
1706
  decisionHandler(actionPolicy)
1598
1707
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/inappbrowser",
3
- "version": "7.17.0",
3
+ "version": "7.19.0",
4
4
  "description": "Capacitor plugin in app browser",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",