Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@vonage/client-sdk
Advanced tools
The Client SDK is intended to provide a ready solution for developers to build Programmable Conversation applications across multiple Channels including: Messages, Voice, SIP, websockets, and App.
The Client SDK is intended to provide a ready solution for developers to build Programmable Conversation applications across multiple Channels including: Messages, Voice, SIP, websockets, and App.
⚠️ Warning: Chat Functionality (Beta)
The chat functionality in our SDK is currently in beta. Methods related to chat may undergo changes as we refine and improve this feature. Please be aware of potential updates as we work towards its stability. Your feedback is valuable in shaping its development.
The SDK can be installed using the npm install command
npm i @vonage/client-sdk
import { VonageClient, ClientConfig, ConfigRegion } from '@vonage/client-sdk';
import { useState, useEffect } from 'react';
function App() {
// Config is optional but recomended, default region is US
const [config] = useState(() => new ClientConfig(ConfigRegion.US));
const [client] = useState(() => {
const client = new VonageClient();
client.setConfig(config);
return client;
});
const [session, setSession] = useState();
const [user, setUser] = useState();
const [error, setError] = useState();
// Create Session as soon as client is available
useEffect(() => {
if (!client) return;
client
.createSession('my-token')
.then((session) => setSession(session))
.catch((error) => setError(error));
}, [client]);
// Get User as soon as a session is available
useEffect(() => {
if (!client || !session) return;
client
.getUser('me')
.then((user) => setUser(user))
.catch((error) => setError(error));
}, [client, session]);
if (error) return <pre>{JSON.stringify(error)}</pre>;
if (!session || !user) return <div>Loading...</div>;
return <div>User {user.displayName || user.name} logged in</div>;
}
export default App;
<!-- <script src="./node_modules/@vonage/client-sdk/dist/vonageClientSDK.js"></script> -->
<!-- <script src="https://cdn.jsdelivr.net/npm/@vonage/client-sdk@1.0.0/dist/vonageClientSDK.min.js"></script> -->
<script src="./node_modules/@vonage/client-sdk/dist/vonageClientSDK.min.js"></script>
<script>
const token = 'my-token';
const client = new vonageClientSDK.VoiceClient();
const config = new vonageClientSDK.ClientConfig(
vonageClientSDK.ConfigRegion.EU
);
client.setConfig(config);
client.createSession(token).then((Session) => {});
</script>
import {
VonageClient,
ClientConfig,
ConfigRegion
} from 'https://cdn.jsdelivr.net/npm/@vonage/client-sdk@1.0.0/dist/vonageClientSDK.esm.min.js';
const client = new VonageClient();
// Config is optional but recomended, default region is US
const config = new ClientConfig(ConfigRegion.US);
client.setConfig(config);
(async () => {
const token = 'my-token';
try {
// Create Session
const sessionId = await client.createSession(token);
// Get User
const user = await client.getUser('me');
console.log(
`User ${
user.displayName || user.name
} logged in with session ID: ${sessionId}`
);
} catch (error) {
// Log errors for either createSession or getUser
console.error(error);
}
})();
Below are several typical scenarios where the SDK is commonly utilized.
const call = await client.serverCall({
customData: {
callee: 'bob',
type: 'app'
}
});
console.log(call);
// Answer Call
client.on(
'callInvite',
async (callId: string, from: string, channelType: string) => {
client.answerCall(callId);
console.log(callId, from, channelType);
}
);
// ----
// Reject Call
client.on(
'callInvite',
async (callId: string, from: string, channelType: string) => {
client.rejectCall(callId);
console.log(callId, from, channelType);
}
);
// await client.hangup(call);
await client.hangup(call, 'reason-text', 'reason-code');
client.on('callHangup', async (callId: string, callQuality: RTCQuality) => {
if (callId == call) {
console.log(`Call ${callId} has hanged up, callQuality:${callQuality}`);
}
});
client.on('callHangup', (callId, callQuality, reason) => {
if (callId == call) {
console.log('The call has finished');
}
console.log(`this was your call mos score: `, callQuality.mos_score);
const reason_name = reason.name;
if (reason_name === 'LOCAL_HANGUP') {
console.log('you hangup the call');
return;
} else if (reason_name === 'REMOTE_HANGUP') {
console.log('call was hanged up remotly');
return;
} else if (reason_name === 'REMOTE_REJECT') {
console.log('call was rejected');
return;
} else if (reason_name === 'MEDIA_TIMEOUT') {
console.log('media timeout');
return;
} else if (reason_name === 'REMOTE_NO_ANSWER_TIMEOUT') {
console.log('remote no answer timeout');
return;
} else {
return exhaustiveCheck(reason_name);
}
});
try {
let cursor: string | undefined | null = undefined;
const pageSize = 10;
const conversations: Conversation[] = [];
do {
const response: ConversationsPage = await client.getConversations(
PresentingOrder.ASC,
pageSize,
cursor
);
conversations.push(...response.conversations);
cursor = response.nextCursor;
} while (cursor !== null);
console.log(`Conversations successfully fetched: ${conversations}`);
} catch (e) {
console.log(`Error in fetching Conversations: ${e}`);
}
try {
const timestamp = await client.sendTextMessage(
'conversationId',
'Hello there'
);
console.log(`Message successfully sent with timestamp ${timestamp}`);
} catch (e) {
console.log(`Error in sending Message: ${e}`);
}
client.on('conversationEvent', (event) => {
if (event.kind == 'member:invited') {
return;
}
if (event.kind == 'member:joined') {
return;
}
if (event.kind == 'member:left') {
return;
}
if (event.kind == 'message:text') {
return;
}
if (event.kind == 'message:custom') {
return;
}
});
Visit Vonage website
Copyright (c) 2023 Vonage, Inc. All rights reserved. Licensed only under the Vonage Client SDK License Agreement (the "License") located at LICENSE.
By downloading or otherwise using our software or services, you acknowledge that you have read, understand and agree to be bound by the Vonage Client SDK License Agreement and Privacy Policy.
You may not use, exercise any rights with respect to or exploit this SDK, or any modifications or derivative works thereof, except in accordance with the License.
FAQs
The Client SDK is intended to provide a ready solution for developers to build Programmable Conversation applications across multiple Channels including: Messages, Voice, SIP, websockets, and App.
The npm package @vonage/client-sdk receives a total of 3,843 weekly downloads. As such, @vonage/client-sdk popularity was classified as popular.
We found that @vonage/client-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.