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

@procteye/node

v2.1.0

Published

Official server-side Node.js SDK for the Procteye Integrity API. Create and manage integrity sessions and verify webhooks from your backend.

Readme

@procteye/node

Official server-side Node.js SDK for the Procteye Integrity API. Use it from your backend to create and manage integrity sessions and to verify incoming webhooks.

This is a secret-key SDK. Never ship your pe_sk_... key to a browser or mobile client. Browser integration is handled by @procteye/proctor-js.

Install

npm install @procteye/node

Requires Node.js 20.19+ (uses the built-in fetch and crypto). One runtime dependency: @paralleldrive/cuid2, which generates the default idempotency keys.

Quickstart

import { Procteye } from "@procteye/node";

const procteye = new Procteye(process.env.PROCTEYE_API_KEY!);

const session = await procteye.sessions.create({
  assurance_level: "HIGH",
  external_user_ref: "user_42",
  candidate_email: "[email protected]",
});

console.log(session.id, session.client_secret); // hand client_secret to the browser
console.log(session.launch.mode); // "browser" | "browser+mobile" | "desktop"

Configuration

const procteye = new Procteye(apiKey, {
  baseUrl: "https://api.procteye.com", // or PROCTEYE_BASE_URL
  timeout: 30_000, // per-request timeout (ms)
  maxRetries: 2, // retries on 429/5xx
});

apiKey falls back to PROCTEYE_API_KEY and baseUrl to PROCTEYE_BASE_URL.

Sessions

await procteye.sessions.create(params); // POST /external/v1/sessions
await procteye.sessions.retrieve(id); // GET  /external/v1/sessions/:id
await procteye.sessions.complete(id); // POST .../complete
await procteye.sessions.cancel(id); // POST .../cancel

// Auto-paginating async iterator (fetches pages as you go):
for await (const s of procteye.sessions.list({ limit: 50 })) {
  console.log(s.id, s.status);
}

// Or a single raw page:
const page = await procteye.sessions.listPage({ limit: 50 });

sessions.create() resolves to a CreatedSession: client_secret, launch (mode, plus deep_link and download_url for HIGH or mobile_pairing_url for STANDARD) and expires_at are always present there. retrieve, list, complete and cancel return an IntegritySession, which never carries the client secret.

sessions.create() sends only the documented fields (assurance_level, duration_minutes, external_user_ref, candidate_name, candidate_email, evidence_mode, metadata) and drops any other key, including keys passed by untyped JavaScript callers. The API itself now rejects unknown request fields with HTTP 400 and the error code unknown_field, so clients that call the API directly should send only documented fields too.

Idempotency

Every POST and DELETE automatically carries an Idempotency-Key header. If you omit one, a cuid2 is generated per call. Pass your own to make a retry safe end-to-end:

await procteye.sessions.create(params, { idempotencyKey: "order_1234" });

Because writes are idempotent, the SDK can safely retry failed requests.

Automatic retries

Requests that fail with 429 or 5xx are retried up to maxRetries times with exponential backoff and full jitter. A Retry-After response header is honored when present. A 409 with code idempotency_request_in_progress (the first request with the same key is still running) is retried the same way, with the same Idempotency-Key, and counts toward maxRetries. Any other 409, such as idempotency_key_in_use, is not retried.

Errors

All non-2xx responses raise a typed error. Every error exposes code, message, status, requestId, and docUrl.

import {
  BillingError,
  RateLimitError,
  InvalidRequestError,
} from "@procteye/node";

try {
  await procteye.sessions.create({ assurance_level: "HIGH" });
} catch (err) {
  if (err instanceof BillingError && err.code === "insufficient_credits") {
    // top up credits
  } else if (err instanceof RateLimitError) {
    // back off
  } else if (err instanceof InvalidRequestError) {
    console.error(err.message, err.requestId);
  }
}

| HTTP status | Class | Retried | | ----------------- | -------------------------------------------------------------------------------------------- | -------------------------------------- | | 400 / 404 / 422 | InvalidRequestError | no | | 401 | AuthenticationError | no | | 402 | BillingError | no | | 403 | PermissionError (extends AuthenticationError; code insufficient_scope) | no | | 409 | InvalidRequestError (code idempotency_request_in_progress, idempotency_key_in_use, or session_not_active from cancel on a session that is already final) | only idempotency_request_in_progress | | 429 | RateLimitError | yes | | 5xx | ApiError | yes | | other 4xx | InvalidRequestError | no | | network / timeout | ConnectionError | yes |

The X-Request-Id from every response is available on both the returned objects' originating request and on thrown errors (err.requestId) — include it in support requests.

Webhook verification

Verify webhook signatures with the raw request body (Standard Webhooks compatible):

import express from "express";
import { Procteye, WebhookVerificationError } from "@procteye/node";

const procteye = new Procteye(process.env.PROCTEYE_API_KEY!);
const app = express();

// IMPORTANT: use the raw body, not a parsed JSON object.
app.post(
  "/webhooks/procteye",
  express.raw({ type: "application/json" }),
  (req, res) => {
    try {
      const event = procteye.webhooks.constructEvent(
        req.body, // Buffer of the raw bytes
        req.headers,
        process.env.PROCTEYE_WEBHOOK_SECRET!, // whsec_...
      );
      if (event.type === "session.completed") {
        // The runtime session ended; finalize the verdict.
        const { id } = event.data as { id: string };
        void procteye.sessions.complete(id);
      } else if (event.type === "session.canceled") {
        // Sent after a successful cancel.
        const { id } = event.data as { id: string };
        console.log("Session canceled:", id);
      }
      res.sendStatus(200);
    } catch (err) {
      if (err instanceof WebhookVerificationError) return res.sendStatus(400);
      throw err;
    }
  },
);

The verifier rejects any request with a missing header, a bad signature, or a timestamp older than 5 minutes.

Examples

examples/express-server.ts is a runnable Express backend that creates sessions and receives verified webhooks.

Links

  • Documentation: https://docs.procteye.com
  • npm: https://www.npmjs.com/package/@procteye/node
  • Browser SDK: @procteye/proctor-js

License

MIT