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

@dmaximyuk/signature

v1.0.15

Published

Quick signature for Telegram and VKontakte

Downloads

30

Readme

@dmaximyuk/signature

Library for working with Telegram and VKontakte signatures: encode raw init/launch data into a compact string and verify signatures on the backend. Compatible with Bun.js, Node.js, and the browser.

Installation

npm install @dmaximyuk/signature
# or
bun add @dmaximyuk/signature

Usage

Telegram

Frontend (or any source): turn raw initData (query string) into a compact string to send to the backend.

import { telegramEncode, telegramDecode, type TelegramDecodeResult } from '@dmaximyuk/signature';

const rawInitData = new URLSearchParams(window.Telegram?.WebApp?.initData || '').toString();
const encoded = telegramEncode(rawInitData);

Backend: verify signature and extract user data.

const validator = telegramDecode({ token: process.env.TG_BOT_TOKEN });
const result = validator(encoded);
if (result) {
  console.log(result.userId, result.user);
}

VKontakte

Frontend: turn raw launch params (query string with sign) into a compact string.

import { vkontakteEncode, vkontakteDecode, type VKontakteDecodeResult } from '@dmaximyuk/signature';

const rawLaunchParams = window.location.search.slice(1);
const encoded = vkontakteEncode(rawLaunchParams);

Backend: verify signature and extract data.

const validator = vkontakteDecode({ token: process.env.VK_APP_TOKEN });
const result = validator(encoded);
if (result) {
  console.log(result.userId, result.params);
}

Types

Telegram

interface TelegramUser {
  id: number;
  first_name: string;
  last_name?: string;
  username?: string;
  language_code?: string;
  is_premium?: boolean;
  allows_write_to_pm?: boolean;
  photo_url?: string;
}

interface TelegramDecodeResult {
  userId: number;
  authDate: number;
  queryId: string;
  user: TelegramUser;
}

interface TelegramDecodeOptions {
  token: string;
  maxAge?: number;
}

VKontakte

interface VKontakteUser {
  vk_user_id: number;
  vk_app_id: number;
  vk_ts: number;
  vk_is_app_user: number;
  vk_are_notifications_enabled: number;
  vk_is_favorite: number;
  vk_language: string;
  vk_platform: string;
  vk_ref: string;
}

interface VKontakteDecodeResult {
  userId: number;
  ts: number;
  params: VKontakteUser;
}

interface VKontakteDecodeOptions {
  token: string;
  maxAge?: number;
}

Tests

Requires a .env file with (see .env.example):

  • Telegram: TG_BOT_TOKEN, TG_RAW_SECRET
  • VKontakte: VK_APP_TOKEN, VK_RAW_SECRET (VK tests are skipped if not set)
bun run test

Tests cover: valid signature from encode, full data from decode, rejection of invalid/tampered signatures and wrong token, plus encode/decode benchmarks.

Benchmarks

Telegram (Apple M4 Pro, 48 GB, bun test):

| Operation | Total | Per op | Throughput | n | |-----------|---------|----------|--------------|--------| | encode | 30.76ms | 0.0031ms | 325 125 ops/s | 10 000 | | decode | 119.42ms| 0.0012ms | 837 367 ops/s | 100 000 |

Compatibility

  • Node.js — full support (decode uses node:crypto)
  • Bun.js — full support
  • Browser — encode only; no signature verification (decode requires Node/Bun for HMAC)