Frontend SDK for age verification via UNQVerify using MitID
npm install @unqtech/age-verification-mitidFrontend SDK for age verification using UNQVerify (MitID-powered).
š Official site: aldersverificering.dk
---
``bash`
npm install @unqtech/age-verification-mitid
---
`ts
import {
init,
startVerificationWithRedirect,
startVerificationWithPopup,
isVerified,
getVerifiedAge,
resetVerification,
handleRedirectResult,
} from '@unqtech/age-verification-mitid'
init({
publicKey: 'pk_test_abc123',
ageToVerify: 18,
redirectUri: 'https://yourapp.com/verify-result',
onVerified: (payload) => {
console.log('ā
Verified!', payload)
const age = getVerifiedAge()
console.log('Verified age:', age)
},
onFailure: (error) => {
// For React: setErrorMessage(error.message)
// For plain JS:
console.error('ā Verification failed', error)
}
})
if (!isVerified()) {
startVerificationWithRedirect()
// or: startVerificationWithPopup()
}
`
`ts
import { handleRedirectResult } from '@unqtech/age-verification-mitid'
handleRedirectResult({
onVerified: (payload) => {
console.log('ā
Token verified:', payload)
window.close() // Optional: auto-close popup
},
onFailure: (err) => {
console.error('ā Invalid token', err)
}
})
`
---
- ā
Secure JWT verification via .well-known/jwkspk_
- ā
Stores cookie-based session (24h)
- ā
Fully frontend-safe ( public key model)
- ā
Supports redirect and (soon) popup mode
- ā
Easy integration in any JS or React app
---
If verification is successful, a cookie named unqverify_token is set and used to skip future verifications (until expired).
You can clear this with:
`ts
import { resetVerification } from '@unqtech/age-verification-mitid'
resetVerification()
`
---
| Function | Description |
|----------------------------------|-----------------------------------------------------|
| init(config) | Initializes the SDK with your public key & options |startVerificationWithRedirect()
| | Starts the flow in redirect mode |startVerificationWithPopup()
| | Starts the flow in popup mode |isVerified()
| | Returns true if the user has a valid token |handleRedirectResult()
| | Used on redirect page to verify and persist token |getVerifiedAge()
| | Returns the verified age if available |resetVerification()
| | Deletes the session token cookie |
---
All JWTs are signed with RS256 and verified against:
```
https://test.api.aldersverificering.dk/well-known/openid-configuration/jwks
https://api.aldersverificering.dk/well-known/openid-configuration/jwks
---
MIT Ā© UNQTech ApS