Skip to main content
The Web SDK runs the verification flow in an iframe inside your page, so the user normally completes it without leaving your site. Your server still creates the verification and receives the result by webhook. The SDK only shows the flow and tells your page when the user is done. Your page is never redirected, no cookies are set on your domain, and no personal data or document images reach it. If the flow cannot run in the user’s browser, for example because the browser is unsupported or camera access stays blocked, the iframe offers a link and a QR code to continue on another device. That link opens the verification on a pawaPass page.

Installation

The CDN script defines a global PawaPass. The npm package has a default ES module export and no runtime dependencies. The CDN path decides which updates you get:

npm registry

The @pawapass scope is published on its own registry. Add this line to the .npmrc in your project, or to ~/.npmrc:
.npmrc
npm and pnpm then install @pawapass/web-sdk as usual. No login is needed.

TypeScript

The npm package includes its type declarations, so there is nothing extra to install. The types of the configuration and of the callback arguments are exported by name:
PawaPassCallbacks, PawaPassInstance, PawaPassErrorCode, PawaPassCompleteStatus and PawaPassLanguage are exported too.

Public key and allowed domains

Create a public key in the Backoffice under Settings > Integration > Web SDK keys (Production, Sandbox). On the key, list the domains your page runs on.
  • The public key is safe to put in your page. It is not your API key.
  • A key works only from the domains listed on it, and only in the environment it was created in.
  • A domain is a scheme and a host, with the port if you use one, and no path. For example https://shop.example.com or, in the sandbox, http://localhost:5173.
  • Only https is accepted, except http://localhost in the sandbox.
  • https://*.example.com allows every subdomain of example.com. The * must be the leftmost part, in front of a domain you own, not a public suffix such as co.zm.
  • Changes to a key or its domains, including revoking it, can take up to a minute to apply.
If your domain is not on the key, or the key is unknown or revoked, the SDK reports NETWORK_ERROR and shows no iframe. The browser hides the reason, so this looks the same as a lost connection. When you see NETWORK_ERROR during integration, check the key and its domains first.

Quickstart

1

Create a verification on your server

Your server creates a verification and passes its id to your page, where the SDK calls it verificationId. The API key stays on your server.The API requires successUrl, errorUrl and supportUrl here too. In the embedded flow, the last screen calls your callbacks instead of linking to successUrl or errorUrl.
2

Add a container

The iframe fills the width of the container. Its height follows the content of the flow and is never less than the height of the container. Set the width you want and let the height grow: a container with a fixed height shorter than the flow is overflowed by the iframe.
3

Start the SDK

destroy() removes the iframe. Call it in onComplete, onCancel and onError: after these callbacks the iframe has nothing more to show. See Cleanup.

Configuration

string
required
Your public key, in the form pk_{env}_{key}, for example pk_sandbox1_... or pk_prod_.... The SDK picks the pawaPass environment from the prefix, so there is nothing else to configure. See Public key and allowed domains.
string
required
The id of a verification your server created.
string
required
The id of the HTML element the iframe is added to.
object
required
onReady, onComplete, onError and onCancel are required. onStart is optional. See Callbacks.
string
default:"en"
The language of the flow: en, fr, pt, rw or sw.
boolean
default:"false"
When true, the SDK keeps a device identifier in localStorage under the key pawapass_device_id, so the same browser is recognised across sessions in pawaPass analytics. When false, the identifier lives in memory and is cleared by destroy().
If the configuration is invalid, init() calls onError straight away, before it returns, and creates no iframe. If onError itself is missing, init() fails without any message.

Callbacks

onReady

The iframe has loaded. Hide your loading indicator here.

onStart

Optional. The user has started the flow. Useful for analytics.

onComplete

The user tapped the button on the last screen of the flow. Call destroy() here: the button stays in a loading state and the iframe does nothing more.
Example result
USER_DATA_COLLECTED and REVIEW are not final. The user has nothing more to do, and the final status arrives by webhook.

onError

An SDK error. Problems in the flow itself, such as a blurry photo, are handled inside the iframe and do not call onError. The error object has code and message. Some errors are reported by the iframe after it loaded, and leave an error screen in it. Call destroy() in onError in every case. You can call init() again with the same verificationId. While the verification has not expired or reached a final status, the user continues it. Otherwise the iframe shows the result.

onCancel

The user tapped Back to your account. That button is on every step and on the error screens, including the one shown when the user’s session times out. Call destroy() here, because the button stays in a loading state. The verification is not cancelled. Its status stays as it was, and it expires on its usual schedule unless the user comes back.

Cleanup

init() returns an instance. destroy() on it removes the iframe, its event listeners and its timers. Calling it more than once is safe.
In a single-page app, call destroy() when the user navigates away during the flow. Calling init() again on the same container destroys the previous instance.

Fullscreen during scans

During the face scan and the document scan, the SDK stretches the iframe over the whole viewport and stops your page from scrolling. When the scan ends, it restores the iframe and your scroll position. Do not place anything that must stay visible on top of the iframe during these steps.

Content Security Policy

The SDK makes one request from your page, to check the public key. Everything else happens inside the iframe. If your site has a Content Security Policy, allow these: The iframe is created with allow="camera" and allowfullscreen. If your page sends a Permissions-Policy header, it must allow camera and fullscreen for the iframe’s domain, or the scans cannot start.

Browser support

The SDK script is ES5 and needs fetch and Promise. The flow inside the iframe needs one of these browsers: On other browsers, including Firefox for Android, some in-app Android browsers and Opera Mini, the iframe shows a message asking the user to switch browsers.