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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@retic/geofence-sdk

v0.1.2

Published

JavaScript SDK for Retic Geofence Pro - geofencing, IP geolocation, and location rules

Readme

@retic/geofence-sdk

JavaScript SDK for Retic Geofence Pro — geofencing, IP geolocation, fraud detection, and location-based rules.

  • Zero dependencies
  • Works in any browser or bundler (ESM + UMD)
  • Full TypeScript support
  • Automatic device fingerprinting
  • Browser geolocation with IP fallback

Install

npm install @retic/geofence-sdk

Or via CDN:

<script src="https://unpkg.com/@retic/geofence-sdk/dist/retic.umd.js"></script>

Quick Start

import { Retic } from '@retic/geofence-sdk'

const retic = Retic.initialize('your_publishable_key')

const result = await retic.trackOnce()
console.log(result.user.location)  // { latitude, longitude, city, country_code, ... }
console.log(result.user.fraud)     // { passed, vpn, proxy, tor, mocked }
console.log(result.events)         // [{ type: 'entry', geofence: { tag, ... } }]
console.log(result.rules)          // { allowed: true }

API Reference

Retic.initialize(key, options?)

Creates and returns the SDK singleton. Must be called before any other method.

const retic = Retic.initialize('retic_live_pk_...', {
  baseUrl: 'https://geofencepro.retic.co',  // default, can be omitted
  onEvents: (events) => { /* geofence entry/exit/dwell */ },
  onRuleAction: (action) => { /* location rule triggered */ },
  onError: (err) => { /* { code, message } */ },
})

Options

| Option | Type | Description | |---|---|---| | baseUrl | string | API base URL. Defaults to https://geofencepro.retic.co | | onEvents | (events: GeofenceEvent[]) => void | Called when geofence events are triggered | | onRuleAction | (action: RuleAction) => void | Called when a location rule blocks the user | | onError | (error: ReticError) => void | Called on any API error |

Retic.getInstance()

Returns the existing SDK instance. Throws if initialize() hasn't been called.

const retic = Retic.getInstance()

retic.trackOnce(location?)

Tracks the user's location and evaluates geofences and rules. Automatically requests browser geolocation; falls back to IP-based location if denied.

// Auto-detect location
const result = await retic.trackOnce()

// Or provide coordinates manually
const result = await retic.trackOnce({
  latitude: 40.7128,
  longitude: -74.0060,
  accuracy: 10,
})

Returns: TrackResponse

{
  events: GeofenceEvent[]  // geofence entry/exit/dwell events
  user: TrackedUser        // user info, location, and fraud check
  rules: RuleResult        // whether the user is allowed
}

retic.ipGeocode()

Returns geolocation data for the user's IP address without triggering geofence evaluation.

const geo = await retic.ipGeocode()
console.log(geo.city, geo.state, geo.country)

Returns: IpGeocodeResponse

{
  ip_address: string
  latitude?: number
  longitude?: number
  country_code?: string
  country?: string
  state_code?: string
  state?: string
  city?: string
  postal_code?: string
  timezone?: string
}

retic.searchGeofences(options)

Searches for geofences near a given point.

const geofences = await retic.searchGeofences({
  latitude: 40.7128,
  longitude: -74.0060,
  radius: 5000,  // meters, optional
  limit: 10,     // optional
})

Returns: GeofenceRef[]

{
  id: string
  tag: string
  external_id: string
  description?: string
}

retic.setUserId(userId)

Associates a user ID with subsequent tracking calls.

retic.setUserId('user_123')

retic.setMetadata(metadata)

Attaches custom key-value metadata to subsequent tracking calls.

retic.setMetadata({ plan: 'pro', source: 'checkout' })

Types

All types are exported for TypeScript users:

import type {
  ReticOptions,
  TrackResponse,
  GeofenceEvent,
  GeofenceRef,
  TrackedUser,
  UserLocation,
  FraudResult,
  RuleResult,
  RuleAction,
  IpGeocodeResponse,
  SearchGeofencesOptions,
  ReticError,
} from '@retic/geofence-sdk'

GeofenceEvent

{
  id: string
  type: 'entry' | 'exit' | 'dwell'
  confidence: number
  geofence: GeofenceRef
  created_at: string
}

FraudResult

{
  passed: boolean   // true if no fraud signals detected
  proxy: boolean
  vpn: boolean
  tor: boolean
  mocked: boolean   // spoofed GPS
}

RuleResult

{
  allowed: boolean       // false if a location rule blocks the user
  action?: string        // 'block' | 'redirect' | ...
  redirect_url?: string  // set when action is 'redirect'
}

Framework Examples

React

import { Retic } from '@retic/geofence-sdk'

// Initialize once at app entry
Retic.initialize('your_key', {
  onRuleAction: ({ action, redirect_url }) => {
    if (action === 'redirect') window.location.href = redirect_url
  },
})

function App() {
  useEffect(() => {
    Retic.getInstance().trackOnce()
  }, [])

  return <div>...</div>
}

Vanilla JS

<script src="https://unpkg.com/@retic/geofence-sdk/dist/retic.umd.js"></script>
<script>
  const retic = Retic.Retic.initialize('your_key')
  retic.trackOnce().then(result => {
    if (!result.rules.allowed) {
      document.body.innerHTML = '<h1>Access restricted in your region</h1>'
    }
  })
</script>

License

MIT