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

@wildfirechat/server-sdk

v1.0.0

Published

Wildfire Chat Server SDK for JavaScript/Node.js - 野火IM服务端JavaScript SDK

Readme

Wildfire Chat Server SDK for JavaScript/Node.js

野火IM服务端JavaScript SDK,功能与Java版Server SDK完全对齐。

安装

npm install @wildfirechat/server-sdk

快速开始

import { init, UserAdmin, MessageAdmin, Conversation, MessageContentType } from '@wildfirechat/server-sdk';

// 初始化SDK
init('http://localhost:18080', 'your-admin-secret');

// 使用async/await调用API
async function example() {
    // 获取用户信息
    const userResult = await UserAdmin.getUserByUserId('userId');
    if (userResult.isSuccess()) {
        console.log('用户信息:', userResult.getResult());
    } else {
        console.error('获取失败:', userResult.getMsg());
    }

    // 发送消息
    const conversation = new Conversation(0, 'targetUserId', 0); // 单聊会话
    const payload = {
        type: MessageContentType.Text,
        searchableContent: 'Hello from Server SDK!'
    };
    const messageResult = await MessageAdmin.sendMessage('senderId', conversation, payload);
    console.log('消息发送结果:', messageResult.getResult());
}

example().catch(console.error);

功能模块

用户管理 (UserAdmin)

import { UserAdmin } from '@wildfirechat/server-sdk';

// 获取用户信息
await UserAdmin.getUserByUserId(userId);
await UserAdmin.getUserByName(name);
await UserAdmin.getUserByMobile(mobile);

// 创建/更新用户
await UserAdmin.createUser(userInfo);
await UserAdmin.updateUserInfo(user, flag);

// 机器人管理
await UserAdmin.createRobot(robot);
await UserAdmin.getRobotInfo(robotId);

// 用户状态管理
await UserAdmin.updateUserBlockStatus(userId, block);
await UserAdmin.checkUserOnlineStatus(userId);
await UserAdmin.kickoffUserClient(userId, clientId);

// Token管理
await UserAdmin.getUserToken(userId, clientId, platform);

// 在线用户
await UserAdmin.getOnlineUserCount();
await UserAdmin.getOnlineUser(nodeId, offset, count);

消息管理 (MessageAdmin)

import { MessageAdmin } from '@wildfirechat/server-sdk';

// 发送消息
await MessageAdmin.sendMessage(sender, conversation, payload);
await MessageAdmin.sendMessageToUsers(sender, conversation, payload, toUsers);

// 消息操作
await MessageAdmin.recallMessage(operator, messageUid);
await MessageAdmin.deleteMessage(messageUid);
await MessageAdmin.updateMessageContent(operator, messageUid, payload, distribute);

// 群发/广播
await MessageAdmin.multicastMessage(sender, receivers, line, payload);
await MessageAdmin.broadcastMessage(sender, line, payload);

// 获取消息状态
await MessageAdmin.getConversationReadTimestamp(userId, conversation);
await MessageAdmin.getMessageDelivery(userId);

群组管理 (GroupAdmin)

import { GroupAdmin } from '@wildfirechat/server-sdk';

// 群组操作
await GroupAdmin.createGroup(operator, groupInfo, members, memberExtra, toLines, notifyMessage);
await GroupAdmin.getGroupInfo(groupId);
await GroupAdmin.dismissGroup(operator, groupId, toLines, notifyMessage);
await GroupAdmin.transferGroup(operator, groupId, newOwner, toLines, notifyMessage);

// 群组成员管理
await GroupAdmin.addGroupMembers(operator, groupId, members, memberExtra, toLines, notifyMessage);
await GroupAdmin.kickoffGroupMembers(operator, groupId, memberIds, toLines, notifyMessage);
await GroupAdmin.quitGroup(operator, groupId, toLines, notifyMessage);
await GroupAdmin.getGroupMembers(groupId);

// 群组设置
await GroupAdmin.modifyGroupInfo(operator, groupId, type, value, toLines, notifyMessage);
await GroupAdmin.setGroupManager(operator, groupId, memberIds, isManager, toLines, notifyMessage);
await GroupAdmin.muteGroupMember(operator, groupId, memberIds, isMute, toLines, notifyMessage);
await GroupAdmin.setGroupMemberAlias(operator, groupId, memberId, alias, toLines, notifyMessage);

