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.2.1

Published

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

Downloads

82

Readme

@scanupload/qr-code-generator-core

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

Install

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

Backend contract

The browser calls one endpoint directly — the hub authenticates from the browser's Origin header, so no token is required.

| Endpoint | Method | Description | | ------------ | ------ | ------------------------------------------------------------------------------------------ | | sessionUrl | POST | Creates a ScanUpload session. Returns { sessionId, deviceLoginUrl, hubUrl, ttlSeconds }. |

Quick start

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

const core = new QrCodeGeneratorCore({
    sessionUrl: '/api/front-end/session',
    clientId: 'your-tenant-id', // optional
    storage: browserStorageAdapter // optional, defaults to localStorage
});

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

await core.start();

// Update at runtime — the core reconnects automatically
await core.setOptions({ sessionUrl: '/api/new-session' });

// Tear down
unsubscribe();
core.dispose();

API

new QrCodeGeneratorCore(options)

| Field | Type | Required | Description | | --------------- | ---------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | | sessionUrl | string | Yes | Endpoint that creates a ScanUpload session. | | clientId | string | No | Optional tenant / Keycloak client_id sent in the request body. | | storage | StorageAdapter | No | Defaults to localStorage via browserStorageAdapter. | | autoResession | boolean | true | Automatically create a fresh session at TTL expiry. Framework UI wrappers default this to false so their disconnected state and Reload action remain visible. |

State

interface QrCodeGeneratorState {
    loading: boolean; // true while the session is being created
    isConnected: boolean; // SignalR connection status
    retry: boolean; // true when the last session create failed
    deviceLoginUrl: string; // URL encoded into the QR code
    uploadedFiles: UploadedFile[];
    expiresAt: number | null; // absolute expiry (ms since epoch)
    secondsRemaining: number | null;
    errorCode: number | null; // 409 (tenant limit) / 429 (rate limit) / null
    sessionId: string | null; // active session id
}

UploadedFile

interface UploadedFile {
    id: string;
    name: string;
    size: number;
    type: string;
    progress: number;
    status: 'added' | 'uploading' | 'success' | 'error';
    error?: string;
    url?: string; // signed download URL — used by DownloadButton
    thumbnailBase64?: string;
}

Methods

  • start() — create the session and open the SignalR connection
  • setOptions({ sessionUrl?, clientId? }) — update at runtime; reconnects automatically
  • retrySession() — tear down the current session and create a new one
  • getState() / subscribe(listener) — reactive state
  • dispose() — clean up

Exports

  • QrCodeGeneratorCore
  • browserStorageAdapter
  • triggerBrowserDownload(blob, filename) — browser-only DOM helper
  • postData, deleteData, ApiError
  • isNullOrEmpty, debounce, debounceAsync, isExpired, truncateWithDots
  • SessionResponse, UploadedFile, QrCodeGeneratorState
  • StorageAdapter, QrCodeGeneratorCoreOptions, QrCodeGeneratorCoreSetOptions

License

MIT © Donald Asante