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

@yaebal/file-id

v0.0.1

Published

yaebal file-id — parse, inspect and re-serialize telegram file_id / file_unique_id strings. zero deps, runtime-agnostic.

Readme

@yaebal/file-id

parse, inspect and re-serialize telegram file_id and file_unique_id strings.

a file_id isn't opaque — it's a TL-serialized TDLib blob (behind zero-byte RLE and url-safe base64) carrying the file's datacenter, type, access hash, file reference and photo-size source. this package decodes it. zero dependencies, pure js, runs anywhere (node/bun/deno/edge) — no Buffer, no telegram client.

install

pnpm add @yaebal/file-id

usage

import { FileId, FileType, isPhotoFileId } from "@yaebal/file-id";

const file = FileId.from(ctx.document.file_id);

file.kind          // "photo" | "document" | "web"
file.fileType      // FileType.Sticker, FileType.Video, …
file.dcId          // 1..5 — which telegram datacenter stores the file
file.accessHash    // bigint
file.hasReference  // carries a fresh file_reference?

if (file.fileType === FileType.Sticker) {
	// …
}

// full discriminated union for narrowing
if (isPhotoFileId(file.raw)) {
	file.raw.photoSize; // legacy | thumbnail | dialog_photo_* | sticker_set_thumbnail*
}

file.toString(); // re-serializes — round-trips the original string byte-for-byte

dedupe with file_unique_id

file_id is bot-scoped and may rotate; file_unique_id is the stable identity. it's derivable from the full id:

const unique = FileId.from(a).toUniqueId();
const same = unique.toString() === FileId.from(b).toUniqueId().toString();

or parse one you already have:

import { FileUniqueId } from "@yaebal/file-id";

const unique = FileUniqueId.from(msg.document.file_unique_id);
unique.kind; // "photo" | "document" | "web" | "secure" | "encrypted" | "temp"

functional api

every class entry point exists as a free function: parseFileId / serializeFileId / fileUniqueIdFromFileId / parseFileUniqueId / serializeFileUniqueId. the encoding primitives (base64urlEncode/Decode, rleEncode/Decode, packTlString/unpackTlString, BinaryReader/BinaryWriter) are exported too.

errors

  • FileIdParseError — malformed input (bad base64url, truncated payload, unknown tags).
  • UnsupportedFileIdVersionError — telegram bumped the format past what this parser knows. open an issue when you hit it.

part of yaebal — a type-safe, runtime-agnostic Telegram Bot API framework. MIT.