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/sdk

v2.1.0

Published

Embeddable React component for browser-safe Procteye assessment, interview, and screening sessions.

Readme

@procteye/sdk

Embed a browser-safe Procteye session directly into your own React application. <ProcteyeSession> mounts the Procteye assessment portal inside a sandboxed <iframe> and streams session events (violations, completion, errors) back to your app over postMessage.

Scope — read this first. This SDK hosts the browser-safe practice / interview / screening tier: sessions a candidate can take inside an ordinary browser tab (camera + microphone + optional screen share). Full proctored, locked-down assessments run in the Procteye desktop app (kiosk mode, keyboard hook, VM detection, watchdog) — that level of enforcement is not achievable inside an iframe and is intentionally out of scope here. Use this component to let recruiters and partners embed low-friction sessions; hand off to the desktop client for high-stakes proctored exams.

Installation

npm install @procteye/sdk
# or
pnpm add @procteye/sdk
# or
yarn add @procteye/sdk

react and react-dom (^16.8 through ^19) are peer dependencies — the SDK does not bundle its own copy and has zero runtime dependencies.

Usage

import React from "react";
import { ProcteyeSession, ViolationPayload } from "@procteye/sdk";

export function InterviewPage({
  practiceSessionToken,
}: {
  practiceSessionToken: string;
}) {
  const [preparing, setPreparing] = React.useState(false);
  return (
    <div style={{ maxWidth: 1000, margin: "0 auto", padding: 40 }}>
      <h1>Screening Interview</h1>
      {preparing && <p>Preparing your questions…</p>}

      <ProcteyeSession
        // Your own id for this attempt; the portal reports the real one.
        sessionId="attempt_123"
        // practice_session_token from POST /external/v1/practice-sessions,
        // fetched by your backend for this attempt.
        sessionToken={practiceSessionToken}
        portalUrl="https://procteye.com"
        onStarting={() => setPreparing(true)}
        onViolation={(v: ViolationPayload) =>
          console.warn(`[${v.severity}] ${v.type}`, v.details)
        }
        onComplete={(r) => console.log("Session complete:", r)}
        onError={(e) => console.error("Session error:", e.message)}
        style={{ height: 700 }}
      />
    </div>
  );
}

Getting the session token

sessionToken is a practice session token. Your backend gets one from the Integrity API with its secret key, then passes it to the page that renders <ProcteyeSession>:

curl https://api.procteye.com/external/v1/practice-sessions \
  -H "Authorization: Bearer $PROCTEYE_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{"external_user_ref": "user_42", "job_posting_id": "<job posting id>"}'
# => {"practice_session_token": "…", "expires_at": "2026-11-13T10:15:00.000Z"}
  • job_posting_id is the job the practice interview is generated for, and external_user_ref is your own id for the candidate.
  • The token is short-lived (see expires_at) and starts exactly one practice session. A second start with the same token fails with practice_session_token_used, so issue a new token for every attempt.
  • The portal sends the token as the x-practice-session-token header on each request; it is never put in the iframe URL.

Integrity sessions do not use this component. A normal integrity session (POST /external/v1/sessions) returns a client_secret, which goes to the tier-appropriate client named by its launch.mode: @procteye/proctor-js in your own page for browser and browser+mobile, or the Procteye desktop app for desktop. Never pass a client_secret or an API key as sessionToken.

Props

