npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

age-estimator

v0.0.6

Published

Easy to use tool to estimate users age

Readme

Age Estimator

A privacy-focused tool for estimating user age using local facial recognition. All processing happens on the user's device - no data is ever sent to any servers.

Drop-in script

Want to just drop a tag into your html pages to add age gates without worrying about implementation? Read here

Live Demo

Try the age estimator directly: https://universal-verify.github.io/age-estimator/

Integration Examples

See how to integrate the age estimator into your website: https://universal-verify.github.io/age-estimator/examples

Installation

npm install age-estimator

Usage

import ageEstimator from 'age-estimator';

// Basic usage with async/await
try {
    const age = await ageEstimator.estimateAge({ livenessCheck: true });
    console.log('Estimated age:', age);
} catch (error) {
    console.error('Age estimation failed:', error);
}

// Or with .then/.catch
ageEstimator.estimateAge({ livenessCheck: true })
    .then(age => {
        console.log('Estimated age:', age);
    })
    .catch(error => {
        console.error('Age estimation failed:', error);
    });

API Reference

estimateAge(params)

Opens the age estimator in a new tab and returns a Promise that resolves with the estimated age or rejects on error.

Parameters
  • params (Object): Configuration object
    • livenessCheck (Boolean): Optional parameter to enable liveness detection
      • When true, performs additional verification to ensure the user is present
      • Helps prevent spoofing attempts using photos
      • Default: false
    • enableCache (Boolean): Optional parameter to enable caching of age estimation results
      • When true, the estimated age will be cached for future use
      • Default: false
    • cacheDuration (Number): Optional parameter to determine the number of milliseconds the cached results will be stored for
      • Only used when enableCache is true
      • Default: 24 hours
Returns
  • Promise: Resolves with the estimated age (number) if successful, rejects with an error code if it fails, the tab is closed, the popup is blocked, or a different face was detected during the liveness check.
Possible Rejection Error Codes
  • CANCELLED: The user closed the age estimation tab before completing the process.
  • POPUP_BLOCKED: The browser blocked the popup window from opening.
  • WEBCAM_ERROR: There was an issue accessing the user's webcam (e.g., permission denied or device not found).
  • DIFFERENT_FACE_ERROR: The face detected during liveness check was different from the one used for age estimation.
  • INVALID_SIGNATURE: The signature of the token generated by the age estimation tool is invalid, possibly due to a spoofing attempt.
  • INTERNAL_ERROR: An unexpected error occurred during the age estimation process.

clearCache()

Clears any cached age estimation token.

getCachedAge()

Retrieves the cached age estimation result if available. Essentially a wrapper function over getCachedToken() and verifyToken(token).

Returns
  • Promise: Resolves with the cached age (number) if found and valid, null otherwise.

getCachedToken()

Retrieves the raw cached token if available.

Returns
  • string: The cached token if found, null otherwise.

verifyToken(token)

Verifies the authenticity and validity of an age estimation token.

Parameters
  • token (string): The token to verify
Returns
  • Promise: Resolves with the decoded token data if valid, rejects with an error if invalid or expired.

Privacy

The age estimator processes all data locally on the user's device:

  • Video from the user's camera is processed in real-time
  • No video or biometric data is ever sent to any servers
  • If directed from another website, only the estimated age is shared
  • All processing happens in the user's browser

Legal

This age estimator provides a basic level of age verification through facial analysis. While it offers more security than a simple checkbox, it should not be considered a replacement for proper ID validation. For applications requiring verified age confirmation, not just an estimation, we recommend using a comprehensive identity verification solution like Universal Verify.

The age estimator is provided "as is" without any warranties, express or implied. Users are responsible for ensuring compliance with applicable laws and regulations regarding age verification in their jurisdiction.

License

MPL-2.0

Credits

This project uses face-api.js for facial detection and age estimation. All processing is done locally on the user's device.