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

@wecom/wecom-aibot-sdk

v0.1.0

Published

企业微信 AI Bot 授权 SDK

Readme

@wecom/wecom-aibot-sdk

企业微信 AI Bot 授权 SDK —— 通过弹窗扫码快速创建企业微信 AI 机器人。

特性

  • 🪟 弹窗授权 — 基于 Popup Window + PostMessage,无需页面跳转
  • 🔒 安全通信 — Origin 校验 + State 防 CSRF,防止跨站攻击
  • 📦 多格式输出 — 同时提供 UMD / ESM / CJS,适配各种使用场景
  • 🏷️ TypeScript — 完整的类型定义,开箱即用
  • 🪶 零依赖 — 无任何第三方运行时依赖

安装

# npm
npm install @wecom/wecom-aibot-sdk

# yarn
yarn add @wecom/wecom-aibot-sdk

或通过 CDN 引入:

<script src="https://cdn.your-domain.com/wecom-aibot-sdk.umd.min.js"></script>

快速开始

模块化引入

import WecomAIBotSDK from '@wecom/wecom-aibot-sdk';

const bot = await WecomAIBotSDK.openBotInfoAuthWindow({
    source: 'your-source-id',
    onCreated: (bot) => {
        console.log('机器人创建成功:', bot.botid, bot.secret);
    },
    onError: (error) => {
        console.error('创建失败:', error.message);
    }
});
console.log('机器人创建成功:', bot.botid, bot.secret);

通过 <script> 标签引入

<script src="https://cdn.your-domain.com/wecom-aibot-sdk.umd.min.js"></script>
<script>
  document.getElementById('createBotBtn').addEventListener('click', () => {
    WecomAIBotSDK.openBotInfoAuthWindow({
      source: 'your-source-id',
      onCreated: (bot) => {
        console.log('机器人创建成功:', bot.botid, bot.secret);
      },
      onError: (error) => {
        console.error('创建失败:', error.message);
      }
    });
  });
</script>

API

openBotInfoAuthWindow(options)

打开机器人信息授权窗口,返回 Promise<BotInfo>

参数:

| 参数 | 类型 | 必填 | 说明 | |------|------|:----:|------| | source | string | ✅ | 来源标识 | | debug | boolean | | 开启调试日志,默认 false | | onCreated | (bot: BotInfo) => void | | 机器人创建成功回调 | | onError | (error: AuthError) => void | | 创建失败回调 |

返回值:

interface BotInfo {
  botid: string;   // 机器人 ID
  secret: string;  // 机器人密钥
}

closeWindow()

手动关闭授权弹窗。

destroy()

销毁 SDK 实例,释放所有资源(关闭窗口、移除事件监听)。

错误码

| 错误码 | 说明 | |--------|------| | WINDOW_BLOCKED | 弹窗被浏览器拦截,需用户允许弹窗 | | INVALID_APP_ID | 无效的应用标识 | | ACCESS_DENIED | 用户拒绝授权 | | AUTH_TIMEOUT | 授权超时 | | CANCELLED | 用户取消授权 |

浏览器兼容性

支持所有现代浏览器:

| Chrome | Firefox | Safari | Edge | |:------:|:-------:|:------:|:----:| | ✅ | ✅ | ✅ | ✅ |

开发

# 安装依赖
yarn install

# 构建
yarn build

# 运行测试
yarn test

# 测试覆盖率
yarn test:coverage