@dynamic-labs/legacy-react-native-extension 5.9.1 → 5.9.4

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.
@@ -7,6 +7,9 @@ import android.graphics.Color
7
7
  import android.net.http.SslError
8
8
  import android.os.Handler
9
9
  import android.os.Looper
10
+ import android.text.TextUtils
11
+ import android.util.Log
12
+ import android.view.Gravity
10
13
  import android.view.View
11
14
  import android.view.ViewGroup
12
15
  import android.webkit.JavascriptInterface
@@ -19,6 +22,10 @@ import android.webkit.WebResourceResponse
19
22
  import android.webkit.WebView
20
23
  import android.webkit.WebViewClient
21
24
  import android.widget.FrameLayout
25
+ import android.widget.LinearLayout
26
+ import android.widget.TextView
27
+ import androidx.webkit.WebSettingsCompat
28
+ import androidx.webkit.WebViewFeature
22
29
  import expo.modules.kotlin.AppContext
23
30
  import org.json.JSONObject
24
31
  import java.util.UUID
@@ -44,6 +51,21 @@ object EmbeddedWebViewController {
44
51
  private var webView: WebView? = null
45
52
  private var debuggingEnabled = false
46
53
 
54
+ // Opt-in for window.open() popups, set via setAllowWebViewPopups before
55
+ // the first setUrl call (ensureWebView reads it once, at creation time —
56
+ // WebSettings.setSupportMultipleWindows/javaScriptCanOpenWindowsAutomatically
57
+ // only take effect for the WebChromeClient wired up below, not
58
+ // retroactively on an existing WebView). Defaults to false: consumers who
59
+ // never call the setter get the pre-Coinbase-popup behavior unchanged.
60
+ private var allowPopups = false
61
+
62
+ // The popup opened via window.open() (e.g. Coinbase's keys.coinbase.com
63
+ // connect flow) — a separate WebView/container from the main overlay, torn
64
+ // down on window.close() (see PopupWebChromeClient.onCloseWindow), the
65
+ // dismiss button, or destroy().
66
+ private var popupContainer: LinearLayout? = null
67
+ private var popupWebView: WebView? = null
68
+
47
69
  private val pendingNavigationUrls = mutableMapOf<String, String>()
48
70
  private val pendingTimeouts = mutableMapOf<String, Runnable>()
49
71
 
@@ -160,6 +182,12 @@ object EmbeddedWebViewController {
160
182
  }
161
183
  }
162
184
 
185
+ fun setAllowWebViewPopups(enabled: Boolean) {
186
+ runOnMain {
187
+ allowPopups = enabled
188
+ }
189
+ }
190
+
163
191
  fun destroy() {
164
192
  runOnMain { teardown() }
165
193
  }
@@ -226,13 +254,19 @@ object EmbeddedWebViewController {
226
254
  settings.mediaPlaybackRequiresUserGesture = false
227
255
  settings.allowFileAccess = false
228
256
  settings.allowContentAccess = false
229
- // Match react-native-webview's `setSupportMultipleWindows={false}`:
230
- // refuse `target=_blank` / window.open popups so they don't escape
231
- // the embedded webview into an unmanaged context.
232
- settings.setSupportMultipleWindows(false)
257
+ // Some wallet-connect flows (e.g. Coinbase's keys.coinbase.com Smart
258
+ // Wallet flow) only work through a real window.open() popup, with the
259
+ // result posted back via `postMessage` to `window.opener` — there's no
260
+ // redirect-based fallback. PopupWebChromeClient below hosts that popup
261
+ // in its own overlay, separate from this WebView's own content.
262
+ // Opt-in via allowPopups (see setAllowWebViewPopups): everyone else
263
+ // keeps the original refuse-popups behavior below.
264
+ settings.setSupportMultipleWindows(allowPopups)
265
+ settings.javaScriptCanOpenWindowsAutomatically = allowPopups
233
266
  addJavascriptInterface(JsBridge(), SCRIPT_HANDLER_NAME)
234
267
  webViewClient = NavigationClient()
235
- webChromeClient = NoPopupWebChromeClient()
268
+ webChromeClient =
269
+ if (allowPopups) PopupWebChromeClient(activity) else NoPopupWebChromeClient()
236
270
  }
237
271
 
