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

@nearid/sdk

v2.0.1

Published

NearID Node.js SDK

Downloads

665

Readme

NearID Node.js SDK

This directory contains the official Node.js SDK for interacting with the NearID Cloud backend. It implements REST API wrappers and webhook verification logic exactly as defined in the protocol specification.

All SDK behavior follows: protocol/spec.md


Features

  • Typed API client (TypeScript)
  • REST methods for orgs, sessions lifecycle, receivers, presence, billing, incidents
  • Webhook signature verification
  • Pagination helpers
  • Error handling & retry wrappers
  • Full API reference (method-by-method)

Installation

npm install @nearid/sdk


API Reference

See the complete method-by-method docs, parameters, responses, and errors in:

  • ../API_REFERENCE.md

Usage Example

import { NearIDClient } from "@nearid/sdk";

const client = new NearIDClient({ apiKey: "YOUR_API_KEY", baseUrl: "https://api.nearid.example" });

const events = await client.listPresenceEvents({ orgId: "org_123" });

await client.createLink({ orgId: "org_123", userRef: "emp_45" });

await client.linkPresenceSession({ presenceSessionId: "psess_001", userRef: "emp_45", orgId: "org_123" });


Webhook Verification

import { verifyNearIDWebhook } from "@nearid/sdk";

const isValid = verifyNearIDWebhook({ rawBody, signature: headers["x-hnnp-signature"], timestamp: headers["x-hnnp-timestamp"], webhookSecret: process.env.WEBHOOK_SECRET });


Webhook Consumer Example (Express)

You can use the SDK helper inside a minimal Express server. An example is provided in:

  • examples/webhook-consumer.ts

Outline:

import express from "express";
import { verifyNearIDWebhook } from "@nearid/sdk";

const app = express();
app.use(express.json({ verify: (req, _res, buf) => { req.rawBody = Buffer.from(buf); } }));

app.post("/nearid/webhook", (req, res) => {
  const isValid = verifyNearIDWebhook({
    rawBody: req.rawBody,
    signature: req.header("X-HNNP-Signature"),
    timestamp: req.header("X-HNNP-Timestamp"),
    webhookSecret: process.env.WEBHOOK_SECRET
  });

  if (!isValid) return res.status(400).json({ error: "invalid_webhook_signature" });

  console.log("Received NearID webhook", req.body);
  return res.status(200).json({ status: "ok" });
});

Available Methods

Receivers

  • listReceivers({ orgId })
  • createReceiver({ orgId, receiverId, authMode, ... }) // authMode: "hmac_shared_secret" | "public_key"
  • updateReceiver({ orgId, receiverId, ... })

Presence (public)

  • listPresenceEvents({ orgId, ... })
  • listPresenceSessions({ orgId, ... })

Links (public)

  • createLink({ orgId, userRef, deviceId? })
  • createLinkV2({ orgId, presenceSessionId, userRef, registrationBlob? })
  • activateLink(id)
  • revokeLink(id)
  • revokeLinkV2({ orgId, linkId })
  • listLinks({ orgId, userRef? })
  • linkPresenceSession({ orgId, presenceSessionId, userRef })
  • unlink(id)

Org console

  • listOrgs()
  • getOrg({ orgId })
  • getOrgSettings({ orgId })
  • updateOrgSettings({ orgId, settings })
  • getOrgConfig({ orgId })
  • updateOrgConfig({ orgId, config })
  • getOrgMetricsRealtime({ orgId, ... })
  • listOrgUsers({ orgId })

Receivers health (org console)

  • listReceiversAdmin()
  • getReceiver({ receiverId })
  • updateReceiverAdmin({ receiverId, payload })
  • getReceiverStatus({ receiverId })
  • getReceiverHealth({ receiverId })

Sessions lifecycle (org console)

  • listOrgSessions()
  • getOrgSessionsSummary()
  • createOrgSession(payload)
  • updateOrgSession({ sessionId, payload })
  • deleteOrgSession({ sessionId })
  • finalizeOrgSession({ sessionId })

Attendance + presence (org console)

  • getPresenceLive()
  • getPresenceLogs()
  • getPresenceEvents()
  • listLocations()
  • listGroups()
  • createGroup(payload)
  • updateGroup({ groupId, payload })
  • deleteGroup({ groupId })
  • getAttendance()
  • exportAttendanceCsv()

Billing

  • getBillingSummary()
  • listInvoices()
  • getInvoicePdf({ invoiceId })

Incidents + safety

  • listIncidents()
  • getIncident({ incidentId })
  • getIncidentRollcall({ incidentId })
  • getSafetyStatus()
  • getSafetySummary()

File Structure

src/ index.ts client.ts http.ts webhook.ts types.ts


Environment Variables

WEBHOOK_SECRET=your_org_webhook_secret


Notes

  • Webhook signing follows the HMAC rules in Section 10.3 of the v2 spec.
  • All network calls use HTTPS.
  • SDK MUST NOT alter any packet formats or cryptographic logic.
  • Some endpoints require an org admin JWT (org console auth) instead of an API key.
  • Presence events include verification_status with values verified, weak, or rejected.
  • If verification_status is verified and user_ref is present, the event is linked.

Typed models are exported from @nearid/sdk (see types.ts).

Webhook event payloads are also typed:

  • WebhookEvent
  • WebhookPresenceCheckIn
  • WebhookPresenceUnknown
  • WebhookLinkCreated
  • WebhookLinkRevoked

Pagination helpers

for await (const evt of client.iteratePresenceEvents({ orgId: "org_123" })) {
  console.log(evt.id);
}

for await (const sess of client.iteratePresenceSessions({ orgId: "org_123" })) {
  console.log(sess.session_id);
}

for await (const rcv of client.iterateReceivers({ orgId: "org_123" })) {
  console.log(rcv.receiver_id);
}

Rate limiting

The client retries on 5xx and 429 responses with exponential backoff.
If Retry-After is provided, it is respected (up to 30s).


Testing

npm test


Reference

Full protocol spec: ../../protocol/spec.md