@capgo/capacitor-inappbrowser 8.17.2 → 8.18.1
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 -0
- package/android/src/main/assets/proxy-bridge.js +6 -6
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/CapgoInAppBrowserPlugin.java +10 -5
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/ProxyRequestSupport.java +11 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java +17 -26
- package/dist/docs.json +37 -0
- package/dist/esm/definitions.d.ts +27 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.js +33 -31
- package/dist/esm/index.js.map +1 -1
- package/dist/plugin.cjs.js +33 -31
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +33 -31
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/InAppBrowserPlugin/InAppBrowserPlugin.swift +30 -5
- package/ios/Sources/InAppBrowserPlugin/PreferredContentModeSupport.swift +50 -0
- package/ios/Sources/InAppBrowserPlugin/Resources/proxy-bridge.js +6 -6
- package/ios/Sources/InAppBrowserPlugin/WKWebViewController.swift +5 -0
- package/package.json +9 -10
|
@@ -446,7 +446,7 @@ public class CapgoInAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
446
446
|
case aware = "AWARE"
|
|
447
447
|
case fakeVisible = "FAKE_VISIBLE"
|
|
448
448
|
}
|
|
449
|
-
private let pluginVersion: String = "8.
|
|
449
|
+
private let pluginVersion: String = "8.18.1"
|
|
450
450
|
public let identifier = "CapgoInAppBrowserPlugin"
|
|
451
451
|
public let jsName = "CapgoInAppBrowser"
|
|
452
452
|
public let pluginMethods: [CAPPluginMethod] = [
|
|
@@ -507,6 +507,7 @@ public class CapgoInAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
507
507
|
private var safariViewController: SFSafariViewController?
|
|
508
508
|
private var safariOpenedUrl: String?
|
|
509
509
|
private var openSecureWindowCall: CAPPluginCall?
|
|
510
|
+
private var authSession: ASWebAuthenticationSession?
|
|
510
511
|
|
|
511
512
|
private func setup() {
|
|
512
513
|
self.isSetupDone = true
|
|
@@ -1368,6 +1369,17 @@ public class CapgoInAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
1368
1369
|
self.isHidden = hidden
|
|
1369
1370
|
let hiddenPopupWindow = call.getBool("hiddenPopupWindow", false)
|
|
1370
1371
|
let allowWebViewJsVisibilityControl = self.getConfig().getBoolean("allowWebViewJsVisibilityControl", false)
|
|
1372
|
+
if let rawPreferredContentMode = call.getString("preferredContentMode"),
|
|
1373
|
+
PreferredContentModeSupport.normalizedMode(rawPreferredContentMode) == nil {
|
|
1374
|
+
call.reject("preferredContentMode must be 'recommended', 'mobile', or 'desktop'")
|
|
1375
|
+
return
|
|
1376
|
+
}
|
|
1377
|
+
let preferredContentMode = PreferredContentModeSupport.resolve(
|
|
1378
|
+
perOpenValue: call.getString("preferredContentMode"),
|
|
1379
|
+
pluginConfigValue: self.getConfig().getString("preferredContentMode"),
|
|
1380
|
+
legacyPluginConfigValue: self.bridge?.config.getPluginConfig("InAppBrowser").getString("preferredContentMode"),
|
|
1381
|
+
capacitorConfigValue: self.bridge?.config.preferredContentMode
|
|
1382
|
+
)
|
|
1371
1383
|
let allowScreenshotsFromWebPage = call.getBool("allowScreenshotsFromWebPage", false)
|
|
1372
1384
|
let screenshotOnHide = call.getBool("screenshotOnHide", false)
|
|
1373
1385
|
let captureConsoleLogs = call.getBool("captureConsoleLogs", false)
|
|
@@ -1526,6 +1538,7 @@ public class CapgoInAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
1526
1538
|
webViewController.source = webSource
|
|
1527
1539
|
webViewController.setCredentials(credentials: credentials)
|
|
1528
1540
|
webViewController.allowWebViewJsVisibilityControl = allowWebViewJsVisibilityControl
|
|
1541
|
+
webViewController.preferredContentMode = preferredContentMode
|
|
1529
1542
|
webViewController.allowScreenshotsFromWebPage = allowScreenshotsFromWebPage
|
|
1530
1543
|
webViewController.captureConsoleLogs = captureConsoleLogs
|
|
1531
1544
|
webViewController.proxyRequests = legacyProxyRequests.isEnabled
|
|
@@ -2751,6 +2764,11 @@ public class CapgoInAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
2751
2764
|
return
|
|
2752
2765
|
}
|
|
2753
2766
|
|
|
2767
|
+
if self.openSecureWindowCall != nil || self.authSession != nil {
|
|
2768
|
+
call.reject("An authentication session is already in progress")
|
|
2769
|
+
return
|
|
2770
|
+
}
|
|
2771
|
+
|
|
2754
2772
|
// Store the call for later resolution
|
|
2755
2773
|
self.openSecureWindowCall = call
|
|
2756
2774
|
|
|
@@ -2759,9 +2777,11 @@ public class CapgoInAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
2759
2777
|
// Open the URL in a secure browser window
|
|
2760
2778
|
DispatchQueue.main.async {
|
|
2761
2779
|
let session = ASWebAuthenticationSession(url: url, callbackURLScheme: callbackURLScheme) {
|
|
2762
|
-
callbackURL, error in
|
|
2763
|
-
|
|
2764
|
-
|
|
2780
|
+
[weak self] callbackURL, error in
|
|
2781
|
+
guard let self = self, self.openSecureWindowCall === call else {
|
|
2782
|
+
return
|
|
2783
|
+
}
|
|
2784
|
+
self.authSession = nil
|
|
2765
2785
|
self.openSecureWindowCall = nil
|
|
2766
2786
|
|
|
2767
2787
|
if let error = error {
|
|
@@ -2787,7 +2807,12 @@ public class CapgoInAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
2787
2807
|
// Present the session
|
|
2788
2808
|
session.prefersEphemeralWebBrowserSession = prefersEphemeral
|
|
2789
2809
|
session.presentationContextProvider = self
|
|
2790
|
-
session
|
|
2810
|
+
self.authSession = session
|
|
2811
|
+
if !session.start() {
|
|
2812
|
+
self.authSession = nil
|
|
2813
|
+
self.openSecureWindowCall = nil
|
|
2814
|
+
call.reject("Failed to start authentication session")
|
|
2815
|
+
}
|
|
2791
2816
|
}
|
|
2792
2817
|
}
|
|
2793
2818
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import WebKit
|
|
3
|
+
|
|
4
|
+
/// Maps Capacitor and plugin `preferredContentMode` values onto WKWebpagePreferences.
|
|
5
|
+
enum PreferredContentModeSupport {
|
|
6
|
+
static func normalizedMode(_ value: String) -> String? {
|
|
7
|
+
switch value.lowercased() {
|
|
8
|
+
case "recommended", "mobile", "desktop":
|
|
9
|
+
return value.lowercased()
|
|
10
|
+
default:
|
|
11
|
+
return nil
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static func resolve(
|
|
16
|
+
perOpenValue: String?,
|
|
17
|
+
pluginConfigValue: String?,
|
|
18
|
+
legacyPluginConfigValue: String?,
|
|
19
|
+
capacitorConfigValue: String?
|
|
20
|
+
) -> String? {
|
|
21
|
+
if let perOpenValue, let normalized = normalizedMode(perOpenValue) {
|
|
22
|
+
return normalized
|
|
23
|
+
}
|
|
24
|
+
if let pluginConfigValue, let normalized = normalizedMode(pluginConfigValue) {
|
|
25
|
+
return normalized
|
|
26
|
+
}
|
|
27
|
+
if let legacyPluginConfigValue, let normalized = normalizedMode(legacyPluginConfigValue) {
|
|
28
|
+
return normalized
|
|
29
|
+
}
|
|
30
|
+
if let capacitorConfigValue, let normalized = normalizedMode(capacitorConfigValue) {
|
|
31
|
+
return normalized
|
|
32
|
+
}
|
|
33
|
+
return nil
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static func webpageContentMode(for mode: String) -> WKWebpagePreferences.ContentMode {
|
|
37
|
+
switch mode.lowercased() {
|
|
38
|
+
case "mobile":
|
|
39
|
+
return .mobile
|
|
40
|
+
case "desktop":
|
|
41
|
+
return .desktop
|
|
42
|
+
default:
|
|
43
|
+
return .recommended
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static func apply(to configuration: WKWebViewConfiguration, mode: String) {
|
|
48
|
+
configuration.defaultWebpagePreferences.preferredContentMode = webpageContentMode(for: mode)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
function resolveProxyBridgeUrl(rawUrl, baseUrl) {
|
|
82
82
|
try {
|
|
83
83
|
return new URL(rawUrl, baseUrl).href;
|
|
84
|
-
} catch (
|
|
84
|
+
} catch (e) {
|
|
85
85
|
return null;
|
|
86
86
|
}
|
|
87
87
|
}
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
form.requestSubmit();
|
|
131
131
|
}
|
|
132
132
|
return;
|
|
133
|
-
} catch (
|
|
133
|
+
} catch (e) {
|
|
134
134
|
delete form.__capgoSkipNextProxySubmit;
|
|
135
135
|
}
|
|
136
136
|
}
|
|
@@ -168,7 +168,7 @@
|
|
|
168
168
|
if (proxyRegexSource) {
|
|
169
169
|
try {
|
|
170
170
|
proxyRequestPattern = new RegExp(proxyRegexSource);
|
|
171
|
-
} catch (
|
|
171
|
+
} catch (e) {
|
|
172
172
|
proxyRequestPattern = null;
|
|
173
173
|
}
|
|
174
174
|
}
|
|
@@ -209,7 +209,7 @@
|
|
|
209
209
|
if (url && !url.match(/^[a-zA-Z][a-zA-Z0-9+\-.]*:\/\//)) {
|
|
210
210
|
try {
|
|
211
211
|
return new URL(url, getDocumentBaseUrl()).href;
|
|
212
|
-
} catch (
|
|
212
|
+
} catch (e) {
|
|
213
213
|
return url;
|
|
214
214
|
}
|
|
215
215
|
}
|
|
@@ -289,7 +289,7 @@
|
|
|
289
289
|
if (submitter instanceof HTMLElement) {
|
|
290
290
|
try {
|
|
291
291
|
return new FormData(form, submitter);
|
|
292
|
-
} catch (
|
|
292
|
+
} catch (e) {
|
|
293
293
|
}
|
|
294
294
|
}
|
|
295
295
|
return new FormData(form);
|
|
@@ -450,7 +450,7 @@
|
|
|
450
450
|
let proxyUrl;
|
|
451
451
|
try {
|
|
452
452
|
proxyUrl = yield storeInterceptedRequest(url, method, headers, body, credentialsMode);
|
|
453
|
-
} catch (
|
|
453
|
+
} catch (e) {
|
|
454
454
|
return originalFetch.call(window, input, init);
|
|
455
455
|
}
|
|
456
456
|
const proxyResponse = yield originalFetch.call(globalThis, proxyUrl, {
|
|
@@ -435,6 +435,7 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
|
|
|
435
435
|
open var clearCookiesOnOpen = false
|
|
436
436
|
open var clearCacheOnOpen = false
|
|
437
437
|
open var handleDownloads = false
|
|
438
|
+
open var preferredContentMode: String?
|
|
438
439
|
open var delegate: WKWebViewControllerDelegate?
|
|
439
440
|
open var bypassedSSLHosts: [String]?
|
|
440
441
|
open var cookies: [HTTPCookie]?
|
|
@@ -2051,6 +2052,9 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
|
|
|
2051
2052
|
self.edgesForExtendedLayout = [.bottom]
|
|
2052
2053
|
|
|
2053
2054
|
let webConfiguration = initialWebConfiguration ?? WKWebViewConfiguration()
|
|
2055
|
+
if let preferredContentMode {
|
|
2056
|
+
PreferredContentModeSupport.apply(to: webConfiguration, mode: preferredContentMode)
|
|
2057
|
+
}
|
|
2054
2058
|
webConfiguration.websiteDataStore = BrowsingDataStoreSupport.websiteDataStore(
|
|
2055
2059
|
persistWebViewData: persistWebViewData,
|
|
2056
2060
|
useSharedDataStore: useSharedDataStore
|
|
@@ -2340,6 +2344,7 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
|
|
|
2340
2344
|
self.captureConsoleLogs = parent.captureConsoleLogs
|
|
2341
2345
|
self.allowWebViewJsVisibilityControl = parent.allowWebViewJsVisibilityControl
|
|
2342
2346
|
self.allowScreenshotsFromWebPage = parent.allowScreenshotsFromWebPage
|
|
2347
|
+
self.preferredContentMode = parent.preferredContentMode
|
|
2343
2348
|
self.handleDownloads = parent.handleDownloads
|
|
2344
2349
|
self.websiteTitleInNavigationBar = parent.websiteTitleInNavigationBar
|
|
2345
2350
|
self.doneBarButtonItemPosition = parent.doneBarButtonItemPosition
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/capacitor-inappbrowser",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.18.1",
|
|
4
4
|
"description": "Capacitor plugin in app browser",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -65,28 +65,27 @@
|
|
|
65
65
|
"@capacitor/core": "^8.0.0",
|
|
66
66
|
"@capacitor/docgen": "^0.3.1",
|
|
67
67
|
"@capacitor/ios": "^8.0.0",
|
|
68
|
-
"@ionic/eslint-config": "^0.
|
|
68
|
+
"@ionic/eslint-config": "^0.5.0",
|
|
69
69
|
"@ionic/prettier-config": "^4.0.0",
|
|
70
70
|
"@ionic/swiftlint-config": "^2.0.0",
|
|
71
71
|
"@types/node": "^24.10.1",
|
|
72
|
+
"@typescript-eslint/eslint-plugin": "^8.70.0",
|
|
73
|
+
"@typescript-eslint/parser": "^8.70.0",
|
|
74
|
+
"@typescript/typescript6": "^6.0.2",
|
|
72
75
|
"esbuild": "^0.28.0",
|
|
73
|
-
"eslint": "^
|
|
74
|
-
"eslint-plugin-import": "^2.31.0",
|
|
76
|
+
"eslint": "^10.0.0",
|
|
75
77
|
"husky": "^9.1.7",
|
|
76
|
-
"prettier": "
|
|
77
|
-
"prettier-plugin-java": "
|
|
78
|
+
"prettier": "3.8.4",
|
|
79
|
+
"prettier-plugin-java": "2.9.7",
|
|
78
80
|
"rimraf": "^6.1.0",
|
|
79
81
|
"rollup": "^4.53.2",
|
|
80
82
|
"swiftlint": "^2.0.0",
|
|
81
|
-
"typescript": "^
|
|
83
|
+
"typescript": "^7.0.0",
|
|
82
84
|
"prettier-pretty-check": "^0.2.0"
|
|
83
85
|
},
|
|
84
86
|
"peerDependencies": {
|
|
85
87
|
"@capacitor/core": ">=8.0.0"
|
|
86
88
|
},
|
|
87
|
-
"eslintConfig": {
|
|
88
|
-
"extends": "@ionic/eslint-config/recommended"
|
|
89
|
-
},
|
|
90
89
|
"prettier": "@ionic/prettier-config",
|
|
91
90
|
"swiftlint": {
|
|
92
91
|
"excluded": [
|