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

yunjia-chat-sdk

v1.0.1

Published

Production-grade TypeScript SDK for Yunjia chat service

Downloads

14

Readme

yunjia-chat-sdk

生产级 TypeScript SDK,用于对接云加聊天服务(IDM 登录、服务发现、Chat Client 注册、Socket 收发、消息发送与回执处理)。

Features

  • IDM password 登录与 refresh_token 自动刷新
  • /oauth2.0/profile 自动解析企业与 chat/emm 服务地址
  • 自动注册 chat client(/client-registry/rest/v1/client
  • 基于 socket.io 的长连接通信(支持重连)
  • 默认使用 Socket.IO v2 客户端(适配云加 chat 服务)
  • 可选跨版本模式:socketIoMode: "auto",自动在 v2/v4 间切换
  • 统一封装常见消息能力:
    • 单聊文本
    • 群聊文本(可 @ 用户)
    • 卡片消息
    • 撤回消息
    • 消息已读
    • 拉取频道最近消息
  • 强类型事件系统与错误体系

Install

npm install yunjia-chat-sdk

Quick Start

import { YunjiaChatSDK } from "yunjia-chat-sdk";

const sdk = new YunjiaChatSDK({
  idmBaseUrl: "https://passport.example.com",
  clientId: "your_client_id",
  clientSecret: "your_client_secret",
  username: "robot_account",
  password: "******",
  tenantId: "default",
  socketIoMode: "v2",
  autoConnect: true
});

sdk.on("ready", (session) => {
  console.log("SDK ready", session.enterpriseId, session.chatClientId);
});

sdk.on("message", (message) => {
  const channelId = message.body?.channel;
  const text = message.body?.content?.text;
  console.log("incoming", channelId, text);
});

sdk.on("error", (error) => {
  console.error("sdk error", error);
});

await sdk.initialize();

await sdk.refreshChannels();

sdk.sendTextDirect({
  channelId: "CHANNEL_ID",
  text: "你好,我是机器人"
});

Initialize with Existing Tokens

const sdk = new YunjiaChatSDK({
  idmBaseUrl: "https://passport.example.com",
  clientId: "your_client_id",
  clientSecret: "your_client_secret",
  tenantId: "1001",
  tokens: {
    accessToken: "ACCESS_TOKEN",
    refreshToken: "REFRESH_TOKEN"
  }
});

await sdk.initialize();

API Overview

Required options:

  • idmBaseUrl

  • clientId

  • clientSecret

  • initialize()

  • connect() / disconnect() / close()

  • refreshChannels()

  • createDirectChannel(mateUserId)

  • sendTextDirect(options)

  • sendTextGroup(options)

  • sendTaskCardMessage(options)

  • recallMessage(options)

  • markChannelRead(options)

  • requestChannelRecentMessages(options)

  • refreshAccessToken()

  • getSession()

Events

  • ready
  • connected
  • disconnected
  • reconnecting
  • message
  • history
  • ack
  • status
  • tokenRefreshed
  • error
  • raw

Build & Test

npm run build
npm run test
npm run typecheck

Publish

npm publish --access public