Research
Security News
Malicious PyPI Package ‘pycord-self’ Targets Discord Developers with Token Theft and Backdoor Exploit
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
eltok-firebase-chat
Advanced tools
The purpose of this node package is to quickly implement one to one text & video chat, group text chat using firebase realtime database as a backend infrastructure. You have to subscribe for your own firebase setup. Currently this package supports one to one and group chat with text and file messages, also supports user online status, typing status (for one to one chat) and other important features.
Create Ionic project
ionic start myApp blank
Create Firebase Account
To create firebase setup follow the below steps:
npm i --save juegostudio-firebase-chat-plugin
import * as FirebaseChat from 'juegostudio-firebase-chat-plugin';
const firebaseConfig = {
apiKey: "xxxxxx",
authDomain: "xxxxxxx.firebaseapp.com",
databaseURL: "https://xxxxxxx.firebaseio.com",
projectId: "xxxxxxx",
storageBucket: "xxxxxxx.appspot.com",
messagingSenderId: "XXXXXXXXXXX"
};
var app = new FirebaseChat(firebaseConfig);
This method will create new user if user doesn't exist, else it will return existing user details. After initialization you'll be able use chat methods mentioned below.
app.initChat(userID, displayName, displayPic /*optional*/)
.then(user=>{
console.log(user);// return user object
})
.catch(err=> console.log(err));
app.sendMessage(otherUserId/groupID, message, channelType, messageType /*optional*/, fileKey /*optional*/)
.then(res => {
console.log(res);
})
.catch(err => console.log(err));
app.getChannelList()
.then(channelList => {
console.log(channelList);
})
.catch(err=> console.log(err));
app.getMessageList(otherUserId/groupID, channelType)
.subscribe(message => {
console.log(message);
},
err => console.log(err));
This package uses WebRTC APIs for video chat. Only one to one video chat is supported. WebRTC uses RTCPeerConnection to communicate streaming data between browsers, but also needs a mechanism to coordinate communication and to send control messages, a process known as signaling. In this package we have implemented Signaling methods using Firebase real time database.
npm i --save juegostudio-firebase-chat-plugin
import * as FirebaseChat from 'juegostudio-firebase-chat-plugin';
Specify the Firebase Configuration
const firebaseConfig = {
apiKey: "xxxxxx",
authDomain: "xxxxxxx.firebaseapp.com",
databaseURL: "https://xxxxxxx.firebaseio.com",
projectId: "xxxxxxx",
storageBucket: "xxxxxxx.appspot.com",
messagingSenderId: "XXXXXXXXXXX"
};
Specify the Video configuration
videoChatServerConfig is an optional
parameter while creating the instance of FirebaseChat
. URLs for STUN and TURN server can be set using this argument.
// videoChatServerConfig looks similar to this.
const videoChatServerConfig = {
'iceServers': [
{
'urls': 'stun:stun.l.google.com:19302'
},
{
'urls': 'yourturn server',
'username': 'userName',
'credential': 'credentials'
},
{
'urls': 'turn server',
'username': 'username',
'credential' : 'credentials'
}
]
}
Create a instance
var app = new FirebaseChat(firebaseConfig, videoChatServerConfig /*optional parameter*/);
STUN/TURN servers are required to get working video chat. Without specifying videoChatServerConfig
video chat will work only on devices connected to same LAN. For more information about STUN and TURN servers you can refer this link. To host TURN Server refer to this link. It will explain how to host TURN server on Amazon AWS.
This method will create new user if user doesn't exist, else it will return existing user details. After initialization you'll be able use chat methods mentioned below.
app.initChat(userID, displayName, displayPic /*optional*/)
.then(user=>{
console.log(user);// return user object
})
.catch(err=> console.log(err));
This method will return Promise, if it is successful it will return channelId and localVideoSrc as response object properties. response.localVideoSrc can be used as src
for html video
tag.
app.initiateCall(otherUid)
.then(response=>{
console.log(response);
})
.catch(err=>{ console.log(err) });
This method will be listening to incoming video calls. If there is a incoming call, you'll get videocall channel ID and initiatedBy(userId of person who has initiated this call) as response object properties. This response properties are required while accepting this call.
app.listenToIncomingCall()
.subscribe(res=>{console.log(res)})
This method will accept incoming call. As a response you'll get localVideoSrc as response object prop.
app.acceptCall(channelId, initiatedBy)
.then(response=>console.log(res))
After completing signaling you can add app.remoteStreamSrc
as src
for remote video
html tag.
This method will stop both remote & local streams. Channel which was used for signaling will be deleted.
app.disconnectCall(channelId)
Video chat requires some permissions for the android build. So if you are making the android build, you need to set following permissions in AndroidManifest file.
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
Ionic project
Check sample code here.
HTML project is under development.
Updating profile picture
This method is used to update both user and group display picture.
To update group display picture pass the groupID and channelType = 'group'.
To update user display picture pass the channelType = 'one2one'.
app.updateProfilePic(filePath, channelType, groupID/*optional*/)
.then(fileKey => {
console.log(filKey)
})
.catch(err => console.log(err));
Get User Details
app.getUserDetails(otherUserId)
.then(response => {
console.log(response);
})
.catch(err => console.log(err));
Listening to Updated Channels
app.listenToUpdatedChannels()
.subscribe( updatedChannels => {
console.log(updatedChannels);
},
err => console.log(err));
Get Online Status
app.getOnlineStatus(otherUserId)
.subscribe(onlineStatus=> {
console.log(onlineStatus);
});
Typing Indicator
To set Typing status of the user, parameters required are: Receiver's UserID and id of the input
html tag.
app.setIsTypingStatus(otherUserId, inputTagId)
.then(successMsg => {
console.log(successMsg);
})
.catch(err=> console.log(err));
To get Typing status, the user has to send userId of the Other user
app.getIsTypingStatus(OtherUserId)
.subscribe(TypingStatus => {
console.log(TypingStatus);
});
Sending Image
app.sendImage(imageUrl, otherUserId/groupID, channelType , messageType)
.then(res =>
console.log(res),
err => console.log(err));
Get file using fileKey
sendImage()
method uploads compressed image, returns fileKey. To get actual image use fileKey with getFile()
method.
app.getFile(fileKey)
.then(res=> {
console.log(res);
})
Creating Group
This method will create the group with the current userID.
app.groupCreate(groupId, groupName, grpProfilePicture /*optional*/)
.then(details => {
console.log(details);
})
.catch(err => console.log(err));
Adding Group Member
This method will add one member at a time.
app.groupAddMember(userId, grpId)
.then(response => {
console.log(response);
})
.catch(err => console.log(err));
Exit Group
This method will delete the group from your channel list.
app.groupDelete(grpId)
then(response => {
console.log(response);
})
.catch(err => console.log(err));
FAQs
Firebase chat plugin
The npm package eltok-firebase-chat receives a total of 0 weekly downloads. As such, eltok-firebase-chat popularity was classified as not popular.
We found that eltok-firebase-chat 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
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.