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 🙏

© 2024 – Pkg Stats / Ryan Hefner

my-security-package1

v1.0.9

Published

A security package providing various utilities for IP detection, device fingerprinting, bot detection, cookie duplication checking, country verification, and VPN detection.

Downloads

48

Readme

Here is a comprehensive README file for your npm package, tailored for use with React and Next.js in both JavaScript and TypeScript. This README covers all functions and their usage.


@vaibhav_masaye/security-package

A security package providing various utilities for IP detection, device fingerprinting, bot detection, cookie duplication checking, country verification, and VPN detection.

Installation

To use this package in your project, install it via npm:

npm install my-security-package1

Usage

In a React or Next.js Project

JavaScript

  1. Import the Functions

    import { 
      getSystemIP, 
      getDeviceFingerprint, 
      isBot, 
      checkCookieDuplication, 
      verifyCountry, 
      isUsingVPN,
      getGeoData 
    } from '@vaibhav_masaye/security-package';
  2. Usage Examples

    // Get System IP
    getSystemIP().then(ip => console.log('IP Address:', ip));
    
    // Get Device Fingerprint
    console.log('Device Fingerprint:', getDeviceFingerprint());
    
    // Detect Bot
    console.log('Is Bot:', isBot(navigator.userAgent));
    
    // Check Cookie Duplication
    console.log('Cookie Duplicate:', checkCookieDuplication('cookieName'));
    
    // Verify Country
    verifyCountry('India').then(isMatch => console.log('Country Match:', isMatch));
    
    // Detect VPN
    isUsingVPN().then(isVPN => console.log('Is Using VPN:', isVPN));
    
    // Get Geo Data
    getGeoData().then(data => console.log('Geo Data:', data));

TypeScript

  1. Import the Functions

    import { 
      getSystemIP, 
      getDeviceFingerprint, 
      isBot, 
      checkCookieDuplication, 
      verifyCountry, 
      isUsingVPN,
      getGeoData 
    } from '@vaibhav_masaye/security-package';
  2. Usage Examples

    // Get System IP
    getSystemIP().then((ip: string) => console.log('IP Address:', ip));
    
    // Get Device Fingerprint
    console.log('Device Fingerprint:', getDeviceFingerprint());
    
    // Detect Bot
    console.log('Is Bot:', isBot(navigator.userAgent));
    
    // Check Cookie Duplication
    console.log('Cookie Duplicate:', checkCookieDuplication('cookieName'));
    
    // Verify Country
    verifyCountry('India').then((isMatch: boolean) => console.log('Country Match:', isMatch));
    
    // Detect VPN
    isUsingVPN().then((isVPN: boolean) => console.log('Is Using VPN:', isVPN));
    
    // Get Geo Data
    getGeoData().then((data: GeoData) => console.log('Geo Data:', data));

Functions

getSystemIP()

  • Returns: Promise<string> - Resolves to the IP address of the current system.

getDeviceFingerprint()

  • Returns: string - Returns a unique identifier for the device.

isBot(userAgent: string)

  • Parameters:
    • userAgent (string): The user agent string of the browser.
  • Returns: boolean - true if the user agent is identified as a bot, otherwise false.

checkCookieDuplication(cookieName: string)

  • Parameters:
    • cookieName (string): The name of the cookie to check.
  • Returns: boolean - true if the cookie is duplicated, otherwise false.

verifyCountry(expectedCountry: string)

  • Parameters:
    • expectedCountry (string): The name of the country to verify.
  • Returns: Promise<boolean> - Resolves to true if the system's country matches the expected country, otherwise false.

isUsingVPN()

  • Returns: Promise<boolean> - Resolves to true if a VPN is detected, otherwise false.

getGeoData()

  • Returns: Promise<GeoData> - Resolves to an object containing geographical data based on the system's IP address.

TypeScript Definitions

Here’s the TypeScript type for GeoData:

interface GeoData {
  ip: string;
  continent_code: string;
  continent_name: string;
  country_code2: string;
  country_code3: string;
  country_name: string;
  country_name_official: string;
  country_capital: string;
  state_prov: string;
  state_code: string;
  district: string;
  city: string;
  zipcode: string;
  latitude: string;
  longitude: string;
  is_eu: boolean;
  calling_code: string;
  country_tld: string;
  languages: string;
  country_flag: string;
  geoname_id: string;
  isp: string;
  connection_type: string;
  organization: string;
  country_emoji: string;
  asn: string;
  currency: {
    code: string;
    name: string;
    symbol: string;
  };
  time_zone: {
    name: string;
    offset: number;
    offset_with_dst: number;
    current_time: string;
    current_time_unix: number;
    is_dst: boolean;
    dst_savings: number;
  };
}

License

This package is licensed under the MIT License. See the LICENSE file for details.


Feel free to adjust any sections according to your specific needs or add any additional information that might be relevant for your package.