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

@regarde-dev/sdk

v1.0.0

Published

Regarde SDK for React and Preact with registration key logic

Readme

@regarde/sdk

SDK for building apps with Jazz registration key authentication. Provides framework-agnostic utilities, React/Preact hooks, and a verification API client.

Installation

pnpm add @regarde/sdk jazz-tools

For React users

pnpm add react

For Preact users

pnpm add preact

Features

  • Framework-agnostic auth utilities - Core registration key logic that works anywhere
  • React and Preact hooks - Easy integration with your UI framework
  • Verification API client - Call the central verification server
  • TypeScript support - Full type definitions included
  • Tree-shaking enabled - Only bundle what you use
  • Separate entry points - No cross-framework pollution

Usage

1. Auth Utilities (Framework-agnostic)

import {
  RegistrationKey,
  getRegistrationKey,
  isKeyExpired,
  generateRegistrationKey,
  KEY_LIFETIME_SECONDS
} from '@regarde/sdk/auth';

// Use the RegistrationKey schema in your Jazz account
const MyAccountRoot = co.map({
  'auth.myapp': RegistrationKey,
  // ... other fields
});

// Generate and store a registration key
const key = await getRegistrationKey({
  loadedRegistrationKeyCoMap: account.root['auth.myapp']
});

// Check if a key is expired
const expired = isKeyExpired(registrationKey);

// Generate a random key (used internally by getRegistrationKey)
const randomKey = generateRegistrationKey();

2. React Hook

import { useAccount } from 'jazz-tools/react';
import { useRegistrationKey } from '@regarde/sdk/react';

function MyComponent() {
  const { me } = useAccount();
  const registrationKey = me?.root?.['auth.myapp'];

  const {
    key,           // Current key value
    keyId,         // CoMap ID for API headers
    expiresAt,     // Expiry timestamp
    isExpired,     // Whether key has expired
    refresh,       // Function to regenerate key
    isLoading,     // Refresh in progress
    error          // Error message if any
  } = useRegistrationKey(registrationKey);

  // Use key in API calls
  useEffect(() => {
    if (key && keyId && !isExpired) {
      fetch('/api/register', {
        headers: {
          'X-Registration-Key': key,
          'X-Registration-Key-Id': keyId,
        }
      });
    }
  }, [key, keyId, isExpired]);

  return (
    <div>
      <button onClick={refresh} disabled={isLoading}>
        {isExpired ? 'Generate New Key' : 'Refresh Key'}
      </button>
      {error && <p>Error: {error}</p>}
    </div>
  );
}

3. Preact Hook

import { useAccount } from 'jazz-tools/preact';
import { useRegistrationKey } from '@regarde/sdk/preact';

function MyComponent() {
  const { me } = useAccount();
  const registrationKey = me?.root?.['auth.myapp'];

  const { key, keyId, refresh, isExpired } = useRegistrationKey(registrationKey);

  return (
    <div>
      <button onClick={refresh}>
        {isExpired ? 'Generate New Key' : 'Refresh Key'}
      </button>
    </div>
  );
}

4. Verification API Client

import { verifyRegistrationKeyViaServer } from '@regarde/sdk/verify';

// Call the central verification server
const result = await verifyRegistrationKeyViaServer({
  baseUrl: 'https://api.regarde.bio',
  jazzAccountId: 'account-123',
  registrationKey: 'abc123...',
  registrationKeyId: 'co_xyz...',
  apiKey: 'your-api-key',
  signal: abortController.signal, // Optional
});

if (result.isValid) {
  console.log('User authenticated successfully');
} else {
  console.error('Authentication failed:', result.error);
}

API Reference

Auth Module (@regarde/sdk/auth)

RegistrationKey

Jazz CoMap schema for registration keys.

const RegistrationKey = co.map({
  key: z.string(),
  expiresAt: z.number(),
});

getRegistrationKey(params)

Generates a new registration key and stores it in the provided CoMap.

Parameters:

  • loadedRegistrationKeyCoMap: Loaded<typeof RegistrationKey> - The loaded RegistrationKey CoMap

Returns: Promise<string | null> - The generated key, or null on error

isKeyExpired(registrationKey)

Checks if a registration key has expired.

Parameters:

  • registrationKey: any - Object with expiresAt property

Returns: boolean - True if expired or invalid

generateRegistrationKey()

Generates a random 16-character registration key.

Returns: string - The generated key

KEY_LIFETIME_SECONDS

Constant for key lifetime (24 hours = 86400 seconds).

React/Preact Hooks

useRegistrationKey(registrationKeyCoMap)

Parameters:

  • registrationKeyCoMap: Loaded<typeof RegistrationKey> | null | undefined - The loaded RegistrationKey CoMap

Returns: UseRegistrationKeyResult

{
  key: string | null;
  keyId: string | null;
  expiresAt: number | null;
  isExpired: boolean;
  refresh: () => Promise<void>;
  isLoading: boolean;
  error: string | null;
}

Verify Module (@regarde/sdk/verify)

verifyRegistrationKeyViaServer(params)

Parameters:

{
  baseUrl: string;              // e.g., 'https://api.regarde.bio'
  jazzAccountId: string;        // User's Jazz account ID
  registrationKey: string;      // The key value
  registrationKeyId: string;    // CoMap ID
  apiKey: string;               // API key for accessing the verify endpoint
  signal?: AbortSignal;         // Optional abort signal
}

Returns: Promise<VerificationResult>

{
  isValid: boolean;
  error?: string;
}

Development

# Build the package
pnpm build

# Watch mode
pnpm dev

# Run tests
pnpm test

License

ISC