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

@feihan-im/sdk

v0.28.108

Published

飞函官方 OpenAPI SDK,支持 Node.js 和 Browser

Readme

飞函 IM OpenAPI SDK - JavaScript

npm version CI npm downloads TypeScript License

English | 中文

飞函,是安全稳定的私有化一站式办公平台,功能包括即时通讯、组织架构、音视频会议、网盘等。

本项目是飞函服务端的 JavaScript SDK,用于通过 OpenAPI 与飞函服务端进行交互。使用前需要先自行部署飞函服务端,部署教程请参考快速部署文档

安装

npm install @feihan-im/sdk

WebSocket 功能在浏览器和 Node.js 22+ 中原生支持。Node.js < 22 需安装 ws

npm install ws

快速开始

import { FeihanClient, MessageType_TEXT } from '@feihan-im/sdk';

const client = await FeihanClient.create(
  'https://your-backend-url.com',
  'your-app-id',
  'your-app-secret',
);

// 可选:预热可提前获取访问凭证和同步服务端时间,减少首次调用的延迟
await client.preheat();

// 调用 API
const resp = await client.Im.Message.sendMessage({
  chat_id: 'chat-id',
  message_type: MessageType_TEXT,
  message_content: { text: { content: '飞函新版本发布!' } },
});
console.log(resp);

// 使用完毕后关闭
await client.close();

客户端配置

FeihanClient.create() 支持通过可选参数配置客户端行为:

import { FeihanClient, LoggerLevel } from '@feihan-im/sdk';

const client = await FeihanClient.create(
  'https://your-backend-url.com',
  'your-app-id',
  'your-app-secret',
  {
    logLevel: LoggerLevel.Debug,         // 日志级别(默认: Info)
    requestTimeout: 30_000,              // 请求超时毫秒数(默认: 60000)
    enableEncryption: false,             // 启用请求加密(默认: true)
  },
);

事件订阅

通过 WebSocket 接收实时事件推送:

// 注册事件处理函数
const handlerId = client.Im.Message.Event.onMessageReceive((event) => {
  console.log('收到消息:', event);
});

// 取消订阅
client.Im.Message.Event.offMessageReceive(handlerId);

错误处理

API 调用返回的响应中包含 codemsg 字段,code0 表示请求成功:

const resp = await client.Im.Message.sendMessage({
  chat_id: 'chat-id',
  message_type: MessageType_TEXT,
  message_content: { text: { content: '飞函新版本发布!' } },
});
if (resp.code !== 0) {
  console.error(`请求失败: code=${resp.code}, msg=${resp.msg}`);
}

环境要求

  • Node.js 18+(需支持 fetchcrypto.subtleCompressionStream
  • 浏览器:现代浏览器(需支持 Web Crypto API 和 CompressionStream)
  • TypeScript 5.0+(可选,SDK 内置类型声明)

相关链接

许可证

Apache-2.0 License