@capgo/inappbrowser 7.17.0 → 7.18.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 +8 -7
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/InAppBrowserPlugin.java +23 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/Options.java +12 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java +138 -1
- package/dist/docs.json +36 -16
- package/dist/esm/definitions.d.ts +47 -34
- package/dist/esm/definitions.js.map +1 -1
- package/ios/Sources/InAppBrowserPlugin/InAppBrowserPlugin.swift +13 -1
- package/ios/Sources/InAppBrowserPlugin/WKWebViewController.swift +105 -0
- package/package.json +1 -1
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:
|
|
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
|
| ------------- | ----------------------------------------------------------------- |
|
|
@@ -540,7 +540,7 @@ Reload the current web page.
|
|
|
540
540
|
| **`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
541
|
| **`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
542
|
| **`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>
|
|
543
|
+
| **`title`** | <code>string</code> | Title of the browser | <code>"New Window"</code> | 0.1.0 |
|
|
544
544
|
| **`backgroundColor`** | <code><a href="#backgroundcolor">BackgroundColor</a></code> | Background color of the browser | <code>BackgroundColor.BLACK</code> | 0.1.0 |
|
|
545
545
|
| **`activeNativeNavigationForWebview`** | <code>boolean</code> | If true, active the native navigation within the webview, Android only | <code>false</code> | |
|
|
546
546
|
| **`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 +549,12 @@ Reload the current web page.
|
|
|
549
549
|
| **`isAnimated`** | <code>boolean</code> | Whether the webview opening is animated or not, ios only | <code>true</code> | |
|
|
550
550
|
| **`showReloadButton`** | <code>boolean</code> | Shows a reload button that reloads the web page | <code>false</code> | 1.0.15 |
|
|
551
551
|
| **`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>
|
|
553
|
-
| **`closeModalDescription`** | <code>string</code> | CloseModalDescription: description of the confirm when user clicks on close button | <code>
|
|
554
|
-
| **`closeModalOk`** | <code>string</code> | CloseModalOk: text of the confirm button when user clicks on close button | <code>
|
|
555
|
-
| **`closeModalCancel`** | <code>string</code> | CloseModalCancel: text of the cancel button when user clicks on close button | <code>
|
|
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 |
|
|
556
556
|
| **`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>
|
|
557
|
+
| **`toolbarColor`** | <code>string</code> | toolbarColor: color of the toolbar in hex format | <code>"#ffffff"</code> | 1.2.5 |
|
|
558
558
|
| **`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
559
|
| **`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
560
|
| **`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 +566,7 @@ Reload the current web page.
|
|
|
566
566
|
| **`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
567
|
| **`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
568
|
| **`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 |
|
|
569
|
+
| **`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
570
|
|
|
570
571
|
|
|
571
572
|
#### Headers
|
|
@@ -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
|
}
|
|
@@ -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 =
|
|
1143
|
+
mlp.topMargin = insets.top;
|
|
1144
1144
|
mlp.leftMargin = insets.left;
|
|
1145
1145
|
mlp.rightMargin = insets.right;
|
|
1146
1146
|
v.setLayoutParams(mlp);
|
|
@@ -2394,6 +2394,124 @@ public class WebViewDialog extends Dialog {
|
|
|
2394
2394
|
return false;
|
|
2395
2395
|
}
|
|
2396
2396
|
|
|
2397
|
+
/**
|
|
2398
|
+
* Checks if a host should be blocked based on the configured blocked hosts patterns
|
|
2399
|
+
* @param url The URL to check
|
|
2400
|
+
* @param blockedHosts The list of blocked hosts patterns
|
|
2401
|
+
* @return true if the host should be blocked, false otherwise
|
|
2402
|
+
*/
|
|
2403
|
+
private boolean shouldBlockHost(String url, List<String> blockedHosts) {
|
|
2404
|
+
Uri uri = Uri.parse(url);
|
|
2405
|
+
String host = uri.getHost();
|
|
2406
|
+
|
|
2407
|
+
if (host == null || host.isEmpty()) {
|
|
2408
|
+
return false;
|
|
2409
|
+
}
|
|
2410
|
+
|
|
2411
|
+
if (blockedHosts == null || blockedHosts.isEmpty()) {
|
|
2412
|
+
return false;
|
|
2413
|
+
}
|
|
2414
|
+
|
|
2415
|
+
String normalizedHost = host.toLowerCase();
|
|
2416
|
+
|
|
2417
|
+
for (String blockPattern : blockedHosts) {
|
|
2418
|
+
if (
|
|
2419
|
+
blockPattern != null &&
|
|
2420
|
+
matchesBlockPattern(normalizedHost, blockPattern.toLowerCase())
|
|
2421
|
+
) {
|
|
2422
|
+
Log.d("InAppBrowser", "Blocked host detected: " + host);
|
|
2423
|
+
return true;
|
|
2424
|
+
}
|
|
2425
|
+
}
|
|
2426
|
+
|
|
2427
|
+
return false;
|
|
2428
|
+
}
|
|
2429
|
+
|
|
2430
|
+
/**
|
|
2431
|
+
* Matches a host against a blocking pattern (supports wildcards)
|
|
2432
|
+
* @param host The normalized host to check
|
|
2433
|
+
* @param pattern The normalized blocking pattern
|
|
2434
|
+
* @return true if the host matches the pattern
|
|
2435
|
+
*/
|
|
2436
|
+
private boolean matchesBlockPattern(String host, String pattern) {
|
|
2437
|
+
if (pattern == null || pattern.isEmpty()) {
|
|
2438
|
+
return false;
|
|
2439
|
+
}
|
|
2440
|
+
|
|
2441
|
+
// Exact match - fastest check first
|
|
2442
|
+
if (host.equals(pattern)) {
|
|
2443
|
+
return true;
|
|
2444
|
+
}
|
|
2445
|
+
|
|
2446
|
+
// No wildcards - already checked exact match above
|
|
2447
|
+
if (!pattern.contains("*")) {
|
|
2448
|
+
return false;
|
|
2449
|
+
}
|
|
2450
|
+
|
|
2451
|
+
// Handle wildcard patterns
|
|
2452
|
+
if (pattern.startsWith("*.")) {
|
|
2453
|
+
return matchesWildcardDomain(host, pattern);
|
|
2454
|
+
} else if (pattern.contains("*")) {
|
|
2455
|
+
return matchesRegexPattern(host, pattern);
|
|
2456
|
+
}
|
|
2457
|
+
|
|
2458
|
+
return false;
|
|
2459
|
+
}
|
|
2460
|
+
|
|
2461
|
+
/**
|
|
2462
|
+
* Handles simple subdomain wildcard patterns like "*.example.com"
|
|
2463
|
+
* @param host The host to check
|
|
2464
|
+
* @param pattern The wildcard pattern starting with "*."
|
|
2465
|
+
* @return true if the host matches the wildcard domain
|
|
2466
|
+
*/
|
|
2467
|
+
private boolean matchesWildcardDomain(String host, String pattern) {
|
|
2468
|
+
String domain = pattern.substring(2); // Remove "*."
|
|
2469
|
+
|
|
2470
|
+
if (domain.isEmpty()) {
|
|
2471
|
+
return false;
|
|
2472
|
+
}
|
|
2473
|
+
|
|
2474
|
+
// Match exact domain or any subdomain
|
|
2475
|
+
return host.equals(domain) || host.endsWith("." + domain);
|
|
2476
|
+
}
|
|
2477
|
+
|
|
2478
|
+
/**
|
|
2479
|
+
* Handles complex regex patterns with multiple wildcards
|
|
2480
|
+
* @param host The host to check
|
|
2481
|
+
* @param pattern The pattern with wildcards to convert to regex
|
|
2482
|
+
* @return true if the host matches the regex pattern
|
|
2483
|
+
*/
|
|
2484
|
+
private boolean matchesRegexPattern(String host, String pattern) {
|
|
2485
|
+
try {
|
|
2486
|
+
// Escape special regex characters except *
|
|
2487
|
+
String escapedPattern = pattern
|
|
2488
|
+
.replace("\\", "\\\\") // Must escape backslashes first
|
|
2489
|
+
.replace(".", "\\.")
|
|
2490
|
+
.replace("+", "\\+")
|
|
2491
|
+
.replace("?", "\\?")
|
|
2492
|
+
.replace("^", "\\^")
|
|
2493
|
+
.replace("$", "\\$")
|
|
2494
|
+
.replace("(", "\\(")
|
|
2495
|
+
.replace(")", "\\)")
|
|
2496
|
+
.replace("[", "\\[")
|
|
2497
|
+
.replace("]", "\\]")
|
|
2498
|
+
.replace("{", "\\{")
|
|
2499
|
+
.replace("}", "\\}")
|
|
2500
|
+
.replace("|", "\\|");
|
|
2501
|
+
|
|
2502
|
+
// Convert wildcards to regex
|
|
2503
|
+
String regexPattern = "^" + escapedPattern.replace("*", ".*") + "$";
|
|
2504
|
+
|
|
2505
|
+
return Pattern.matches(regexPattern, host);
|
|
2506
|
+
} catch (Exception e) {
|
|
2507
|
+
Log.e(
|
|
2508
|
+
"InAppBrowser",
|
|
2509
|
+
"Invalid regex pattern '" + pattern + "': " + e.getMessage()
|
|
2510
|
+
);
|
|
2511
|
+
return false;
|
|
2512
|
+
}
|
|
2513
|
+
}
|
|
2514
|
+
|
|
2397
2515
|
@Override
|
|
2398
2516
|
public boolean shouldOverrideUrlLoading(
|
|
2399
2517
|
WebView view,
|
|
@@ -2463,6 +2581,25 @@ public class WebViewDialog extends Dialog {
|
|
|
2463
2581
|
// Do nothing
|
|
2464
2582
|
}
|
|
2465
2583
|
}
|
|
2584
|
+
|
|
2585
|
+
// Check for blocked hosts (main-frame only) using the extracted function
|
|
2586
|
+
List<String> blockedHosts = _options.getBlockedHosts();
|
|
2587
|
+
if (
|
|
2588
|
+
blockedHosts != null &&
|
|
2589
|
+
!blockedHosts.isEmpty() &&
|
|
2590
|
+
request.isForMainFrame()
|
|
2591
|
+
) {
|
|
2592
|
+
Log.d("InAppBrowser", "Checking for blocked hosts (on main frame)");
|
|
2593
|
+
if (shouldBlockHost(url, blockedHosts)) {
|
|
2594
|
+
// Make sure to notify that a URL has changed even when it was blocked
|
|
2595
|
+
if (_options.getCallbacks() != null) {
|
|
2596
|
+
_options.getCallbacks().urlChangeEvent(url);
|
|
2597
|
+
}
|
|
2598
|
+
Log.d("InAppBrowser", "Navigation blocked for URL: " + url);
|
|
2599
|
+
return true; // Block the navigation
|
|
2600
|
+
}
|
|
2601
|
+
}
|
|
2602
|
+
|
|
2466
2603
|
return false;
|
|
2467
2604
|
}
|
|
2468
2605
|
|
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:
|
|
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
|
],
|
|
@@ -552,7 +552,7 @@
|
|
|
552
552
|
"name": "since"
|
|
553
553
|
},
|
|
554
554
|
{
|
|
555
|
-
"text": "headers: {\n
|
|
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:
|
|
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(
|
|
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:
|
|
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:
|
|
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": "
|
|
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:
|
|
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": "
|
|
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": "
|
|
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": "
|
|
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": "
|
|
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": "
|
|
917
|
+
"text": "\"#ffffff\"",
|
|
918
918
|
"name": "default"
|
|
919
919
|
},
|
|
920
920
|
{
|
|
921
|
-
"text": "toolbarColor:
|
|
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:
|
|
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:
|
|
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
|
-
*
|
|
113
|
-
*
|
|
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:
|
|
124
|
-
* password:
|
|
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(
|
|
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:
|
|
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:
|
|
170
|
-
* message:
|
|
171
|
-
* confirmBtn:
|
|
172
|
-
* cancelBtn:
|
|
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:
|
|
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
|
|
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:
|
|
266
|
-
* closeModalDescription:
|
|
267
|
-
* closeModalOk:
|
|
268
|
-
* closeModalCancel:
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
305
|
+
* @default "#ffffff"
|
|
306
306
|
* @example
|
|
307
|
-
* toolbarColor:
|
|
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:
|
|
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:
|
|
369
|
-
* icon:
|
|
368
|
+
* iconType: "sf-symbol",
|
|
369
|
+
* icon: "star.fill"
|
|
370
370
|
* },
|
|
371
371
|
* android: {
|
|
372
|
-
* iconType:
|
|
373
|
-
* icon:
|
|
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:
|
|
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
|
*/
|
|
@@ -570,7 +583,7 @@ export interface InAppBrowserPlugin {
|
|
|
570
583
|
* window.mobileApp.close();
|
|
571
584
|
*
|
|
572
585
|
* // Sending a message from webview to the native app
|
|
573
|
-
* window.mobileApp.postMessage({ key:
|
|
586
|
+
* window.mobileApp.postMessage({ key: "value" });
|
|
574
587
|
*
|
|
575
588
|
* @since 6.10.0
|
|
576
589
|
*/
|
|
@@ -584,9 +597,9 @@ export interface InAppBrowserWebViewAPIs {
|
|
|
584
597
|
*
|
|
585
598
|
* @example
|
|
586
599
|
* // Add a button to close the webview
|
|
587
|
-
* const closeButton = document.createElement(
|
|
588
|
-
* closeButton.textContent =
|
|
589
|
-
* closeButton.addEventListener(
|
|
600
|
+
* const closeButton = document.createElement("button");
|
|
601
|
+
* closeButton.textContent = "Close WebView";
|
|
602
|
+
* closeButton.addEventListener("click", () => {
|
|
590
603
|
* window.mobileApp.close();
|
|
591
604
|
* });
|
|
592
605
|
* document.body.appendChild(closeButton);
|
|
@@ -602,8 +615,8 @@ export interface InAppBrowserWebViewAPIs {
|
|
|
602
615
|
* @example
|
|
603
616
|
* // Send data to native app
|
|
604
617
|
* window.mobileApp.postMessage({
|
|
605
|
-
* action:
|
|
606
|
-
* data: { username:
|
|
618
|
+
* action: "dataSubmitted",
|
|
619
|
+
* data: { username: "test", email: "test@example.com" }
|
|
607
620
|
* });
|
|
608
621
|
*
|
|
609
622
|
* @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 *\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(
|
|
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 {
|
|
@@ -1417,6 +1434,86 @@ extension WKWebViewController: WKUIDelegate {
|
|
|
1417
1434
|
}
|
|
1418
1435
|
}
|
|
1419
1436
|
|
|
1437
|
+
// MARK: - Host Blocking Utilities
|
|
1438
|
+
extension WKWebViewController {
|
|
1439
|
+
|
|
1440
|
+
/// Checks if a host should be blocked based on the configured blocked hosts patterns
|
|
1441
|
+
/// - Parameter host: The host to check
|
|
1442
|
+
/// - Returns: true if the host should be blocked, false otherwise
|
|
1443
|
+
private func shouldBlockHost(_ host: String) -> Bool {
|
|
1444
|
+
guard !host.isEmpty else { return false }
|
|
1445
|
+
|
|
1446
|
+
let normalizedHost = host.lowercased()
|
|
1447
|
+
|
|
1448
|
+
return blockedHosts.contains { blockPattern in
|
|
1449
|
+
return matchesBlockPattern(host: normalizedHost, pattern: blockPattern.lowercased())
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
/// Matches a host against a blocking pattern (supports wildcards)
|
|
1454
|
+
/// - Parameters:
|
|
1455
|
+
/// - host: The normalized host to check
|
|
1456
|
+
/// - pattern: The normalized blocking pattern
|
|
1457
|
+
/// - Returns: true if the host matches the pattern
|
|
1458
|
+
private func matchesBlockPattern(host: String, pattern: String) -> Bool {
|
|
1459
|
+
guard !pattern.isEmpty else { return false }
|
|
1460
|
+
|
|
1461
|
+
// Exact match - fastest check first
|
|
1462
|
+
if host == pattern {
|
|
1463
|
+
return true
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
// No wildcards - already checked exact match above
|
|
1467
|
+
guard pattern.contains("*") else {
|
|
1468
|
+
return false
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
// Handle wildcard patterns
|
|
1472
|
+
if pattern.hasPrefix("*.") {
|
|
1473
|
+
return matchesWildcardDomain(host: host, pattern: pattern)
|
|
1474
|
+
} else if pattern.contains("*") {
|
|
1475
|
+
return matchesRegexPattern(host: host, pattern: pattern)
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
return false
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
/// Handles simple subdomain wildcard patterns like "*.example.com"
|
|
1482
|
+
/// - Parameters:
|
|
1483
|
+
/// - host: The host to check
|
|
1484
|
+
/// - pattern: The wildcard pattern starting with "*."
|
|
1485
|
+
/// - Returns: true if the host matches the wildcard domain
|
|
1486
|
+
private func matchesWildcardDomain(host: String, pattern: String) -> Bool {
|
|
1487
|
+
let domain = String(pattern.dropFirst(2)) // Remove "*."
|
|
1488
|
+
|
|
1489
|
+
guard !domain.isEmpty else { return false }
|
|
1490
|
+
|
|
1491
|
+
// Match exact domain or any subdomain
|
|
1492
|
+
return host == domain || host.hasSuffix("." + domain)
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
/// Handles complex regex patterns with multiple wildcards
|
|
1496
|
+
/// - Parameters:
|
|
1497
|
+
/// - host: The host to check
|
|
1498
|
+
/// - pattern: The pattern with wildcards to convert to regex
|
|
1499
|
+
/// - Returns: true if the host matches the regex pattern
|
|
1500
|
+
private func matchesRegexPattern(host: String, pattern: String) -> Bool {
|
|
1501
|
+
// Escape everything, then re-enable '*' as a wildcard
|
|
1502
|
+
let escaped = NSRegularExpression.escapedPattern(for: pattern)
|
|
1503
|
+
let wildcardEnabled = escaped.replacingOccurrences(of: "\\*", with: ".*")
|
|
1504
|
+
let regexPattern = "^\(wildcardEnabled)$"
|
|
1505
|
+
|
|
1506
|
+
do {
|
|
1507
|
+
let regex = try NSRegularExpression(pattern: regexPattern, options: [])
|
|
1508
|
+
let range = NSRange(location: 0, length: host.utf16.count)
|
|
1509
|
+
return regex.firstMatch(in: host, options: [], range: range) != nil
|
|
1510
|
+
} catch {
|
|
1511
|
+
print("[InAppBrowser] Invalid regex pattern '\(regexPattern)': \(error)")
|
|
1512
|
+
return false
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1420
1517
|
// MARK: - WKNavigationDelegate
|
|
1421
1518
|
extension WKWebViewController: WKNavigationDelegate {
|
|
1422
1519
|
internal func injectPreShowScript() {
|
|
@@ -1593,6 +1690,14 @@ extension WKWebViewController: WKNavigationDelegate {
|
|
|
1593
1690
|
if let navigationType = NavigationType(rawValue: navigationAction.navigationType.rawValue), let result = delegate?.webViewController?(self, decidePolicy: u, navigationType: navigationType) {
|
|
1594
1691
|
actionPolicy = result ? .allow : .cancel
|
|
1595
1692
|
}
|
|
1693
|
+
|
|
1694
|
+
// Check for blocked hosts using the extracted function
|
|
1695
|
+
if let host = u.host, shouldBlockHost(host) {
|
|
1696
|
+
print("[InAppBrowser] Blocked host detected: \(host)")
|
|
1697
|
+
self.capBrowserPlugin?.notifyListeners("urlChangeEvent", data: ["url": u.absoluteString])
|
|
1698
|
+
actionPolicy = .cancel
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1596
1701
|
self.injectJavaScriptInterface()
|
|
1597
1702
|
decisionHandler(actionPolicy)
|
|
1598
1703
|
}
|