🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@w3bstream/geolocation

Package Overview
Dependencies
Maintainers
4
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@w3bstream/geolocation

```bash pnpm i @w3bstream/geolocation ```

latest
npmnpm
Version
0.1.12
Version published
Maintainers
4
Created
Source

Installation

pnpm i @w3bstream/geolocation

Guide

import { GeolocationSDK } from "@w3bstream/geolocation";
import ethers from 'ethers';

// if you want to use wallet signer, you can use this, and you need to set YourPrivateKey, please store your private key locally and don't expose it to the public, in online deployment, you can inject it from environment variables
const signer = new ethers.Wallet(YourPrivateKey);
// if your private key is stored by wallet software, such as metamask, you can use this
// const signer = new ethers.providers.Web3Provider(window.ethereum).getSigner();


const sdk = new GeolocationSDK({
  mode: "dev", //"dev" | "prod", it's optional, default is 'dev'
  signer, // signer extends ethers.Signer
});
const proof = await sdk.pol.getProof({
  locations: [
    {
      from: 1676879793, // The start of the time range of interest (Unix timestamp).
      to: 1676015793, // The end of the time range of interest (Unix timestamp).
      scaled_latitude: 30400000, // The GPS latitude where the user is supposed to be. tip:(4.131637, 10.168213) => (4131637, 10168213)
      scaled_longitude: 120520000, // The GPS longitude where the user is supposed to be. tip:(4.131637, 10.168213) => (4131637, 10168213)
      distance: 1000, // The maximum distance from the GPS location you allow the user to be (integer, meters)
    },
  ],
});
// if you want to use mock api, you can use this
const proof = await sdk.pol.getMockProof({
  locations: [
    {
      imei: "123456789012345", // The imei of the device, you can set any value you want
      from: 1676879793, // The start of the time range of interest (Unix timestamp).
      to: 1676015793, // The end of the time range of interest (Unix timestamp).
      scaled_latitude: 30400000, // The GPS latitude where the user is supposed to be. tip:(4.131637, 10.168213) => (4131637, 10168213)
      scaled_longitude: 120520000, // The GPS longitude where the user is supposed to be. tip:(4.131637, 10.168213) => (4131637, 10168213)
      distance: 1000, // The maximum distance from the GPS location you allow the user to be (integer, meters)
    },
  ],
});

FAQs

Package last updated on 15 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts