
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
chat-lib-moosedesk
Advanced tools
This documentation provides an overview of the Chat
, Network
class and its methods.
npm install chat-app-workhub --save
or
yarn add chat-app-workhub
We need to install axios socket.io-client before using libs
{
"data": "response api", // response all api
"success": true, // status api true: success, false : have error
}
header status
:
response error
:{
"error": {
"code": "string", // code error
"message": "string", // message
"details": "string", // detail error
"data": {
"additionalProp1": "string", // It cannot determined
"additionalProp2": "string",
"additionalProp3": "string"
},
"validationErrors": [
{
"message": "string",
"members": [
"string"
]
}
]
}
}
Method | Description |
---|---|
connect | Create connections |
disconnet | Stop connections |
sendMessage | send message with group |
updateMessage | update message with group |
receiveMessage | Listens for incoming mes |
receiveDeleteMessage | Listens for incoming mes delete |
setMessageSeenStatus | Sets the "message seen" |
pinMessage | |
unpinMessage | |
reactMessage | |
receiveMessageReaction | |
setMessageSeenStatus | |
receiveMessageSeenStatus | |
revokeMessage | |
onRevokeMessage | |
revokeAttachment | |
onRevokeAttachment |
sendMessage
Listens for incoming chat messages and invokes a callback function when a new message is received.
chat.sendMessage(
{
message: '', // message sent
attachments: [
{
name: '', // name file
desciption: '',
id: '', // id attachments (send id = null or '')
url: '', // url file
typeAttachment: 1, // - video = 1, // - audio = 2// - image = 3// - file = 4 // - other = 5
sizeByte: 0,
durationSeconds: 0,
revoke: 1, // 1 revoke for sender, 2 revoke for all group
},
],
forwardFromRoomId: '',
mentionIds: [], // list userId mention
type: 0, //type message list in here:
// - text = 0
// - audio = 1
// - file = 2
// - sticker = 3
// - gallery = 4
// - video = 5
quoteMessageId: '', // message quote id
forwardMessageId: '', // message forward id
},
id
);
receiveMessage
Listens for incoming chat messages and invokes a callback function when a new message is received.
chat.receiveMessage((message) => {});
import {
ChatUser,
Chat,
InitChatSocket,
InitChatMagement,
} from 'chat-app-demo-abc';
// auth config
const chatUser = InitChatUser(url, token); // url auth (http://123.30.145.67:14100/) . token : your access token (string)
or;
const chatUser = new ChatUser(url, token);
// auth message reader
const apiMessage = InitMessageReader(url, token); // url auth (http://123.30.145.67:14103/) . token : your access token (string)
or;
const apiMessage = new MessageReader(url, token);
// chat management
const apiManage = new ChatMagement('url_chat_manager', token); // url http://123.30.145.67:14101/
or;
const apiManage = InitChatMagement('url_chat_manager', token);
// chat management
const chat = new InitChatSocket('url_chat_soket', token); // url http://123.30.145.67:14110/
or;
const chat = ChatSocket('url_chat_socket', token);
Method | Params | Description |
---|---|---|
Login | userName:String, passWord: string | get token using to conect chat |
Login
const result = await ChatUser.login(param);
// param request
{
"userName": "string", //email account login
"passWord": "string", // password
"pushToken": "string"// pushtoken is device token in firebase
}
// this way to get info user
import jwt_decode from "jwt-decode";
var infoUser = jwt_decode(access_token);
note: if you need get info user ex: useId, name... you have to instal jwt-decode to decode access_token then you have it
register
const result = await ChatUser.register(param);
// param request
{
"username": "string",
"email": "string",
"phoneNumber": "string",
"gender": 0,
"avatar": "string", // url avatar (optional)
"dateOfBirth": "2023-10-06T02:43:24.154Z",
"password": "string",
"image": { // optional
"fileId": "string", // file id get from api upload(optional)
"fileName": "string", // name file (optional)
"extension": "string", // extension file
"fileUrl": "string", // url file
"contentType": "string"
},
"isAdmin": false // status is admin default false
}
// this way to get info user
import jwt_decode from "jwt-decode";
var infoUser = jwt_decode(access_token);
listUserContactAdd
find list user by contact(phone)
const param = ['09xxx', '08xxx'];
const result = await chatUser.listUserContactAdd(param);
searchFriends
find friends
const result = await chatUser.searchFriends(param);
// param request
{
"GroupId": "string",
"Filters": "string", // string search
"phoneNumber": "string",
"Sorting": "ASC",
"SkipCount": 0,
"MaxResultCount": 0,
}
userDoAction
User action(add friend, unfriend, block , unblock)
const result = await chatUser.userDoAction(param);
// param request
{
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",// userid user
"actionType": 0 // 0: add friend, 1: unfriend, 2: block , 3 unblock
}
}
listFriends
const result = await chatUser.listFriends(param);
// param request
{
"GroupId": "string",
"Filters": "string", // string search
"phoneNumber": "string",
"Sorting": "ASC",
"SkipCount": 0,
"MaxResultCount": 0,
}
ListRoomChat
Retrieves a list of chat rooms in which a user has participated.
const param = { userId: '', skip: 0, take: 20 };
const result = await apiManage.ListRoomChat(param);
// param request
{
"userId": "string", // userId (can be null default get by token)
"groupName":"", // name group
"tagFilter": null, // number 1,2,3
"skip": 0, // point start record
"take": 0// The number of records retrieved
}
searchRoomChat
Searches for chat rooms based on specified criteria.
const result = await apiManage.searchRoomChat(param);
// param request
{
"roomType":"", // 0,1,2
"filter": '', // string filter
"skip": 0, // point start record
"take": 0// The number of records retrieved
}
getTotalUnread
Searches for chat rooms based on specified criteria.
const result = await apiManage.getTotalUnread();
groupParticipants
Searches for chat rooms based on specified criteria.
const result = await apiManage.groupParticipants(groupId, param);
// param request
{
"skip": 0, // point start record
"take": 0// The number of records retrieved
}
getInfoRoomChat
Searches for chat rooms based on specified criteria.
const result = await apiManage.getInfoRoomChat(groupId);
// param request
groupId: ''; // id group chat
createRoomChat
Searches for chat rooms based on specified criteria.
const result = await apiManage.createRoomChat(param);
// param request
{
"name": "string", // name group
"roomType": 0, // deprecated
"typeOfGroup": 0, // type group 0.1.2, default 0
"topic": "string",
"description": "string",
"image": "string", // url image group
"ownerId": "string", // id user owner group
"participants": [
"string"
], // list userid
"tags": [
"string"
],
"sendDefaultMessage": true, //status send default message
"defaultMessageContent": "string" // message default
}
updateInfoRoom
Searches for chat rooms based on specified criteria.
const result = await apiManage.updateInfoRoom(param);
// param request
{
"name": "string",
"topic": "string",
"description": "string",
"image": "string"
}
deleteChatRoom
Searches for chat rooms based on specified criteria.
const result = await apiManage.deleteChatRoom(roomId);
// param request
"roomId":'' // room id
// response
// method delete success: 200 in header status
// error
joinChatGroup
Searches for chat rooms based on specified criteria.
const result = await apiManage.joinChatGroup(groupId, userId);
// param request
{
"groupId": "string",
"userId": "string"
}
inviteChatGroup
Searches for chat rooms based on specified criteria.
const result = await apiManage.inviteChatGroup(param);
// param request
{
"groupId": "string", // id room
"userId": [
"string"
] // list userId invite
}
inviteChatGroup
Searches for chat rooms based on specified criteria.
const result = await apiManage.removeUserChatGroup(param);
// param request
{
"groupId": "string",
"userId": "string"
}
chatHistory
Retrieves the chat history of a group.
const param = { userId: '', skip: 0, take: 20 };
const result = await apiMessage.chatHistory(roomid, param);
// param request
{
"before":"", //
"after": '', //messageid after
"isPined":null, //boolean, true message pined
"skip": 0, // point start record
"take": 0// The number of records retrieved
}
historyAttachment
Retrieves the history of attachments in a group.
const result = await apiMessage.historyAttachment(roomId, param);
// param request
{
"before":"", //
"after": '', //messageid after
"types": [], // - VIDEO = 1,AUDIO = 2,IMAGE = 3,FILE = 4,OTHER = 5
"skip": 0, // point start record
"take": 0// The number of records retrieved
}
searchMessegeInGroup
Retrieves the history of message in a group.
const result = await apiMessage.searchMessegeInGroup(roomId, param);
// param request
{
"textSearch": '', // text search
"skip": 0, // point start record
"take": 0// The number of records retrieved
}
getHistoryAroundMessage
Retrieves the history of attachments in a group.
const result = await api.getHistoryAroundMessage(param);
// param request
{
"roomId": '', // roomid search
"messageId": '', // messageid
"take": 10 // The number of records retrieved: default 10
}
getLastMessagePined
Retrieves the history of attachments in a group.
const result = await api.getLastMessagePined(roomid);
Optional
if you don't have server saved files(audio, image, gift, video) you can using this server for that
const formData = new FormData(form);
// url: http://123.30.145.67:14104/file/upload
const result = await ChatUser.upload('url_server_upload', formData);
Connect and receive
import { ChatSocket } from 'chat-app-demo-abc';
const ChatScreen = () => {
const chat = new ChatSocket('url_socket', token);
useEffect(() => {
chat.connect();
chat.receiveMessage((message) => {
//
});
return () => {
chat.disconnect();
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const sendMessage = () => {
const param = {
message: 'text test',
attachments: [],
forwardFromRoomId: '',
mentionIds: [],
type: 0,
quoteMessageId: '',
forwardMessageId: '',
};
chat.sendMessage(param, id);
};
};
login
const api = InitChatAuth({
authUrl: 'http://123.30.145.67:14100/',
token: '',
});
const handelLogin = useCallback(async () => {
const result = await api.Login({
passWord: 'paasword',
userName: 'username',
});
setToken(result.access_token);
}, [api]);
FAQs
chat and auth socket
The npm package chat-lib-moosedesk receives a total of 42 weekly downloads. As such, chat-lib-moosedesk popularity was classified as not popular.
We found that chat-lib-moosedesk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.