好友关系管理 (RelationAdmin)

import { RelationAdmin } from '@wildfirechat/server-sdk';

// 好友管理
await RelationAdmin.setUserFriend(userId, targetId, isFriend, extra);
await RelationAdmin.getFriendList(userId);
await RelationAdmin.sendFriendRequest(userId, targetId, reason, force);
await RelationAdmin.updateFriendAlias(operator, targetId, alias);

// 黑名单管理
await RelationAdmin.setUserBlacklist(userId, targetId, isBlacklist);
await RelationAdmin.getUserBlacklist(userId);

// 获取关系
await RelationAdmin.getRelation(userId, targetId);

聊天室管理 (ChatroomAdmin)

import { ChatroomAdmin } from '@wildfirechat/server-sdk';

await ChatroomAdmin.createChatroom(chatroomId, title, desc, portrait, extra, state);
await ChatroomAdmin.destroyChatroom(chatroomId);
await ChatroomAdmin.getChatroomInfo(chatroomId);
await ChatroomAdmin.getChatroomMembers(chatroomId);
await ChatroomAdmin.setChatroomManager(chatroomId, userId, status);
await ChatroomAdmin.setChatroomMute(chatroomId, mute);

频道管理 (ChannelAdmin)

import { ChannelAdmin } from '@wildfirechat/server-sdk';

await ChannelAdmin.createChannel(channelInfo);
await ChannelAdmin.destroyChannel(channelId);
await ChannelAdmin.getChannelInfo(channelId);
await ChannelAdmin.subscribeChannel(channelId, userId);
await ChannelAdmin.unsubscribeChannel(channelId, userId);

会议管理 (ConferenceAdmin)

import { ConferenceAdmin } from '@wildfirechat/server-sdk';

await ConferenceAdmin.listConferences(count, offset);
await ConferenceAdmin.createRoom(roomId, description, pin, maxPublisher, advance, bitrate, recording, permanent);
await ConferenceAdmin.destroy(roomId, advance);
await ConferenceAdmin.listParticipants(roomId, advance);
await ConferenceAdmin.enableRecording(roomId, advance, recording);

机器人服务 (RobotService)

import { RobotService } from '@wildfirechat/server-sdk';

// 创建机器人服务实例(与Admin不同,需要实例化)
const robotService = new RobotService('http://localhost:18080', 'robotId', 'robotSecret');

// 发送消息
await robotService.sendMessage(sender, conversation, payload);
await robotService.replyMessage(messageUid, payload, only2Sender);

// 获取用户信息
await robotService.getUserInfo(userId);

// 群组管理
await robotService.createGroup(groupInfo, members, memberExtra, toLines, notifyMessage);
await robotService.getGroupInfo(groupId);
await robotService.addGroupMembers(groupId, members, memberExtra, toLines, notifyMessage);

// 回调管理
await robotService.setCallback(url);
await robotService.getCallback();

模型类

SDK提供了与vue-pc-chat完全兼容的模型类:

import {
    // 会话
    Conversation,
    ConversationType,
    
    // 用户和群组
    UserInfo,
    GroupInfo,
    GroupMember,
    GroupType,
    GroupMemberType,
    
    // 聊天室和频道
    ChatRoomInfo,
    ChannelInfo,
    
    // 消息内容
    MessagePayload,
    MessageContent,
    MessageContentType,
    TextMessageContent,
    ImageMessageContent,
    FileMessageContent,
    // ... 等等
} from '@wildfirechat/server-sdk';

错误处理

所有API调用都返回 IMResult 对象:

const result = await UserAdmin.getUserByUserId('userId');

if (result.isSuccess()) {
    // 成功,获取返回数据
    const user = result.getResult();
} else {
    // 失败,获取错误信息
    console.error('错误码:', result.getCode());
    console.error('错误信息:', result.getMsg());
    console.error('错误码常量:', result.getErrorCode()); // 如: 'ERROR_CODE_USER_NOT_EXIST'
}

许可证

MIT