         return nil
     }
 }
+
+// MARK: - WKScriptMessageHandler
+
+extension VerificationFlowWebView: WKScriptMessageHandler {
+    func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
+        guard let messageHandler = ScriptMessageHandler(rawValue: message.name) else { return }
+
+        switch messageHandler {
+        case .closeWindow:
+            delegate?.verificationFlowWebViewDidClose(self)
+        }
+    }
+}

        webView.navigationDelegate = self
        webView.uiDelegate = self
        VerificationFlowWebView.injectSDKInfoToJS(webView: webView)

        return webView
    }()

    }
}

// MARK: WKUIDelegate

extension VerificationFlowWebView: WKUIDelegate {
    func webViewDidClose(_ webView: WKWebView) {
        // `window.close` is called in JS
