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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@duc1607/bb10-picture-auth

v1.0.1

Published

BlackBerry 10 style picture password authentication component for React

Downloads

7

Readme

BB10 Picture Auth

A React component that replicates the BlackBerry 10 picture password authentication interface.

Installation

npm install @duc1607/bb10-picture-auth

Usage

import { useEffect, useState } from "react";
import PictureAuth from "@duc1607/bb10-picture-auth";
import { type SetupMode, type UserSetup } from "@duc1607/bb10-picture-auth";

export default function App() {
  const [userSetup, setUserSetup] = useState<UserSetup | null>(null);
  const [mode, setMode] = useState<SetupMode>("setup");
  const [setupStep, setSetupStep] = useState<
    null | "image" | "number" | "position" | "test" | "finish"
  >(null);
  const [pictureDataUrl, setPictureDataUrl] = useState<string | null>(null);

  const SIZE = 300;

  // Handle picture upload
  const handlePictureUpload = (event: React.ChangeEvent<HTMLInputElement>) => {
    if (!event.target.files || event.target.files.length === 0) return;

    const file = event.target.files?.[0];
    if (file && file.type.startsWith("image/")) {
      const reader = new FileReader();
      reader.onload = (e) => {
        const dataUrl = e.target?.result as string;
        setPictureDataUrl(dataUrl);

        setUserSetup((prevSetup) => {
          if (!prevSetup || prevSetup.chosenNumber === undefined) {
            return prevSetup;
          }
          return {
            ...prevSetup,
            pictureDataUrl: dataUrl || undefined,
          };
        });
      };
      reader.readAsDataURL(file);
    }
  };

  useEffect(() => {
    // Initialize user setup if not already set
    if (!userSetup) {
      setSetupStep("number");
    }
  }, [userSetup]);

  return (
    <div className="App">
      {mode === "auth" && (
        <PictureAuth
          userSetup={userSetup}
          mode={mode}
          onSuccess={() => console.log("Authentication successful!")}
          onFailure={() => console.log("Authentication failed!")}
          canvasWidth={SIZE}
          canvasHeight={SIZE}
        />
      )}

      {mode !== "auth" && (
        <div>
          <h1>Welcome to the Picture Password Setup</h1>
          {setupStep === "number" && (
            <div>
              <h2>Choose a Number</h2>
              <select
                onChange={(e) =>
                  setUserSetup({ chosenNumber: parseInt(e.target.value, 10) })
                }
              >
                <option value="">Select a number</option>
                {[0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map((num) => (
                  <option key={num} value={num}>
                    {num}
                  </option>
                ))}
              </select>
              <button onClick={() => setSetupStep("image")}>Next</button>
            </div>
          )}
          {setupStep === "image" && (
            <div>
              <h2>Upload Your Picture</h2>
              <input
                type="file"
                accept="image/*"
                onChange={handlePictureUpload}
              />
              {pictureDataUrl && (
                <img
                  src={pictureDataUrl}
                  alt="Uploaded"
                  style={{ maxWidth: "200px" }}
                />
              )}
              <button onClick={() => setSetupStep("position")}>Next</button>
            </div>
          )}
          {(setupStep === "position" || setupStep === "test") && (
            <div>
              {setupStep === "position" ? (
                <h2>Click on the Picture to Set Position</h2>
              ) : (
                <h2>Test Your Setup</h2>
              )}
              <PictureAuth
                userSetup={userSetup}
                setUserSetup={setUserSetup}
                mode={mode}
                onSuccess={() => {
                  setSetupStep("finish");
                }}
                canvasWidth={SIZE}
                canvasHeight={SIZE}
              />
              {setupStep === "position" && (
                <button
                  onClick={() => {
                    setSetupStep("test");
                    setMode("auth-test");
                  }}
                >
                  Next
                </button>
              )}
            </div>
          )}
          {setupStep === "finish" && (
            <div>
              <h2>Setup Complete</h2>
              <p>Your picture password is ready to use!</p>
              <pre>{JSON.stringify(userSetup, null, 2)}</pre>
              <button onClick={() => setMode("auth")}>
                Start Authentication
              </button>
            </div>
          )}
        </div>
      )}
    </div>
  );
}

Features

  • Authentic BB10 Design: Faithful recreation of the BlackBerry 10 picture password interface
  • Canvas Rendering: High-performance matrix rendering with smooth animations
  • Touch/Mouse Support: Works with both touch and mouse interactions
  • TypeScript Support: Full TypeScript definitions included
  • Fade Animation: Visual feedback with fade effects during interaction
  • Secure Authentication: Position-based password verification

Development

This component is built with:

  • React 19+
  • TypeScript
  • HTML5 Canvas API
  • Vite (for building)

License

MIT