| Prop | Type | Required | Default | Description | | --------------------- | ---------------------------------------------------- | :------: | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | sessionId | string | yes | — | Your own id for this embed (for example the attempt id). Used in the frame URL and as the fallback id in onComplete/onDone; the portal reports the real practice session id. | | sessionToken | string | yes | — | The practice_session_token from POST /external/v1/practice-sessions (see above). Sent to the portal in the procteye:init handshake, never in the URL. Not an API key or client_secret. | | portalUrl | string | no | "https://procteye.com" | Base URL of the Procteye portal; also the trusted origin for incoming postMessage events. Must be HTTPS; plain http is only accepted for localhost in development/test builds or when allowInsecurePortal is set. | | allowInsecurePortal | boolean | no | false | Dev-only escape hatch. Explicitly allows a plain-http portal origin (any host) so the session token can be handed to a local/insecure portal. Never set this in production. | | theme | "light" \| "dark" \| "system" | no | "system" | Colour theme of the session frame. "system" follows your page's prefers-color-scheme and updates the frame when it changes. Sent in procteye:init and, on later changes, in procteye:theme. | | onViolation | (v: ViolationPayload) => void | no | — | Fired for each proctoring violation reported by the session. | | onComplete | (r: { sessionId: string; status: string }) => void | no | — | Fired once when the session finishes, with the real sessionId/status reported by the embed. | | onStarting | () => void | no | — | Fired when the candidate presses Start. Preparing the questions can take around 20 seconds, so show your own progress cue. | | onError | (e: { message: string }) => void | no | — | Fired when the session frame reports an error. | | onDone | (r: { sessionId: string }) => void | no | — | Fired when the candidate dismisses the completed screen — a cue to close/advance the host’s own UI. | | style | React.CSSProperties | no | — | Merged into the outer container style (e.g. override height). | | className | string | no | — | Applied to the outer container <div>. |

ViolationPayload

interface ViolationPayload {
  type: string;
  severity: "low" | "medium" | "high" | "critical";
  details?: string;
  timestamp: number;
}

How it works

The component renders a strictly sandboxed iframe pointed at:

{portalUrl}/sessions/embed?session_id={sessionId}&embed=true

with sandbox="allow-scripts allow-same-origin allow-forms allow-popups" and allow="fullscreen; camera; microphone; display-capture; accelerometer; gyroscope". allow-same-origin lets the portal keep its own origin: without it the frame runs with an opaque origin (Origin: null), its scripts fail CORS and the API refuses its requests, so the portal never loads. This is safe because the portal is served from a different origin than your page, so the same-origin policy still keeps the frame out of your page, and top navigation stays blocked. If portalUrl is on your page's own origin, the component leaves allow-same-origin out, because with allow-scripts that would let the frame reach window.parent.document.

3-Step Bi-Directional PostMessage Handshake Protocol

  1. Step 1 — Frame Mount & Ready Beacon (procteye:ready): When the assessment frame loads inside the iframe, it broadcasts a procteye:ready event to its parent window (window.parent.postMessage({ type: "procteye:ready" }, "*")).
  2. Step 2 — Targeted Initialization Handshake (procteye:init): Upon receiving procteye:ready, <ProcteyeSession> verifies that event.source === iframe.contentWindow and that the event is trustworthy, then transmits the candidate's sessionToken via a targeted message:
    • Opaque-origin frames (same-origin portal only): when the portal shares your page's origin the sandbox omits allow-same-origin, so real browsers report the frame's origin as "null" (an opaque origin). That is accepted only when event.source matches the iframe's own contentWindow (the browser fills this in — it cannot be spoofed by other pages), the sandbox still omits allow-same-origin, and the configured portalUrl is itself an allowed origin (HTTPS, or localhost in dev mode). The init reply is then addressed to that specific window with "*", since an opaque frame cannot be addressed by origin.
    • Portal origin (the normal case): event.origin must exactly match the expected portalUrl origin, byte-for-byte (never prefix-matched), and that origin must be HTTPS outside dev mode.
    iframe.contentWindow.postMessage(
      {
        type: "procteye:init",
        payload: { sessionId, sessionToken, theme }, // theme: "light" | "dark"
      },
      expectedPortalOrigin, // "*" only for the same-origin opaque fallback
    );
    theme is the resolved colour theme ("light" or "dark"): the theme prop, with "system" resolved against the host page's prefers-color-scheme. It is optional for the portal; without it the portal keeps its default light theme.
  3. Step 3 — Origin-Bound Session Execution & Event Stream: The embed host captures trustedParentOrigin = event.origin from the handshake and guarantees that all subsequent event payloads (procteye:violation, procteye:complete, procteye:error, procteye:done) are strictly dispatched directly to trustedParentOrigin (never wildcard "*").

