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

@scanupload/qr-code-generator-core

v0.1.8

Published

Framework-agnostic core for the ScanUpload QR Code Generator — SignalR session management, state, and types.

Downloads

149

Readme

@scanupload/qr-code-generator-core

Framework-agnostic runtime for the ScanUpload QR Code Generator. This package handles session creation, token refresh, SignalR connection management, upload state, and the typed primitives needed to build framework adapters.

What this package provides

  • QrCodeGeneratorCore runtime class
  • Typed backend contracts and UI state models
  • StorageAdapter abstraction for persistence
  • browserStorageAdapter for browser environments
  • Small utility and API helper exports

Installation

npm install @scanupload/qr-code-generator-core

Backend contract

Your backend must expose two endpoints:

| Endpoint | Method | Description | | ----------------- | ------ | --------------------------------------------------------------------------------------------- | | sessionUrl | POST | Creates a ScanUpload session and returns { sessionId, accessToken, hubUrl, deviceLoginUrl } | | refreshTokenUrl | POST | Returns a fresh Bearer token { access_token, expires_in } |

Basic usage

import {
  QrCodeGeneratorCore,
  browserStorageAdapter,
} from "@scanupload/qr-code-generator-core";

const core = new QrCodeGeneratorCore({
  sessionUrl: "/api/session",
  refreshTokenUrl: "/api/token",
  storage: browserStorageAdapter,
});

const unsubscribe = core.subscribe(() => {
  const state = core.getState();
  console.log(state.deviceLoginUrl, state.uploadedFiles);
});

await core.start();

// Later
await core.retrySession();

// Cleanup
unsubscribe();
core.dispose();

Public API

QrCodeGeneratorCoreOptions

| Field | Type | Required | Description | | ----------------- | ---------------- | -------- | ------------------------------------------------------------------ | | sessionUrl | string | Yes | Endpoint used to create a ScanUpload session. | | refreshTokenUrl | string | Yes | Endpoint used to fetch a fresh access token. | | storage | StorageAdapter | No | Optional storage implementation. Defaults to browser localStorage. |

QrCodeGeneratorState

interface QrCodeGeneratorState {
  loading: boolean;
  isConnected: boolean;
  retry: boolean;
  deviceLoginUrl: string;
  uploadedFiles: UploadedFile[];
}

UploadedFile

interface UploadedFile {
  id: string;
  name: string;
  size: number;
  type: string;
  progress: number;
  status: "added" | "uploading" | "success" | "error";
  error?: string;
  url?: string;
  thumbnailBase64?: string;
}

StorageAdapter

interface StorageAdapter {
  getItem<T = unknown>(key: string): T | undefined;
  setItem(key: string, value: unknown): void;
}

Building a custom adapter

Use this package when you want to integrate the QR workflow into another UI framework.

  1. Create a QrCodeGeneratorCore instance.
  2. Call start() when your component or widget initializes.
  3. Subscribe to state changes with subscribe().
  4. Read the current state with getState() and render your UI.
  5. Call retrySession() to refresh the QR code.
  6. Call dispose() during teardown.

Exports

This package exports:

  • QrCodeGeneratorCore
  • browserStorageAdapter
  • postData, deleteData, ApiError
  • isNullOrEmpty, debounce, debounceAsync, isExpired, truncateWithDots
  • SessionResponse, TokenResponse, UploadedFile, QrCodeGeneratorState
  • StorageAdapter, QrCodeGeneratorCoreOptions

License

MIT © Donald Asante