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

@shanjing-inc/wechat-node-sdk

v0.2.0

Published

Modern TypeScript SDK for WeChat server-side APIs.

Readme

@shanjing-inc/wechat-node-sdk

现代 TypeScript 微信服务端 SDK。当前覆盖 coremini-appofficial-accountpayworkopen-platformopen-workchannel 的基础能力。

特性

  • ESM first,支持 npm 子路径导出
  • 原生 fetch HTTP 客户端
  • Web Crypto 优先,Node crypto 通过 @shanjing-inc/wechat-node-sdk/adapters/node 引入
  • CacheStore 抽象,内置内存缓存
  • zod 配置校验
  • fast-xml-parser XML 解析和构建
  • vitest 测试,tsup 构建

安装

pnpm add @shanjing-inc/wechat-node-sdk

小程序

import { createMiniAppClient } from '@shanjing-inc/wechat-node-sdk/mini-app';

const miniApp = createMiniAppClient({
  appId: process.env.WECHAT_APP_ID!,
  appSecret: process.env.WECHAT_APP_SECRET!
});

const session = await miniApp.code2Session('js_code');

公众号

import { createOfficialAccountClient } from '@shanjing-inc/wechat-node-sdk/official-account';

const officialAccount = createOfficialAccountClient({
  appId: process.env.WECHAT_APP_ID!,
  appSecret: process.env.WECHAT_APP_SECRET!
});

const user = await officialAccount.getUserInfo('openid');

微信支付 API v3

import { createPayClient } from '@shanjing-inc/wechat-node-sdk/pay';
import { createNodeCryptoAdapter } from '@shanjing-inc/wechat-node-sdk/adapters/node';

const pay = createPayClient({
  appId: process.env.WECHAT_APP_ID!,
  mchId: process.env.WECHAT_MCH_ID!,
  serialNo: process.env.WECHAT_PAY_SERIAL_NO!,
  privateKey: process.env.WECHAT_PAY_PRIVATE_KEY!,
  apiV3Key: process.env.WECHAT_PAY_API_V3_KEY!,
  crypto: createNodeCryptoAdapter()
});

const transaction = await pay.transactionsJsapi({
  openid: 'openid',
  description: '测试订单',
  outTradeNo: 'order-1',
  notifyUrl: 'https://example.com/pay/notify',
  amount: { total: 1 },
  settleInfo: { profitSharing: true }
});

const jsapiParams = await pay.createJsapiPaySign(transaction.prepay_id, process.env.WECHAT_APP_ID!);

const partnerTransaction = await pay.transactionsJsapi({
  openid: 'sub-openid',
  description: '服务商测试订单',
  outTradeNo: 'partner-order-1',
  notifyUrl: 'https://example.com/pay/partner-notify',
  amount: { total: 1 },
  subAppId: process.env.WECHAT_SUB_APP_ID!,
  subMchId: process.env.WECHAT_SUB_MCH_ID!
});

const partnerJsapiParams = await pay.createJsapiPaySign(
  partnerTransaction.prepay_id,
  process.env.WECHAT_SUB_APP_ID!
);

企业微信

import { createWorkClient } from '@shanjing-inc/wechat-node-sdk/work';

const work = createWorkClient({
  corpId: process.env.WECHAT_WORK_CORP_ID!,
  corpSecret: process.env.WECHAT_WORK_CORP_SECRET!
});

await work.sendMessage({
  touser: 'userid',
  msgtype: 'text',
  agentid: 1000001,
  text: { content: 'hello' }
});

微信开放平台

import { createOpenPlatformClient } from '@shanjing-inc/wechat-node-sdk/open-platform';

const openPlatform = createOpenPlatformClient({
  appId: process.env.WECHAT_OPEN_APP_ID!,
  appSecret: process.env.WECHAT_OPEN_APP_SECRET!,
  componentVerifyTicket: async () => loadComponentVerifyTicket()
});

const preAuthCode = await openPlatform.createPreAuthCode();

企业微信开放平台

import { createOpenWorkClient } from '@shanjing-inc/wechat-node-sdk/open-work';

const openWork = createOpenWorkClient({
  suiteId: process.env.WECHAT_WORK_SUITE_ID!,
  suiteSecret: process.env.WECHAT_WORK_SUITE_SECRET!,
  suiteTicket: async () => loadSuiteTicket()
});

const preAuthCode = await openWork.getPreAuthCode();

视频号

import { createChannelClient } from '@shanjing-inc/wechat-node-sdk/channel';

const channel = createChannelClient({
  appId: process.env.WECHAT_APP_ID!,
  appSecret: process.env.WECHAT_APP_SECRET!
});

const info = await channel.getBasicsInfo();

开发

pnpm install
pnpm typecheck
pnpm test
pnpm build

设计说明见 docs/architecture.md