Theme updates (sent by the SDK)

After the handshake, whenever the resolved theme changes (the host's colour scheme changes while theme is "system", or the theme prop changes), the SDK sends the portal, at the same target origin as procteye:init:

{ type: "procteye:theme", payload: { theme: "light" | "dark" } }

postMessage event contract (consumed by the SDK)

The embedded portal dispatches events of the following shape to the parent window. The SDK reads data.type and maps data.payload onto the corresponding callback:

| data.type | data.payload fields | Invokes | | -------------------- | ---------------------------------------------------- | ----------------------------------------------------- | | procteye:ready | (none) | Responds with procteye:init payload containing auth | | procteye:starting | (none) | onStarting() | | procteye:violation | violation_type, severity, details, timestamp | onViolation({ type, severity, details, timestamp }) | | procteye:complete | session_id, status | onComplete({ sessionId, status }) | | procteye:error | message | onError({ message }) | | procteye:done | session_id | onDone({ sessionId }) |

Missing fields fall back to defaults (violation_type → "unknown", severity → "medium", timestamp → Date.now()). For procteye:complete, sessionId/status fall back to the sessionId prop and "completed" only if the embed omits them from the payload. Any other data.type is ignored.

What the embedding site must provide

  • A sessionId of your own and a sessionToken: the practice session token your backend gets from POST /external/v1/practice-sessions. The SDK never asks for and never carries an API key — server credentials stay on your server.
  • The portalUrl of the Procteye deployment you are integrating with.
  • A page served over HTTPS if the portal is HTTPS, and appropriate camera / microphone / display-capture permissions policy so the iframe can request device access. The portalUrl must itself be HTTPS outside development/test builds. For a plain http portal (other than the cases above), a javascript: URL or a malformed one, the component renders a visible "Secure session unavailable" error state instead of the iframe, so no camera or microphone permission is delegated and no token is sent, and it calls onError once.

Changelog

2.1.0

  • Add a theme prop ("light", "dark" or "system", default "system"). The resolved theme goes to the portal in procteye:init, and later changes in a new procteye:theme message, so the frame follows the host page's dark mode.
  • Add onStarting, fired on the portal's procteye:starting event when the candidate presses Start.
  • The iframe title is now "Procteye session".
  • Show the portal frame at full opacity as soon as it mounts. The white loading overlay, the opacity fade and the container's light background and transition are gone, so the host page shows through until the portal paints; the portal shows its own "Connecting…" state.
  • Document that sessionToken is the practice session token from POST /external/v1/practice-sessions, and that integrity sessions use @procteye/proctor-js or the desktop app instead.
  • An insecure portalUrl (plain http to a non-loopback host without allowInsecurePortal, http://localhost outside development/test builds, javascript: or malformed) now renders a visible error state and calls onError, instead of an empty iframe that still delegated camera and microphone access.

2.0.2

  • The default portalUrl is now https://procteye.com, the production portal that serves /sessions/embed. The previous default, https://assess.procteye.com, is not a Procteye host. To use a local portal, pass portalUrl explicitly.

2.0.1

  • The portal iframe now keeps its own origin (allow-same-origin added to the sandbox). Before this, the frame ran with Origin: null, its scripts failed CORS and the API refused its requests, so the embedded portal never loaded. allow-same-origin is still left out when portalUrl is on the host page's own origin.

Development

pnpm install --no-frozen-lockfile
pnpm run lint && pnpm run typecheck
timeout 600 pnpm test
pnpm run build

Repository rules: AGENTS.md. Releases: RELEASING.md.

Links

  • Documentation: https://docs.procteye.com
  • npm: https://www.npmjs.com/package/@procteye/sdk

License

MIT