Geolocation npm package
Last updated
Was this helpful?
Was this helpful?
npm i @w3bstream/geolocation-lightconst geolocation = new GeolocationVerifier()new GeolocationVerifier({isMainnet: true})geolocation.location = {
latitude: 47.658872, // range [-90, 90]
longitude: -27.4444, // range [-180, 180]
distance: 1000, // range [0, infinity), meters
from: 1676305034021, // timestamp, unix milliseconds
to: 1676305034488 // timestamp, unix milliseconds
}// sets location area
geolocation.scaledLocation = {
scaled_latitude: -45500000,
scaled_longitude: 123000000,
distance: 100,
from: 1676305034, // timestamp, unix seconds
to: 1676305035 // timestamp, unix seconds
}// generates Siwe message and returns it as a string
const msg = geolocation.generateSiweMessage({
domain: string,
uri: string,
address: string,
})// sets the signature
geolocation.signature = "the-signature-you-just–got"const verifiedLocation = await geolocation.verifyLocation();