@espuni/browser
v0.2.0
Published
Browser SDK for the espuni Age Verification flow (DC API → OID4VP/QR fallback)
Readme
@espuni/browser
Browser SDK for the espuni Age Verification flow. Encapsulates the DC API →
OID4VP/QR fallback so relying parties don't reimplement it, built over the
shared @espuni/core logic.
- Prefers the Digital Credentials API (ISO 18013-7) when the browser supports it
and the session carries
orgIsoMdoc; otherwise falls back to the OID4VP QR/deeplink flow (av://rewrite via core, configurable). - Resolves the result via your backend's poll and/or SSE endpoint (poll is
fetched with
cache: 'no-store'). - Render-agnostic QR: pass a
container(+ optionalrenderQr, defaults towindow.QRCode/qrcodejs) or take the derived links fromonLinksand render them yourself.
Decoupled from any specific backend: your server creates the session with the
espuni API (or @espuni/node) and hands the browser the session plus the URLs
on your backend for DC API submission and result polling.
<script src="https://unpkg.com/@espuni/browser"></script>
<script>
espuni.verify({
session, // from your server (createSession)
dcApiSubmitUrl: '/av/dc-response/' + session.sessionId,
pollUrl: '/av/session/' + session.sessionId,
container: document.getElementById('qr'),
onSuccess: (r) => console.log('verified', r.ageOver18),
onFailure: (e) => console.warn(e.error),
});
</script>Or via npm: import { verify, hasDcApi } from '@espuni/browser'.
Ships ESM/CJS (
import) and an IIFE global (window.espuni, for<script>/CDN).@espuni/coreis bundled in — no runtime dependency.
