
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
nexmo-conversation
Advanced tools
nexmo-cli
tool[username]
)$ npm install nexmo-conversation
create a nexmo application using the nexmo-cli
$ nexmo app:create "Application name" --type rtc --keyfile private.key
>Application created: xxxxxxxx-xxxx-xxxx-xxxx-xxxxsxxxxxxx
>Private Key saved to: private.key
get a token to create a user:
$ nexmo jwt:generate private.key application_id=[application_id]
create a user in your app
$ curl -X POST -H 'Authorization: Bearer [JWT]' -H 'Content-Type:application/json' -d '{"name":"[username]"}' https://api.nexmo.com/beta/users
include the script in your web page
<script src="node_modules/nexmo-conversation/dist/conversationClient.js"></script>
get a user's token
$ nexmo jwt:generate private.key application_id=[application_id] sub=[username]
var rtc = new ConversationClient({debug:false});
// var token = request login token as above, with sub=<username>
rtc.login(token).then(
function(application){
// use the application object to manage the conversations
// access the available conversations
console.log(application.conversations);
});
var conversationData = {
display_name:'Nexmo Conversation'
};
application.newConversation(conversationData).then(
function(conversation) {
// join the created conversation
conversation.join().then(
function(member) {
console.log("Joined as " + member.user.name);
});
}).catch(function(error) {
console.log(error);
});
application.getConversation(conversation_id).then(
function(conversation) {
// console.log(conversation);
});
conversation.on("text", function(sender, textEvent){
if (textEvent.cid === conversation.id){
// if (rtc.isVisible) { textEvent.seen(); }
console.log("message received:", textEvent, sender);
}
});
conversation.sendText("Hi Nexmo").then(function(){
console.log('message was sent');
}).catch(function(error){
console.log('error sending the message', error);
});
var rtc = new ConversationClient({debug:false});
// var token = request login token as above, with sub=<username>
rtc.login(token).then(
function(application){
// access the available conversations
console.log(application.conversations);
// you might already have conversations under `application.conversations[]` to get,
// or join (if application.conversations[xxx].me.state === "joined" || "invited" respectively)
application.newConversation().then( //not providing a name, the service will assign a random one for you
function(conversation) {
// join the created conversation
// you can also find your user_id under rtc.application.me (as application === rtc.application)
conversation.join().then(
function(member) {
console.log("Joined as " + member.user.name); //member.id is your member's id
});
// listen for incoming text messages
conversation.on("text", function(sender, textEvent){
// manage seen indication
// if (rtc.isVisible) { textEvent.seen(); }
console.log("message received:", textEvent, sender);
});
// send a text event to the conversation
conversation.sendText("Hi Nexmo").then(
function(){
console.log('message was sent');
}).catch(function(error){
console.log('error sending the message', error);
});
}).catch(function(error) {
console.log(error);
});
});
The main objects here are application
and conversation
you can use them to extend the use case.
E.g. by inviting a second user to a conversation that you are a member (have joined).
The second instance should see the conversation listed, and the member(or me).state as "invited"
When both instances have attached listener to "text" events of a conversation they have both joined,
you should be able to send/receive text events in that conversation.
If you want to contribute:
clone this repo and enter in it's directory
$ npm install
$ npm start
it will build interracially your code.
or
$ npm run build
$ npm run docs
it will generate your code in dist/conversationClient
you can run the test with
$ npm run test
FAQs
Nexmo Conversation SDK for JavaScript
The npm package nexmo-conversation receives a total of 2 weekly downloads. As such, nexmo-conversation popularity was classified as not popular.
We found that nexmo-conversation demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers 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.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.