238
272
  val container = FrameLayout(activity).apply {
@@ -288,6 +322,7 @@ object EmbeddedWebViewController {
288
322
  }
289
323
 
290
324
  private fun teardown() {
325
+ closePopup()
291
326
  overlayContainer?.let { container ->
292
327
  (container.parent as? ViewGroup)?.removeView(container)
293
328
  container.removeAllViews()
@@ -311,6 +346,143 @@ object EmbeddedWebViewController {
311
346
  preApprovedOrigin = null
312
347
  }
313
348
 
349
+ // ---- Popup window (window.open) -------------------------------------------
350
+
351
+ // Builds the popup's overlay: its own visible, non-zero-size container and
352
+ // WebView, attached above the main overlay so a passkey/connect prompt is
353
+ // actually reachable by the user. Settings mirror the main WebView's
354
+ // hardening (no file/content access, no host JsBridge — the popup only
355
+ // ever talks to the wallet's own hosted page, never our RN bridge).
356
+ @SuppressLint("SetJavaScriptEnabled")
357
+ private fun createPopupWebView(activity: android.app.Activity): WebView {
358
+ val density = activity.resources.displayMetrics.density
359
+
360
+ // Shows the popup's current origin (e.g. "🔒 keys.coinbase.com") so the
361
+ // overlay reads as a real browser chrome bar rather than a bare content
362
+ // frame — the wallet page is running on a domain the user didn't
363
+ // navigate to themselves, so this is also a legitimate trust signal, not
364
+ // just cosmetic.
365
+ val addressBarText = TextView(activity).apply {
366
+ setTextColor(Color.parseColor("#E0E0E0"))
367
+ textSize = 14f
368
+ maxLines = 1
369
+ ellipsize = TextUtils.TruncateAt.MIDDLE
370
+ layoutParams = LinearLayout.LayoutParams(
371
+ 0,
372
+ ViewGroup.LayoutParams.WRAP_CONTENT,
373
+ 1f,
374
+ )
375
+ }
376
+
377
+ val webView = WebView(activity).apply {
378
+ setBackgroundColor(Color.WHITE)
379
+ settings.javaScriptEnabled = true
380
+ settings.domStorageEnabled = true
381
+ settings.databaseEnabled = true
382
+ settings.mediaPlaybackRequiresUserGesture = false
383
+ settings.allowFileAccess = false
384
+ settings.allowContentAccess = false
385
+ settings.setSupportMultipleWindows(false)
386
+ // Coinbase's keys.coinbase.com page refuses to proceed when it detects
387
+ // an embedded WebView — it reads the "wv" and "Version/x.x" markers
388
+ // Android adds to the default WebView user-agent (a real Chrome tab
389
+ // has neither). Stripping them makes this popup present as a stock
390
+ // Chrome tab, which is otherwise indistinguishable from one: it's a
391
+ // real window opened via WebChromeClient#onCreateWindow, not a
392
+ // same-document overlay.
393
+ settings.userAgentString =
394
+ settings.userAgentString
395
+ .replace("; wv", "")
396
+ .replace(Regex("Version/[\\d.]+ "), "")
397
+ webViewClient = PopupNavigationClient { origin ->
398
+ val host = origin.removePrefix("https://").removePrefix("http://")
399
+ runOnMain { addressBarText.text = "🔒 $host" }
400
+ }
401
+ webChromeClient = object : WebChromeClient() {
402
+ override fun onCloseWindow(window: WebView) {
403
+ // The wallet's own page calls window.close() once it has posted
404
+ // the connect result back via postMessage.
405
+ runOnMain { closePopup() }
406
+ }
407
+ }
408
+ if (WebViewFeature.isFeatureSupported(WebViewFeature.WEB_AUTHENTICATION)) {
409
+ WebSettingsCompat.setWebAuthenticationSupport(
410
+ settings,
411
+ WebSettingsCompat.WEB_AUTHENTICATION_SUPPORT_FOR_APP,
412
+ )
413
+ }
414
+ }
415
+
416
+ val dismissButton = TextView(activity).apply {
417
+ text = "✕"
418
+ setTextColor(Color.WHITE)
419
+ textSize = 18f
420
+ val padding = (12 * density).toInt()
421
+ setPadding(padding, 0, padding, 0)
422
+ setOnClickListener { closePopup() }
423
+ }
424
+
425
+ val addressBar = LinearLayout(activity).apply {
426
+ orientation = LinearLayout.HORIZONTAL
427
+ gravity = Gravity.CENTER_VERTICAL
428
+ setBackgroundColor(Color.parseColor("#F2202124"))
429
+ val horizontalPadding = (12 * density).toInt()
430
+ val verticalPadding = (10 * density).toInt()
431
+ setPadding(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding)
432
+ addView(addressBarText)
433
+ addView(dismissButton)
434
+ }
435
+
436
+ val container = LinearLayout(activity).apply {
437
+ orientation = LinearLayout.VERTICAL
438
+ setBackgroundColor(Color.WHITE)
439
+ addView(
440
+ addressBar,
441
+ LinearLayout.LayoutParams(
442
+ ViewGroup.LayoutParams.MATCH_PARENT,
443
+ ViewGroup.LayoutParams.WRAP_CONTENT,
444
+ ).apply { topMargin = (24 * density).toInt() },
445
+ )
446
+ addView(
447
+ webView,
448
+ LinearLayout.LayoutParams(
449
+ ViewGroup.LayoutParams.MATCH_PARENT,
450
+ 0,
451
+ 1f,
452
+ ),
453
+ )
454
+ visibility = View.VISIBLE
455
+ }
456
+
457
+ val decor = activity.window.decorView as ViewGroup
458
+ decor.addView(
459
+ container,
460
+ ViewGroup.LayoutParams(
461
+ ViewGroup.LayoutParams.MATCH_PARENT,
462
+ ViewGroup.LayoutParams.MATCH_PARENT,
463
+ ),
464
+ )
465
+ container.requestFocus()
466
+
467
+ popupContainer = container
468
+ popupWebView = webView
469
+ return webView
470
+ }
471
+
472
+ private fun closePopup() {
473
+ popupContainer?.let { container ->
474
+ (container.parent as? ViewGroup)?.removeView(container)
475
+ container.removeAllViews()
476
+ }
477
+ popupWebView?.let {
478
+ it.stopLoading()
479
+ it.webChromeClient = null
480
+ it.destroy()
481
+ }
482
+ popupContainer = null
483
+ popupWebView = null
484
+ }
485
+
314
486
  private fun runOnMain(action: () -> Unit) {
315
487
  if (Looper.myLooper() == Looper.getMainLooper()) {
316
488
  action()
@@ -543,9 +715,10 @@ object EmbeddedWebViewController {
543
715
  return if (shouldIncludePort) "$scheme://$host:$port" else "$scheme://$host"
544
716
  }
545
717
 
546
- // Refuse target=_blank / window.open popups (matches react-native-webview's
547
- // `setSupportMultipleWindows={false}` semantics: there's nowhere reasonable
548
- // to open the new window inside the overlay).
718
+ // Default when allowPopups is false: refuse target=_blank / window.open
719
+ // popups (matches react-native-webview's `setSupportMultipleWindows={false}`
720
+ // semantics) — there's nowhere reasonable to open the new window inside
721
+ // the overlay unless the consumer has opted in via setAllowWebViewPopups.
549
722
  private class NoPopupWebChromeClient : WebChromeClient() {
550
723
  override fun onCreateWindow(
551
724
  view: WebView,
@@ -556,4 +729,115 @@ object EmbeddedWebViewController {
556
729
  return false
557
730
  }
558
731
  }
732
+
733
+ // Hosts window.open() popups (e.g. Coinbase's keys.coinbase.com Smart
734
+ // Wallet connect flow) in their own overlay — see createPopupWebView.
735
+ // Only one popup at a time: a second onCreateWindow while one is already
736
+ // open closes the first, matching a page replacing its own popup.
737
+ private class PopupWebChromeClient(
738
+ private val activity: android.app.Activity,
739
+ ) : WebChromeClient() {
740
+ override fun onCreateWindow(
741
+ view: WebView,
742
+ isDialog: Boolean,
743
+ isUserGesture: Boolean,
744
+ resultMsg: android.os.Message?,
745
+ ): Boolean {
746
+ val transport = resultMsg?.obj as? WebView.WebViewTransport ?: return false
747
+
748
+ closePopup()
749
+ val popup = createPopupWebView(activity)
750
+ transport.webView = popup
751
+ resultMsg.sendToTarget()
752
+ return true
753
+ }
754
+ }
755
+
756
+ // The popup only ever needs to stay within the origin it started on (e.g.
757
+ // keys.coinbase.com) — that first navigation is trusted because it's the
758
+ // trusted top-frame's own JS that called window.open() with the target
759
+ // URL. Anything the popup subsequently tries to navigate to outside that
760
+ // origin is refused, closing off a mid-flow redirect to an attacker page.
761
+ private class PopupNavigationClient(
762
+ private val onUrlChanged: (String) -> Unit,
763
+ ) : WebViewClient() {
764
+ private var popupOrigin: String? = null
765
+
766
+ // Tracks whether the trusted first navigation has already happened,
767
+ // separately from popupOrigin itself. An opaque first load (about:blank,
768
+ // javascript:, etc.) has no host and so no determinable origin — without
769
+ // this flag, popupOrigin would stay null and the "first navigation is
770
+ // trusted" branch below would keep re-triggering on every subsequent
771
+ // navigation, letting a page open the popup at about:blank then redirect
772
+ // it to an attacker origin as if that were the trusted first load.
773
+ private var hasApprovedFirstNavigation = false
774
+
775
+ // Sonar flags any shouldOverrideUrlLoading override as a security
776
+ // hotspot (S6363, "unrestricted navigation") purely for existing, since
777
+ // it's the choke point that could let a WebView navigate anywhere.
778
+ // This one is the actual control, not a gap in it: it locks onto the
779
+ // popup's first-navigated origin below and rejects every subsequent
780
+ // navigation outside that origin. Removing or loosening this override
781
+ // would remove the security control the hotspot is asking about.
782
+ override fun shouldOverrideUrlLoading( // NOSONAR
783
+ view: WebView,
784
+ request: WebResourceRequest,
785
+ ): Boolean {
786
+ if (!request.isForMainFrame) return false
787
+
788
+ val origin = originString(request.url)
789
+
790
+ if (!hasApprovedFirstNavigation) {
791
+ hasApprovedFirstNavigation = true
792
+ // Blocked navigations are not reported through emitLoadError: that
793
+ // channel is shared with the main webview's onLoadError, which feeds
794
+ // the SDK's reload/recovery budget — a benign popup-side block (e.g.
795
+ // the wallet page navigating off-origin) would otherwise count
796
+ // against and can exhaust the main webview's retry attempts, even
797
+ // though it never actually failed to load. Mirrors iOS's
798
+ // PopupNavigationDelegate, which is silent here too.
799
+ popupOrigin = origin
800
+ return false
801
+ }
802
+
803
+ if (origin != null && origin == popupOrigin) return false
804
+
805
+ return true
806
+ }
807
+
808
+ override fun onPageStarted(view: WebView, url: String?, favicon: Bitmap?) {
809
+ super.onPageStarted(view, url, favicon)
810
+ val origin = originString(url?.let(android.net.Uri::parse))
811
+ // Defensive fallback: some WebView versions don't route the very first,
812
+ // window.open()-triggered navigation through shouldOverrideUrlLoading.
813
+ // Capture the origin here too if it hasn't been captured yet, so the
814
+ // allowlist above is never left empty for the popup's whole lifetime.
815
+ if (!hasApprovedFirstNavigation) {
816
+ hasApprovedFirstNavigation = true
817
+ popupOrigin = origin
818
+ }
819
+ // Only ever report the approved origin, never a navigation that
820
+ // shouldOverrideUrlLoading is about to block (or already tried to) —
821
+ // otherwise the address bar could momentarily show an attacker's
822
+ // origin while the popup's actual (trusted) content stays on screen.
823
+ if (origin != null && origin == popupOrigin) onUrlChanged(origin)
824
+ }
825
+
826
+ override fun onReceivedSslError(
827
+ view: WebView,
828
+ handler: SslErrorHandler,
829
+ error: SslError,
830
+ ) {
831
+ // Not routed through emitLoadError (see shouldOverrideUrlLoading's
832
+ // comment above) — but still worth a native log line, unlike a benign
833
+ // off-origin block, since a cert error here could mean a
834
+ // man-in-the-middle attack against the wallet connection. Origin
835
+ // only, not the full URL, which can carry session tokens.
836
+ Log.w(
837
+ "EmbeddedWebViewController",
838
+ "Popup SSL error ${error.primaryError} for ${originString(error.url?.let(android.net.Uri::parse)) ?: "unknown origin"}",
839
+ )
840
+ handler.cancel()
841
+ }
842
+ }
559
843
  }
@@ -47,6 +47,10 @@ class EmbeddedWebViewModule : Module() {
47
47
  EmbeddedWebViewController.setDebuggingEnabled(enabled)
48
48
  }
49
49
 
50
+ AsyncFunction("setAllowWebViewPopups") { enabled: Boolean ->
51
+ EmbeddedWebViewController.setAllowWebViewPopups(enabled)
52
+ }
53
+
50
54
  AsyncFunction("destroy") {
51
55
  EmbeddedWebViewController.destroy()
52
56
  }
package/index.cjs CHANGED
@@ -35,7 +35,7 @@ function _interopNamespace(e) {
35
35
  return Object.freeze(n);
36
36
  }
37
37
 
38
- var version = "5.9.1";
38
+ var version = "5.9.4";
39
39
 
40
40
  function _extends() {
41
41
  return _extends = Object.assign ? Object.assign.bind() : function (n) {
@@ -369,6 +369,7 @@ const getEmbeddedWebView = () => {
369
369
  destroy: () => Promise.reject(unavailableError),
370
370
  postMessage: () => Promise.reject(unavailableError),
371
371
  respondToShouldStartLoad: () => Promise.reject(unavailableError),
372
+ setAllowWebViewPopups: () => Promise.reject(unavailableError),
372
373
  setDebuggingEnabled: () => Promise.reject(unavailableError),
373
374
  setUrl: () => Promise.reject(unavailableError),
374
375
  setVisible: () => Promise.reject(unavailableError)
@@ -403,8 +404,10 @@ const setupEmbeddedWebView = ({
403
404
  webviewUrl,
404
405
  core,
405
406
  webviewDebuggingEnabled: _webviewDebuggingEnabled = false,
406
- webviewLoad
407
+ webviewLoad,
408
+ allowWebViewPopups: _allowWebViewPopups = false
407
409
  }) => {
410
+ var _a;
408
411
  const native = getEmbeddedWebView();
409
412
  // The URL of the load attempt currently in flight. The controller owns
410
413
  // URL construction (environmentId, start time, retry counter), so the
@@ -509,13 +512,26 @@ const setupEmbeddedWebView = ({
509
512
  native.setDebuggingEnabled(_webviewDebuggingEnabled).catch(err => {
510
513
  logger.warn('EmbeddedWebView.setDebuggingEnabled failed', err);
511
514
  });
515
+ // setAllowWebViewPopups postdates the native module itself — an OTA JS
516
+ // update can land on a binary new enough to have the module but old
517
+ // enough to predate this method, where a non-optional call would throw
518
+ // synchronously before .catch() ever attaches.
519
+ //
520
+ // Awaited before controller.start() below: allowPopups is read once by
521
+ // ensureWebView() with no retroactive-apply path (see the native-side
522
+ // comment on it), so if the webview gets created before this native call
523
+ // resolves, popups are silently disabled for that webview's entire
524
+ // lifetime — no window.open() ever succeeds, with no further signal.
525
+ const popupSetupPromise = Promise.resolve((_a = native.setAllowWebViewPopups) === null || _a === void 0 ? void 0 : _a.call(native, _allowWebViewPopups)).catch(err => {
526
+ logger.warn('EmbeddedWebView.setAllowWebViewPopups failed', err);
527
+ });
512
528
  // Defer the initial load by one event-loop tick so the JS thread has fully
513
529
  // settled after listener registration. On cold boot the main thread is
514
530
  // congested with bundle evaluation — yielding here gives pending microtasks
515
531
  // and native bridge batches a chance to flush before the native side starts
516
532
  // firing navigation events that require a JS round-trip response.
517
533
  const warmupTimer = setTimeout(() => {
518
- controller.start();
534
+ popupSetupPromise.finally(() => controller.start());
519
535
  }, 0);
520
536
  return () => {
521
537
  logger.debug('[EmbeddedWebView] teardown — removing listeners');
@@ -1132,7 +1148,8 @@ const ReactNativeExtension = ({
1132
1148
  webviewDebuggingEnabled,
1133
1149
  appOrigin,
1134
1150
  embeddedWebView: _embeddedWebView = false,
1135
- webviewLoad
1151
+ webviewLoad,
1152
+ allowWebViewPopups
1136
1153
  } = {}) => (_, core) => {
1137
1154
  const isPlatformSupportedByWebView = reactNative.Platform.OS === 'android' || reactNative.Platform.OS === 'ios';
1138
1155
  /**
@@ -1181,6 +1198,7 @@ const ReactNativeExtension = ({
1181
1198
  }
1182
1199
  try {
1183
1200
  previousEmbeddedWebViewTeardown = setupEmbeddedWebView({
1201
+ allowWebViewPopups,
1184
1202
  core,
1185
1203
  webviewDebuggingEnabled,
1186
1204
  webviewLoad,
package/index.js CHANGED
@@ -14,7 +14,7 @@ import { openAuthSessionAsync } from 'expo-web-browser';
14
14
  import { resetGenericPassword, getGenericPassword, setGenericPassword } from 'react-native-keychain';
15
15
  import { createPasskey, PasskeyStamper } from '@turnkey/react-native-passkey-stamper';
16
16
 
17
- var version = "5.9.1";
17
+ var version = "5.9.4";
18
18
 
19
19
  function _extends() {
20
20
  return _extends = Object.assign ? Object.assign.bind() : function (n) {
@@ -348,6 +348,7 @@ const getEmbeddedWebView = () => {
348
348
  destroy: () => Promise.reject(unavailableError),
349
349
  postMessage: () => Promise.reject(unavailableError),
350
350
  respondToShouldStartLoad: () => Promise.reject(unavailableError),
351
+ setAllowWebViewPopups: () => Promise.reject(unavailableError),
351
352
  setDebuggingEnabled: () => Promise.reject(unavailableError),
352
353
  setUrl: () => Promise.reject(unavailableError),
353
354
  setVisible: () => Promise.reject(unavailableError)
@@ -382,8 +383,10 @@ const setupEmbeddedWebView = ({
382
383
  webviewUrl,
383
384
  core,
384
385
  webviewDebuggingEnabled: _webviewDebuggingEnabled = false,
385
- webviewLoad
386
+ webviewLoad,
387
+ allowWebViewPopups: _allowWebViewPopups = false
386
388
  }) => {
389
+ var _a;
387
390
  const native = getEmbeddedWebView();
388
391
  // The URL of the load attempt currently in flight. The controller owns
389
392
  // URL construction (environmentId, start time, retry counter), so the
@@ -488,13 +491,26 @@ const setupEmbeddedWebView = ({
488
491
  native.setDebuggingEnabled(_webviewDebuggingEnabled).catch(err => {
489
492
  logger.warn('EmbeddedWebView.setDebuggingEnabled failed', err);
490
493
  });
494
+ // setAllowWebViewPopups postdates the native module itself — an OTA JS
495
+ // update can land on a binary new enough to have the module but old
496
+ // enough to predate this method, where a non-optional call would throw
497
+ // synchronously before .catch() ever attaches.
498
+ //
499
+ // Awaited before controller.start() below: allowPopups is read once by
500
+ // ensureWebView() with no retroactive-apply path (see the native-side
501
+ // comment on it), so if the webview gets created before this native call
502
+ // resolves, popups are silently disabled for that webview's entire
503
+ // lifetime — no window.open() ever succeeds, with no further signal.
504
+ const popupSetupPromise = Promise.resolve((_a = native.setAllowWebViewPopups) === null || _a === void 0 ? void 0 : _a.call(native, _allowWebViewPopups)).catch(err => {
505
+ logger.warn('EmbeddedWebView.setAllowWebViewPopups failed', err);
506
+ });
491
507
  // Defer the initial load by one event-loop tick so the JS thread has fully
492
508
  // settled after listener registration. On cold boot the main thread is
493
509
  // congested with bundle evaluation — yielding here gives pending microtasks
494
510
  // and native bridge batches a chance to flush before the native side starts
495
511
  // firing navigation events that require a JS round-trip response.
496
512
  const warmupTimer = setTimeout(() => {
497
- controller.start();
513
+ popupSetupPromise.finally(() => controller.start());
498
514
  }, 0);
499
515
  return () => {
500
516
  logger.debug('[EmbeddedWebView] teardown — removing listeners');
@@ -1111,7 +1127,8 @@ const ReactNativeExtension = ({
1111
1127
  webviewDebuggingEnabled,
1112
1128
  appOrigin,
1113
1129
  embeddedWebView: _embeddedWebView = false,
1114
- webviewLoad
1130
+ webviewLoad,
1131
+ allowWebViewPopups
1115
1132
  } = {}) => (_, core) => {
1116
1133
  const isPlatformSupportedByWebView = Platform.OS === 'android' || Platform.OS === 'ios';
1117
1134
  /**
@@ -1160,6 +1177,7 @@ const ReactNativeExtension = ({
1160
1177
  }
1161
1178
  try {
1162
1179
  previousEmbeddedWebViewTeardown = setupEmbeddedWebView({
1180
+ allowWebViewPopups,
1163
1181
  core,
1164
1182
  webviewDebuggingEnabled,
1165
1183
  webviewLoad,