Skip to content

weixin-ts / cdn/src

cdn/src

@weixin-ts/cdn — WeChat CDN upload/download with AES-ECB encryption

Cross-platform CDN media handling using WebCrypto API. Works in Node.js 18+, Deno, Bun, and modern browsers.

Example

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

// Upload media
const result = await uploadMedia({
  file: imageBuffer,
  toUserId: 'user_id',
  mediaType: 'image',
  apiOptions: { baseUrl: '...', token: '...' },
  cdnBaseUrl: '...',
})

// Download media
const data = await downloadMedia({ media: msg.image_item.media })

Interfaces

Functions

Released under the MIT License.