The agecheck.pro SDK exposes a public API through the global object window.AgeCheck and a DOM event system based on CustomEvent. This page documents all available methods and all events the SDK can emit.
Methods
AgeCheck.show()
Shows the age verification modal. Returns Promise<boolean> — true if the modal was displayed successfully.
window.AgeCheck.show();
window.AgeCheck.show().then(function(shown) {
if (shown) console.log('Modal shown');
});
AgeCheck.hide()
Hides the verification modal if currently visible. Returns boolean.
window.AgeCheck.hide();
AgeCheck.on(event, callback) / AgeCheck.off(event, callback)
Subscribes or unsubscribes a function to an internal SDK event (without the agecheck: prefix).
window.AgeCheck.on('complete', function(data) {
console.log('Verification complete:', data);
});
window.AgeCheck.off('complete', handleComplete);
AgeCheck.isVerified()
Indicates whether the current user is verified. Returns boolean.
if (window.AgeCheck.isVerified()) {
showContent();
} else {
window.AgeCheck.show();
}
AgeCheck.getStatus()
Returns an object with the current complete state of the SDK.
const status = window.AgeCheck.getStatus();
// { version, state, config, currentModule, managers }
| State value | Description |
|---|---|
idle |
SDK loaded but not yet initialized |
initializing |
Initialization in progress |
ready |
SDK initialized and ready to show the modal |
verified |
User verified successfully |
failed |
Verification failed |
error |
Error during initialization or verification |
geo-blocked |
User blocked by geographic restriction |
AgeCheck.clearVerification()
Clears the verification data saved in cookies and localStorage. The user will need to verify again on their next visit.
window.AgeCheck.clearVerification();
DOM Events
All events are prefixed with agecheck: and data is available in event.detail. They can also be listened to via AgeCheck.on() (without the prefix).
agecheck:initialized
Emitted when the SDK completes initialization and the remote configuration is loaded.
document.addEventListener('agecheck:initialized', function(event) {
console.log('SDK ready. Config:', event.detail.config);
});
agecheck:complete
Emitted when the verification process ends. The event.detail.success field indicates the outcome.
document.addEventListener('agecheck:complete', function(event) {
if (event.detail.success) {
console.log('Verified. Method:', event.detail.method);
console.log('Token:', event.detail.verification_token);
} else {
console.log('Verification failed:', event.detail.error);
}
});
agecheck:already-verified
Emitted when the SDK detects that the user already has a valid verification in storage.
agecheck:error
Emitted when an error occurs during initialization or verification.
agecheck:geo-blocked
Emitted when the user accesses from a blocked geographic location.
Events Summary
| DOM Event | AgeCheck.on() name | When emitted |
|---|---|---|
agecheck:initialized |
initialized |
SDK completed initialization |
agecheck:complete |
complete |
Verification process finished |
agecheck:already-verified |
already-verified |
User was already verified |
agecheck:error |
error |
Initialization or verification error |
agecheck:geo-blocked |
geo-blocked |
IP blocked by geographic restriction |
agecheck:modal-opened |
modal-opened |
Modal made visible |
agecheck:modal-closed |
modal-closed |
Modal hidden |
agecheck:rate-limited |
rate-limited |
Attempt limit exceeded |
agecheck:verification-cleared |
verification-cleared |
Verification data cleared |
Methods Summary
| Method | Returns | Description |
|---|---|---|
AgeCheck.show() |
Promise<boolean> |
Shows the verification modal |
AgeCheck.hide() |
boolean |
Hides the modal |
AgeCheck.on(event, fn) |
void |
Subscribes to an internal event |
AgeCheck.off(event, fn) |
void |
Unsubscribes from an internal event |
AgeCheck.getStatus() |
Object |
Full SDK status |
AgeCheck.isReady() |
boolean |
Whether the SDK is ready to operate |
AgeCheck.isVerified() |
boolean |
Whether the user is verified |
AgeCheck.clearVerification() |
boolean |
Clears stored verification data |
AgeCheck.getVersion() |
string |
SDK version |