Class GeoLocationValidator

A geolocation validation middleware to based on Ip address

Hierarchy

  • GeoLocationValidator

Constructors

Properties

radiusOfEarth: number = 6371000

Radius of the earth in meters

Methods

  • A method to calculate the distance between two geographic points based on latitude and longitude

    Parameters

    • coordinates1: Coordinates

      A object/interface containing the longitude and latitude of the point of location

    • coordinates2: Coordinates

      An object/interface containing the longitude and the latittude of the point of reference

    Returns number

    The distance between these points in meters

  • Converts degrees to radians

    Parameters

    • deg: number

    Returns number

  • Fetches coordinates using IP Geolocation API on

    Returns any

  • Fetches the ip address of the client making the HTTP request

    Parameters

    • req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>

      The req object of the HTTP request

    • ipDataAPIKey: string

    Returns Promise<Coordinates>

    • Geographic coordinates of device based on http request to be validated on backend application
  • using Azure Map services, a physical address can be passed to give its coordinates

    Parameters

    • address: string

      Pass in the physical address of a location to be gp

    • azureMapAPIKey: string

    Returns Promise<Coordinates>

  • using Google Map services, a physical address can be passed to give its coordinates

    Parameters

    • address: string

      Pass in the physical address of a location to be geocoded

    • googleMapAPIKey: string

      API key of Google Geocoding API

    Returns Promise<Coordinates>

  • Validation Method to check location of device

    Parameters

    • userCoordinates: Coordinates

      Geographic coordinates of device

    • validationPoint: Coordinates

      Geographic coordinates of validation point

    • range: number

      Acceptable distance between the device and validation point in meters

    Returns Promise<ValidationMessage>

    Validation message True or false

Generated using TypeDoc