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

@weixin-ts/cdn

v0.1.0

Published

WeChat CDN upload/download with AES-ECB encryption (cross-platform WebCrypto)

Downloads

269

Readme

@weixin-ts/cdn

WeChat CDN upload/download with AES-128-ECB encryption. Cross-platform using WebCrypto API.

Disclaimer: This project is an unofficial SDK for the WeChat iLink Bot API. It is not affiliated with, endorsed by, or supported by Tencent or WeChat. Use it at your own risk and ensure compliance with applicable terms of service.

Features

  • AES-128-ECB: Encrypt/decrypt using WebCrypto (no node:crypto dependency)
  • Upload pipeline: Full flow from file → hash → encrypt → CDN upload
  • Download + decrypt: Fetch and decrypt media from WeChat CDN
  • Cross-platform: Works in Node.js 18+, Deno, Bun, and browsers
  • Zero dependencies: Pure Web standard APIs

Install

pnpm add @weixin-ts/cdn

Usage

Upload Media

import { uploadMedia } from '@weixin-ts/cdn'

const result = await uploadMedia({
  file: imageBuffer, // Uint8Array or ArrayBuffer
  toUserId: 'recipient_user_id',
  mediaType: 'image', // 'image' | 'video' | 'file' | 'voice'
  apiOptions: {
    baseUrl: 'https://ilinkai.weixin.qq.com',
    token: 'YOUR_BOT_TOKEN',
  },
  cdnBaseUrl: 'https://novac2c.cdn.weixin.qq.com/c2c',
})

// Use result.downloadParam in message construction
console.log(result.filekey, result.aesKeyHex)

Download Media

import { downloadMedia } from '@weixin-ts/cdn'

// From an incoming message
const decrypted = await downloadMedia({
  media: message.item_list[0].image_item.media,
  aesKeyHex: message.item_list[0].image_item.aeskey,
})

Low-level AES-ECB

import { decryptAesEcb, encryptAesEcb } from '@weixin-ts/cdn'

const key = crypto.getRandomValues(new Uint8Array(16))
const encrypted = await encryptAesEcb(data, key)
const decrypted = await decryptAesEcb(encrypted, key)

API

uploadMedia(options)UploadedMedia

Full upload pipeline: hash → encrypt → request URL → upload to CDN.

downloadMedia(options)Uint8Array

Download and decrypt a media file from CDN.

encryptAesEcb(plaintext, key)Uint8Array

Encrypt data using AES-128-ECB with PKCS7 padding.

decryptAesEcb(ciphertext, key)Uint8Array

Decrypt AES-128-ECB encrypted data, removing PKCS7 padding.

Utilities

  • aesEcbPaddedSize(rawSize) — Calculate ciphertext size
  • md5Hex(data) — Compute MD5 hash (hex string)
  • randomBytes(length) — Cryptographic random bytes
  • toHex(bytes) / fromHex(hex) — Hex conversion
  • toBase64(bytes) / fromBase64(str) — Base64 conversion

Related Packages

License

MIT