Installation
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
@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.comor, in the sandbox,http://localhost:5173. - Only
httpsis accepted, excepthttp://localhostin the sandbox. https://*.example.comallows every subdomain ofexample.com. The*must be the leftmost part, in front of a domain you own, not a public suffix such asco.zm.- Changes to a key or its domains, including revoking it, can take up to a minute to apply.
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
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
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.The
id of a verification your server created.onReady, onComplete, onError and onCancel are required. onStart is optional. See Callbacks.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().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.
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 needsfetch 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.
