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

@divinevideo/login

v1.1.0

Published

TypeScript/JavaScript OAuth client for Divine authentication and Nostr signing via REST RPC

Readme

@divinevideo/login

TypeScript/JavaScript OAuth client for Divine authentication and Nostr signing via REST RPC.

Install

npm install @divinevideo/login

Quick Start

import { createDivineClient } from '@divinevideo/login';

const client = createDivineClient({
  serverUrl: 'https://login.divine.video',
  clientId: 'my-app',
  redirectUri: window.location.origin + '/callback',
  storage: localStorage, // persist sessions across page reloads
});

// Start OAuth flow
const { url } = await client.oauth.getAuthorizationUrl();
window.location.href = url;

// After redirect back, exchange code for tokens
const params = new URLSearchParams(window.location.search);
const code = params.get('code');
const tokens = await client.oauth.exchangeCode(code);

// Use RPC client for Nostr signing
const rpc = client.createRpc(tokens);
const pubkey = await rpc.getPublicKey();
const signed = await rpc.signEvent({
  kind: 1,
  content: 'Hello from Divine!',
  tags: [],
  created_at: Math.floor(Date.now() / 1000),
  pubkey,
});

Features

  • OAuth 2.0 + PKCE — Secure authorization flow with automatic PKCE handling
  • REST RPC signing — Low-latency alternative to NIP-46 relay-based signing
  • Session management — Automatic token storage, refresh, and silent re-authentication
  • BYOK (Bring Your Own Key) — Import existing nsec keys
  • Storage abstraction — Works with localStorage, sessionStorage, or custom backends
  • Tree-shakeable — ESM, CJS, and IIFE (browser global) builds

API

createDivineClient(config)

Creates a client with OAuth and RPC capabilities.

const client = createDivineClient({
  serverUrl: string;     // e.g., "https://login.divine.video"
  clientId: string;      // Your app's OAuth client ID
  redirectUri: string;   // OAuth callback URL
  storage?: Storage;     // Optional storage backend (default: in-memory)
  fetch?: typeof fetch;  // Optional custom fetch
});

client.oauth

  • getAuthorizationUrl(options?) — Generate OAuth URL with PKCE
  • exchangeCode(code, verifier?) — Exchange auth code for tokens
  • parseCallback(url) — Extract code from callback URL
  • getSession() — Get stored credentials (sync)
  • getSessionWithRefresh() — Get credentials with auto-refresh
  • logout() — Clear all session data
  • refreshSession(refreshToken) — Manually refresh tokens

client.createRpc(tokens)

Creates a Nostr RPC client (mirrors NIP-46 methods):

  • getPublicKey() — Get user's hex pubkey
  • signEvent(event) — Sign an unsigned Nostr event
  • nip44Encrypt(pubkey, plaintext) / nip44Decrypt(pubkey, ciphertext)
  • nip04Encrypt(pubkey, plaintext) / nip04Decrypt(pubkey, ciphertext)

BYOK (Bring Your Own Key)

const { url } = await client.oauth.getAuthorizationUrl({
  nsec: 'nsec1...', // User's existing key (pubkey derived automatically)
  defaultRegister: true,
});

Migration from keycast-login

This package is the successor to keycast-login. Backward-compatible aliases are provided:

// Old (still works)
import { createKeycastClient, KeycastOAuth, KeycastRpc } from '@divinevideo/login';

// New (preferred)
import { createDivineClient, DivineOAuth, DivineRpc } from '@divinevideo/login';

Storage keys changed from keycast_* to divine_*. Existing sessions will need to re-authenticate.

License

MIT