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

@kastov/cryptohapp

v1.1.2

Published

A library for creating Happ crypto deep links.

Readme

@kastov/cryptohapp

A lightweight library for creating Happ crypto deep links. Works on both Node.js (backend) and browser (frontend) environments.

Features

  • 🖥️ Backend: Uses native Node.js crypto module (zero dependencies)
  • 🌐 Frontend: Uses lightweight jsencrypt library (~30KB)
  • 📦 Supports multiple crypto versions (v2, v3, v4)

Installation

Backend (Node.js):

npm i @kastov/cryptohapp

Frontend (Browser):

npm i @kastov/cryptohapp jsencrypt

Usage

Get Full Link (string)

import { createHappCryptoLink } from '@kastov/cryptohapp';

const link = createHappCryptoLink('https://subscription.link.com/s/remnawavetop', 'v4', true);
// Returns: 'happ://crypt4/base64encodeddata...'

if (link) {
  console.log(link); // 'happ://crypt4/base64encodeddata...'
}

Get Separate Parts (object)

import { createHappCryptoLink } from '@kastov/cryptohapp';

const result = createHappCryptoLink('https://subscription.link.com/s/remnawavetop', 'v4');

if (result) {
  console.log(result.deepLink); // 'happ://crypt4/'
  console.log(result.encryptedContent); // 'base64encodeddata...'
}

Error Handling

import { createHappCryptoLink } from '@kastov/cryptohapp';

const result = createHappCryptoLink('https://example.com/subscription', 'v4');

if (result === null) {
  console.error('Encryption failed');
} else {
  console.log('Success:', result.deepLink + result.encryptedContent);
}

React Example

import { useState } from 'react';
import { createHappCryptoLink } from '@kastov/cryptohapp';

function CryptoLinkGenerator() {
  const [link, setLink] = useState('');

  const generateLink = () => {
    const cryptoLink = createHappCryptoLink(
      'https://subscription.link.com/s/remnawavetop',
      'v4',
      true,
    );

    if (cryptoLink) {
      setLink(cryptoLink);
    }
  };

  return (
    <div>
      <button onClick={generateLink}>Generate Crypto Link</button>
      {link && <a href={link}>Open in Happ</a>}
    </div>
  );
}

NestJS Example

import { Injectable } from '@nestjs/common';
import { createHappCryptoLink } from '@kastov/cryptohapp';

@Injectable()
export class HappService {
  generateCryptoLink(subscriptionUrl: string): string | null {
    return createHappCryptoLink(subscriptionUrl, 'v4', true);
  }
}

API Reference

createHappCryptoLink(content, version, asLink?)

Creates an encrypted Happ deep link.

Parameters

| Parameter | Type | Default | Description | | --------- | ---------------------- | ------- | ----------------------------------------------- | | content | string | — | The content to encrypt (e.g., subscription URL) | | version | 'v2' \| 'v3' \| 'v4' | — | Crypto version to use (required) | | asLink | boolean | false | When true, returns full link string |

Returns

When asLink is true: string | null

const link = createHappCryptoLink(content, 'v4', true);
// Returns: 'happ://crypt4/base64encodeddata...' or null

When asLink is false or omitted: HappCryptoResult | null

interface HappCryptoResult {
  /** Deep link prefix (e.g., 'happ://crypt4/') */
  deepLink: string;
  /** Base64 encoded encrypted content */
  encryptedContent: string;
}

Returns null if encryption fails.

Exported Constants

You can also access the public keys directly:

import { HAPP_CRYPTO_V2, HAPP_CRYPTO_V3, HAPP_CRYPTO_V4 } from '@kastov/cryptohapp';

console.log(HAPP_CRYPTO_V4.publicKey); // RSA public key
console.log(HAPP_CRYPTO_V4.deepLink); // 'happ://crypt4/'

How It Works

The library uses RSA encryption with PKCS1 padding to encrypt your content:

  • Backend: Uses Node.js native crypto.publicEncrypt()
  • Frontend: Uses jsencrypt library for browser compatibility

Both implementations produce identical encrypted output, ensuring cross-platform compatibility.

Content Size Limits

RSA with PKCS1 padding can encrypt data up to (keySize / 8) - 11 bytes. For a 4096-bit key, this is approximately 501 bytes. If your content exceeds this limit, consider using a URL shortener or compression.

Reference

License

MIT