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

@cyphlens/2fa-sse-sdk

v2.2.0

Published

Cyphlens SDK for 2FA SSE

Readme

Cyphlens SSE Client SDK 🚀

A lightweight JavaScript library designed to simplify 2FA authentication with Cyphlens' Server-Sent Events (SSE) integration.

This SDK is bundled using Rollup and supports ES Modules (ESM), CommonJS (CJS), and UMD (Universal Module Definition) formats for maximum compatibility across environments.


Features ✨

  • Easy integration with Cyphlens 2FA authentication
  • Real-time event listening via Server-Sent Events (SSE)
  • Lightweight and dependency-free
  • Cross-environment support (Node.js, browsers, and modern frameworks)

Installation 📦

Using NPM

Install the SDK via npm:

npm install @cyphlens/2fa-sse-sdk

Using Yarn

Install the SDK via Yarn:

yarn add @cyphlens/2fa-sse-sdk

Using CDN (Browser)

Include the SDK directly in your HTML:

<script src="https://cdn.jsdelivr.net/npm/@cyphlens/2fa-sse-sdk@2/dist/bundle.min.js"></script>

Usage 🔧

💡 Tip: Start with the Sandbox base URL for development and testing.

Importing the SDK

1. ES Modules (ESM) - Modern JavaScript

import { Cyphlens, EventType } from "@cyphlens/2fa-sse-sdk";

2. CommonJS (CJS) - Node.js

const { Cyphlens, EventType } = require("@cyphlens/2fa-sse-sdk");

3. Browser (IIFE)

After including the CDN script, the SDK is available as a global Cyphlens object:

const cyphlensClient = new Cyphlens("https://api.sandbox.cyphlens.com/b2b/v1");

Example: Listening to 2FA Events

1. Initialize the Client

const baseUrl = "https://api.sandbox.cyphlens.com/b2b/v1";  // Use the correct Cyphlens base URL
const sessionId = "your-session-id";                        // Replace with the current session ID
const cyphlensClient = new Cyphlens(baseUrl);               // Initialize the Cyphlens client

2. Listen for Events

// Define the callback for handling events
const onData = (eventType, data) => {
  if (eventType === EventType.MFASwipe) {
    const twoFactorEvent = data;
    console.log("2FA Status:", twoFactorEvent.status);
    // Handle status change (e.g., update UI or trigger logic)
  }
};
const onError = (error) => {
    console.error("SSE Error:", error);
    // Handle the error (e.g., retry connection, notify user)
};
// Start listening to events
cyphlensClient.listen(sessionId, onData, onError);

3. Stop Listening

// Stop the event listener when no longer needed 
cyphlensClient.stop();

API Reference 📚

new Cyphlens(baseUrl)

Creates a new instance of the Cyphlens client.

  • baseUrl: string — Cyphlens API base URL
    • Production: https://api.prod.cyphlens.com/b2b/v1
    • Sandbox: https://api.sandbox.cyphlens.com/b2b/v1

listen(sessionId, callback, errorCallback)

Starts listening for Server-Sent Events tied to the specified session.

  • sessionId: string - The session ID to listen for events
  • callback: (eventType: EventType, data: any) => void - Callback function to handle incoming events
  • errorCallback: (error: Event) => void - Callback function to handle errors (optional)

stop()

Stops the event listener and closes the connection.


Event Types

  • EventType.MFASwipe: Triggered when a 2FA swipe event occurs.
    • data: { status: string, ... } - Contains the event details, including the 2FA status.

Types

  • CyphlensErrorCallback: (error: Event) => void - Type definition for the error callback function.

Requirements ⚙️

  • Node.js: v14.x or higher (for CommonJS/ESM usage)
  • Browsers: Modern browsers with support for Server-Sent Events (SSE)

Contributing 🤝

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/YourFeature)
  3. Commit your changes (git commit -m "Add your feature")
  4. Push to the branch (git push origin feature/YourFeature)
  5. Open a Pull Request

Maintainers

If you're looking for docs on maintaining this package, head over to docs/

Note:

•	Ensure your local branch is up to date with origin/main (or your target branch) before tagging.
•	You can verify the tag using git tag.

License 📄

This project is licensed under the Cyphlens License. See the LICENSE file for details.