Frequently Asked Questions - iProov/web GitHub Wiki

What is the size impact of the Web SDK?

We know that SDK size impact is an important factor, and we continue to do everything we can to pack iProov's advanced technologies into as small a payload as possible.

The SDK loads lazily. As of 7.0.0 iProovMe.js is a thin ES module — around 45 KB gzipped — and that is all your page loads up front. Everything heavy is fetched at runtime from the origin given by your assets_url attribute, and only as a journey actually needs it, so any one session downloads a fraction of what the npm package holds. Expect on the order of 2 MB gzipped on first use, cached by the browser and versioned by SDK release, so it is a one-time cost per user per version.

The long answer:

The runtime assets include WebAssembly binaries, TensorFlow.js and the Blazeface model used for face detection. Despite their size, we use Blazeface because web browsers still do not offer a native face detector that performs well enough or consistently enough across the range of devices we support.

The full published asset set is larger than any one session downloads — about 2.8 MB gzipped. That is deliberate: we publish several variants of the same asset so the right one exists for every browser. Only one of the three TensorFlow.js Wasm backends is fetched, depending on the device's SIMD support — face detection runs single-threaded, so the multithreaded build is published but never used — and the web fonts ship in five formats of which a browser takes one per face.

We also minify and obfuscate our source for commercial reasons, and that is a real cost rather than a rounding error: obfuscation roughly quintuples iProovMe.js and the runtime chunks, and adds about a third to the gzipped total. Make sure your assets_url origin serves the assets with compression enabled.

For the measured, per-category breakdown and how to measure it against the version you are shipping, see the more comprehensive Package Size article.

Our <script src="..."> integration stopped working after upgrading. Why?

From 7.0.0 the SDK is an ES module only. A classic <script src=".../iProovMe.js"> tag no longer executes, and there is no CommonJS or UMD build, so require() is also unsupported.

Load it as a module instead:

<script type="module" src="/path/to/iProovMe.js"></script>

Serve iProovMe.js exactly as published, and do not run it through a bundler: if a build changes the file in any way, every transaction fails. Loading the SDK shows how to load it by URL from a bundled app. The window.IProov and window.iProovSupport globals were removed in the same release — import the support checker from the @iproov/web-sdk/iProovSupport.js subpath. The .js extension is required, because exports subpaths are matched exactly.

See the Upgrade Guide for the full list of breaking changes.

Can we disable the message "Press Esc to exit full screen"?

"Press ESC to exit fullscreen" is a browser functionality and it is there to prevent users from phishing attacks, hence it cannot be disabled.

Can I customise my webview app's userAgent?

Yes, as long as the user agent is well formed.

❌ Not valid:

  • Web3/CryptoWallet (i5.g.6)

✅ Valid:

  • Mozilla/5.0 (iPhone; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B176 Safari/7534.48.3
  • Mozilla/5.0 (iPhone; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B176 Safari/7534.48.3 Web3/CryptoWallet (i5.g.6)
  • Web3/CryptoWallet (i5.g.6) Mozilla/5.0 (iPhone; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B176 Safari/7534.48.3

My webview app already has camera permission. Why does the SDK still show the grant button?

The SDK decides whether to show grant_button by asking the browser's Permissions API (navigator.permissions.query({ name: "camera" })). In a browser that answers "granted" once the user has allowed the camera. A webview often cannot answer at all, because the permission your native app holds is not visible to the page, so the SDK takes the safe path and shows the button.

If your app has already been granted camera permission natively, you can tell the page so by injecting a script into the webview that runs before the Web SDK loads:

(() => {
  const permissions = navigator.permissions
  if (!permissions || !permissions.query) return
  const originalQuery = permissions.query.bind(permissions)
  permissions.query = descriptor =>
    descriptor && descriptor.name === "camera"
      ? Promise.resolve({ state: "granted", onchange: null })
      : originalQuery(descriptor)
})()

On a webview with no Permissions API the script does nothing and the SDK keeps showing the button.

The script only removes the button. The camera is then opened straight away, so the webview must also grant the page's own camera request, and video must be allowed to play without a separate tap.

iOS (WKWebView, iOS 15 and later)

let configuration = WKWebViewConfiguration()
configuration.allowsInlineMediaPlayback = true
configuration.mediaTypesRequiringUserActionForPlayback = []
configuration.userContentController.addUserScript(WKUserScript(
    source: grantedCameraScript, // the JavaScript above
    injectionTime: .atDocumentStart,
    forMainFrameOnly: true
))

let webView = WKWebView(frame: .zero, configuration: configuration)
webView.uiDelegate = self

// WKUIDelegate
func webView(
    _ webView: WKWebView,
    requestMediaCapturePermissionFor origin: WKSecurityOrigin,
    initiatedByFrame frame: WKFrameInfo,
    type: WKMediaCaptureType,
    decisionHandler: @escaping (WKPermissionDecision) -> Void
) {
    decisionHandler(origin.host == "your-domain.example" ? .grant : .prompt)
}

Without the WKUIDelegate method, WebKit shows its own camera prompt even though the SDK has skipped the button.

Android (android.webkit.WebView)

Use addDocumentStartJavaScript from androidx.webkit. Calling evaluateJavascript from onPageStarted is not guaranteed to run before the page's own scripts.

webView.settings.mediaPlaybackRequiresUserGesture = false

if (WebViewFeature.isFeatureSupported(WebViewFeature.DOCUMENT_START_SCRIPT)) {
    WebViewCompat.addDocumentStartJavaScript(
        webView,
        grantedCameraScript, // the JavaScript above
        setOf("https://your-domain.example")
    )
}

webView.webChromeClient = object : WebChromeClient() {
    override fun onPermissionRequest(request: PermissionRequest) {
        if (PermissionRequest.RESOURCE_VIDEO_CAPTURE in request.resources) {
            request.grant(arrayOf(PermissionRequest.RESOURCE_VIDEO_CAPTURE))
        } else {
            request.deny()
        }
    }
}

Before you ship it

  • Inject the script only when the native camera permission is actually granted. Otherwise the SDK skips the button, the camera fails to open, and the claim ends in an error instead of a prompt.
  • The permission event no longer fires for these sessions, because grant_button is never shown. Do not wait on it.
  • The start button must still be tapped by the user. With grant_button gone, that tap is the only user gesture in the journey. Starting the claim from script leaves video playback, motion permission and fullscreen with no gesture to use. See User Gestures.
  • No changes to the Web SDK itself are required.
⚠️ **GitHub.com Fallback** ⚠️