Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@wazo/sdk
Advanced tools
Wazo JavaScript SDK makes it easy for you to build Programmable Conversation applications. Use this dev kit in any JS application to leverage communication possibilities.
Wazo's Javascript SDK allows you to use these features :
Voice
Video
Chat
Fax
Log
Status
Config
Misc
Voice
Video
Chat
Fax
Status
Config
Misc
You may install the Wazo JavaScript Software Development Kit to your project one of the following ways:
npm install @wazo/sdk
yarn add @wazo/sdk
Voice
Video
Chat
Fax
Status
Config
Misc
Alternatively, you may load the Wazo SDK from a CDN. Use one of the following Content Delivery Networks:
<script src="https://unpkg.com/@wazo/sdk/dist/wazo-sdk.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@wazo/sdk"></script>
// For Node / packaged app
import Wazo from '@wazo/sdk';
// Browser
// You can access the `Wazo` object directly on the browser, simply include it in the html :
<script src="https://unpkg.com/@wazo/sdk/dist/wazo-sdk.js"></script>
or
<script src="https://cdn.jsdelivr.net/npm/@wazo/sdk"></script>
Wazo.Auth.init(clientId, tokenExpiration, minSubscriptionType, authorizationName);
clientId
: string (optional)
tokenExpiration
: number (optional, default 3600 seconds)
minSubscriptionType
: number (optional)
authorizationName
: string (optional)
Wazo.Auth.setHost(host);
host
: string
fetch
optionsWazo.Auth.fetchOptions({
referrer: '',
});
options
: Object
fetch
requests of the SDK.const session = await Wazo.Auth.logIn(username, password, backend, tenantId);
username
: string
password
: string
backend
: string
tenantId
: string
Returns as Wazo.domain.Session
. This object contains, among other information, the user's token.
Note: you need to set clientId
in your WazoAPIClient in order to get a refresh token in the returned Session
.
const response = await Wazo.Auth.initiateIdpAuthentication(domain, redirectUrl);
domain
: string
redirectUrl
: string
Returns an object that contains a location
and a saml_session_id
location
is the URL to open for the user to log in through an identity provider.
saml_session_id
needs to be used to create a wazo-auth token once the SAML authentication has been completed successfully.
const session = await Wazo.Auth.samlLogIn(samlSessionId);
samlSessionId
: string
initiateIdpAuthentication
Returns as Wazo.domain.Session
. This object contains, among other information, the user's token.
const logoutResponse = await Wazo.Auth.samlLogOut();
Returns an object that contains a location
location
is the URL to open for the user to log out from their identity provider.
const session = await Wazo.Auth.validateToken(token, refreshToken);
token
: string
refreshToken
: string (optional)
Returns as Wazo.domain.Session
.
When the user's token is about to expire, Wazo's SDK triggers a callback so you can update it in your application. Like updating the new token in your localstorage / cookies.
Note: you need to set clientId
in your WazoAPIClient in order to refresh tokens.
Wazo.Auth.setOnRefreshToken(token => { /* Do something with the new token */ });
callback
: Function(token: string)
Destroys user's token and refreshToken.
await Wazo.Auth.logout();
Wazo.Room.connect(options);
options
: Objectextension
: string
The room extension (number) you want to joinaudio
: boolean|Object
A boolean, if you want to send the user audio or not; or an Object, if you want to specify the audio input, etc...
See getUserMedia arguments for more information.video
: boolean|Object
A boolean, if you want to send the user video or not; or an Object, if you want to specify the audio input, etc...
See getUserMedia arguments for more information.extra
: Object
A map of values that will be added to the information of the current participant.Returns a Wazo.Room
instance.
room.sendChat(content);
content
: string
The chat message content you want to send to all participants in the room.room.sendSignal(content);
content
: string
The message content you want to send to all participants in the room.room.startScreenSharing(constraints);
constraints
: Object
See getUserMedia arguments for more information.room.stopScreenSharing();
room.turnCameraOff();
room.turnCameraOn();
room.mute();
room.unmute();
room.participants;
participants
: An array of Wazo.LocalParticipant
and Wazo.RemoteParticipant
.
Wazo.room.disconnect();
room.on(room.ON_CHAT, (message) => {});
Triggered when receiving a chat message.
message
: stringroom.on(room.ON_MESSAGE, (message) => {});
Triggered when receiving a custom message.
message
: stringroom.on(room.ON_JOINED, (participant) => {});
Triggered when joining the room.
participant
: Wazo.LocalParticipant
.room.on(room.CONFERENCE_USER_PARTICIPANT_JOINED, (participant) => {});
Triggered when a participant joins the room.
participant
: Wazo.RemoteParticipant
.room.on(room.CONFERENCE_USER_PARTICIPANT_LEFT, (participant) => {});
Triggered when a participant leaves the room.
participant
: Wazo.RemoteParticipant
.room.on(room.ON_SCREEN_SHARE_ENDED, () => {});
Triggered when screensharing is stopped.
participant
: Wazo.RemoteParticipant
.room.on(room.ON_TALKING, (channel, participant) => {});
Triggered when a participant is talking or stops talking.
channel
: Object containing information about the event.participant
: Wazo.RemoteParticipant
or Wazo.LocalParticipant
.
The participant instance, you can access the participant.isTalking
attribute to know the status.Voice
Video
Use this method to merge multiple calls in a new ad hoc conference.
const adHocConference = Wazo.Phone.startConference(host: CallSession, otherCalls: CallSession[]): Promise<AdHocAPIConference>;
Use this method to add a single call to an existing conference room.
adHocConference.addParticipant(participant: CallSession);
Use this method to remove a participant from a conference.
adHocConference.removeParticipant(callSession: CallSession);
// shouldHold indicate if the session should be held after removed from session
Use this method to terminate a conference.
adHocConference.hangup();
You can access the current webRtcPhone instance via Wazo.Phone.phone
.
You can access all Wazo's domain objects in Wazo.domain.*
, like Wazo.domain.Session
;
Wazo.LocalParticipant
and Wazo.RemoteParticipant
shares the same properties :
uuid
: string
The participant uuid.
name
: string
The participant name, retrieved from the sip configuration.
isTalking
: boolean
Indicates if the participant is currently talking.
streams
: Array of Wazo.Stream
List all streams that the participant is sending.
videoStreams
: Array of Wazo.Stream
List all video streams that the participant is sending.
audioMuted
: boolean
Indicates if the participant has muted his microphone.
videoMuted
: boolean
Indicates if the participant has muted his camera.
screensharing
: boolean
Indicates if the participant is currently sharing his screen.
extra
: Object
extra information related to a participant.
participant.on(participant.ON_UPDATED, () => {});
Triggered when the participant is updated.
participant.on(participant.ON_START_TALKING, () => {});
Triggered when the participant is talking.
participant.on(participant.ON_STOP_TALKING, () => {});
Triggered when the participant stops talking.
participant.on(participant.ON_DISCONNECT, () => {});
Triggered when the participant leaves the room.
participant.on(participant.ON_STREAM_SUBSCRIBED, (stream) => {});
Triggered when the participant sends a stream.
stream
: Wazo.Stream
A Wazo stream that is sent by the participant.participant.on(participant.ON_STREAM_UNSUBSCRIBED, (stream) => {});
Triggered when the participant stops sending a stream.
stream
: Wazo.Stream
A Wazo stream that is no longer sent by the participant.participant.on(participant.ON_AUDIO_MUTED, () => {});
Triggered when the participant has disabled his microphone.
participant.on(participant.ON_AUDIO_UNMUTED, () => {});
Triggered when the participant has enabled his microphone.
participant.on(participant.ON_VIDEO_MUTED, () => {});
Triggered when the participant has disabled his camera.
participant.on(participant.ON_VIDEO_UNMUTED, () => {});
Triggered when the participant has enabled his camera.
participant.on(participant.ON_SCREENSHARING, () => {});
Triggered when the participant is sharing his screen.
participant.on(participant.ON_STOP_SCREENSHARING, () => {});
Triggered when the participant stops sharing his screen.
Wazo.Stream
helps attach or detach streams to HTML elements:
stream.attach(htmlEmelent)
Attaches a stream to an existing htmlElement or creates and returns a new one.
htmlElement
: htmlElement (optional).Returns a htmlElement
(audio or video) attached to the stream.
stream.detach(htmlEmelent)
Detaches a stream from an existing htmlElement.
htmlElement
: htmlElement.Voice
Video
Chat
Fax
Status
Config
Misc
Depending on your preference, you may require or add the Wazo SDK to your own client application one of the following ways using:
const { WazoApiClient } = require('@wazo/sdk');
import { WazoApiClient } from '@wazo/sdk';
Depending on your environment you can import:
@wazo/sdk/esm
: compatible with (most) browsers only.@wazo/sdk/lib
: runnable on node
env.import { WebRTCClient } from '@wazo/sdk';
import { WazoWebSocketClient } from '@wazo/sdk';
Voice
Video
Chat
Fax
Status
Config
Misc
const client = new WazoApiClient({
server: 'stack.example.com', // required string
agent: null, // http(s).Agent instance, allows custom proxy, unsecured https, certificate etc.
clientId: null, // Set an identifier for your app when using refreshToken
isMobile: false,
});
const session = await client.auth.logIn({ ... });
Voice
Video
Chat
Fax
Status
Config
Misc
client.auth.logIn({
expiration, // optional integer. Session life in number of seconds. If omitted, defaults to 3600 (an hour).
username, // required string
password, // required string
backend, // optional string. If omitted, defaults to wazo_user
mobile, // optional boolean. If omitted, defaults to false: tells if the current user uses a mobile application
tenantId, // optional string. The tenant identifier (uuid or slug). Needed when backend is external (not wazo_user)
}).then(/* undefined if login failed, or : */{
metadata: {
username,
uuid_tenant_uuid,
xivo_user_uuid,
groups,
xivo_uuid,
tenants: [{ uuid }],
auth_id
},
// should be used for other request
acl,
utc_expires_at,
xivo_uuid,
issued_at,
utc_issued_at,
auth_id,
expires_at,
xivo_user_uuid
});
// or
const { refreshToken, ...result } = await client.auth.logIn(/* ... */);
Note: you need to set clientId
in your WazoAPIClient in order to get a refresh token.
Voice
Video
Chat
Fax
Status
Config
Misc
client.setToken(token);
client.setRefreshToken(refreshToken);
client.setRefreshTokenExpiration(tokenExpirationInSeconds);
Note: you need to set clientId
in your WazoAPIClient in order to get a refresh token.
Voice
Video
Chat
Fax
Status
Config
Misc
client.setOnRefreshToken((newToken, newSession) => {
// Do something with the new token and the new session (like storing them in the localstorage...).
});
Note: you need to set clientId
in your WazoAPIClient to refresh a token.
Voice
Video
Chat
Fax
Status
Config
Misc
client.auth.logOut(token).then(/* ... */);
// or
await client.auth.logOut(token);
Voice
Video
Chat
Fax
Status
Config
Misc
client.auth.checkToken(token).then(valid);
// or
const valid = await client.auth.checkToken(token);
Config
client.auth.listTenants();
client.auth.createTenant(name);
client.auth.deleteTenant(uuid);
client.auth.createUser(username, password, firstname, lastname);
client.auth.addUserEmail(userUuid, email, main);
client.auth.addUserPolicy(userUuid, policyUuid);
client.auth.deleteUser();
client.auth.listUsers();
client.auth.listGroups();
client.auth.createPolicy(name, description, acl);
client.auth.listPolicies();
Log
import Wazo from '@wazo/sdk';
Wazo.IssueReporter.enable();
Wazo.IssueReporter.configureRemoteClient({
host: 'localhost', // fluentd http host
port: 9880, // fluentd http port
tag: 'name of your application,
level: 'trace', // Min log level to be sent
extra: {
// Extra info sent for every logs
user_uuid: '...',
},
});
Using the logger :
// Log with for category, this will send a `category` attribute in every logs for this logger.
const logger = Wazo.IssueReporter.loggerFor('my_category');
logger(logger.TRACE, 'my log');
// or simply
Wazo.IssueReporter.log(Wazo.IssueReporter.INFO, 'my log');
Voice
Video
Chat
Fax
Status
Config
Use Applicationd to construct your own communication features.
client.application.calls(applicationUuid); // list calls
client.application.hangupCall(applicationUuid, callId); // hangup a call
client.application.answerCall(applicationUuid, callId, context, exten, autoanswer); // answer a call
client.application.listNodes(applicationUuid); // list nodes
client.application.listCallsNodes(applicationUuid, nodeUuid); // list calls in a node
client.application.removeCallNodes(applicationUuid, nodeUuid, callId); // remove call from node (no hangup)
client.application.addCallNodes(applicationUuid, nodeUuid, callId); // add call in a node
client.application.playCall(applicationUuid, callId, language, uri); // play a sound into a call
Voice
Video
Chat
Fax
Status
Use Calld to directly control interactions. (Please note, ctidNg endpoint is deprecated but continues to work with old versions. Please update your code.)
client.calld.getConferenceParticipantsAsUser(conferenceId); // List participants of a conference the user is part of
client.calld.answerSwitchboardQueuedCall(switchboardUuid, callId);
client.calld.answerSwitchboardHeldCall(switchboardUuid, callId);
client.calld.cancelCall(callId);
client.calld.deleteVoicemail(voicemailId);
client.calld.fetchSwitchboardHeldCalls(switchboardUuid);
client.calld.fetchSwitchboardQueuedCalls(switchboardUuid);
client.calld.getConferenceParticipantsAsUser(conferenceId);
client.calld.getPresence(contactUuid); //deprecated use chatd in ctidNg, don't work with calld
client.calld.getStatus(lineUuid); //deprecated use chatd in ctidNg, don't work with calld
client.calld.holdSwitchboardCall(switchboardUuid, callId);
client.calld.listCalls();
client.calld.listMessages(participantUuid, limit);
client.calld.listVoicemails();
client.calld.makeCall(extension, fromMobile, lineId, allLines);
client.calld.sendFax(extension, fax, callerId);
client.calld.sendMessage(alias, msg, toUserId);
client.calld.relocateCall(callId, destination, lineId);
client.calld.updatePresence(presence);
Config
Use Confd to interact with configurations.
client.confd.listUsers();
client.confd.getUser(userUuid);
client.confd.getUserLineSip(userUuid, lineId);
client.confd.listApplications();
Misc
Use Dird to interact with directories.
client.dird.search(context: string, term: string, offset: number, limit: number);
client.dird.listPersonalContacts();
client.dird.addContact(newContact: NewContact);
client.dird.editContact(contact: Contact);
client.dird.deleteContact(contactUuid: UUID);
client.dird.listFavorites(context: string);
client.dird.markAsFavorite(source: string, sourceId: string);
client.dird.removeFavorite(source: string, sourceId: string);
Misc
Use Agentd to handle agent states
Legacy (all versions)
client.agentd.getAgent(agentNumber);
client.agentd.login(agentNumber, context, extension);
client.agentd.logout(agentNumber);
client.agentd.pause(agentNumber);
client.agentd.resume(agentNumber);
Log in with line ID only (engine version > 20.11 -- recommended)
client.agentd.loginWithLineId(lineId);
No-args methods (engine version >= 20.17 -- recommended)
client.agentd.getStatus();
client.agentd.staticLogout();
client.agentd.staticPause();
client.agentd.staticResume();
Voice
Misc
Use callLogd to interact with call logs.
client.callLogd.search(search, limit);
client.callLogd.listCallLogs(offset, limit);
client.callLogd.listCallLogsFromDate(from, number);
Chat
Status
Use chatd to send and retrieve chat messages and user statuses.
client.chatd.getContactStatusInfo(contactUuid: UUID);
client.chatd.getState(contactUuid: UUID);
client.chatd.getLineState(contactUuid: UUID);
client.chatd.getMultipleLineState(contactUuids: ?Array<UUID>);
client.chatd.getUserRooms();
client.chatd.updateState(contactUuid: UUID, state: string);
client.chatd.updateStatus(contactUuid: UUID, state: string, status: string);
client.chatd.createRoom(name: string, users: Array<ChatUser>);
client.chatd.getRoomMessages(roomUuid: string);
client.chatd.sendRoomMessage(roomUuid: string, message: ChatMessage);
client.chatd.getMessages(options: GetMessagesOptions);
Voice
Video
Chat
Fax
Status
Config
Misc
Use this generic method to request endpoints directly.
const requester = new ApiRequester({
server: 'stack.example.com', // Engine server
refreshTokenCallback: () => {}, // Called when the token is refreshed
clientId: 'my-id', // ClientId used for refreshToken
agent: null, // http(s).Agent instance, allows custom proxy, unsecured https, certificate etc.
token: null, // User token (can be defined later with requester.setToken()
});
// Retrieve personal contacts
const results = await requester.call('dird/0.1/personal');
This sample describes the very first steps to place a call using WebRTC.
import { WebRTCClient } from '@wazo/sdk'; // import the library
const session = await client.auth.logIn({ ... }); // log in
const client = new WebRTCClient({
displayName: 'From WEB',
host: 'stack.example.com',
websocketSip: 'other.url.com', // Allows to connect throught another URL than host (default to `host` is not set).
media: {
audio: boolean,
video: boolean | document.getElementById('video'), // pointing to a `<video id="video" />` element
localVideo: boolean | document.getElementById('video'), // pointing to a `<video id="video" />` element
}
}, session);
// eventName can be on the of events :
// - transport: `connected`, `disconnected`, `transportError`, `message`, `closed`, `keepAliveDebounceTimeout`
// - webrtc: `registered`, `unregistered`, `registrationFailed`, `invite`, `inviteSent`, `transportCreated`, `newTransaction`, `transactionDestroyed`, `notify`, `outOfDialogReferRequested`, `message`.
client.on('invite', (sipSession: SipSession, hasVideo: boolean, shouldAutoAnswer: boolean) => {
this.currentSipSession = sipSession;
// ...
});
// We have to wait to be registered to be able to make a call
await client.waitForRegister();
client.call('1234');
const config = {
displayName: '', // Display name sent in SIP payload
host: '', // Host where to connect
port: '', // Port of the host (default to `443`)
media: {
audio: boolean, // If we want to send audio
video: boolean | document.getElementById('video'), // pointing to a `<video id="video" />` element
localVideo: boolean | document.getElementById('video'), // pointing to a `<video id="video" />` element
},
iceCheckingTimeout: 1000, // Time allowed to retrieve ice candidates
log: {}, // @see https://sipjs.com/api/0.5.0/ua_configuration_parameters/#log
audioOutputDeviceId: null, // The audio output device id (when we want to send audio in another destination).
userAgentString: null, // Customize the User-Agent SIP header
heartbeatDelay: 1000, // Duration in ms between 2 heartbeat (default to 2000)
heartbeatTimeout: 5000, // Duration in ms when to consider that the Asterisk server is not responding (default to 5000)
maxHeartbeats: 4, // Number of heatbeat send each time we want to check connection (default to 3)
// When not passing session as second argument:
authorizationUser: '', // The SIP username
password: '', // The SIP user password
uri: '', // The SIP user identity
}
const uaConfigOverrides = {
peerConnectionOptions: {
iceServers = [
{urls: "stun:stun.example.com:443"}, // STUN server
{urls: "turn:turn.example.com:443", username: "login", credential: "secret" }, // TURN server
...
]
}
}
const client = new WebRTCClient(config, session, /* optional */ uaConfigOverrides);
Voice
Video
Chat
Use this method to dial a number.
client.call(number: string);
Use this method to be notified of an incoming call.
client.on('invite', (sipSession: SipSession) => {
this.currentSipSession = sipSession;
});
Use this method to pick up an incoming call.
client.answer(sipSession: SipSession);
Use this method to hangup a call (the call must have been already picked up)
client.hangup(sipSession: SipSession);
Use this method to deny an incoming call (Must not have been picked up already)
client.reject(sipSession: SipSession);
Use this method to mute yourself in a running call.
client.mute(sipSession: SipSession);
Use this method to unmute yourself in a running call.
client.unmute(sipSession: SipSession);
Use this method to put a running call on hold.
client.hold(sipSession: SipSession);
Use this method to resume a running call.
client.unhold(sipSession: SipSession);
Use this method to transfer a call to another target, without introduction
client.transfer(sipSession: SipSession, target: string);
Use this method to transfer a call to another target, but first introduce the caller to the transfer target. The transfer may be cancelled (hangup the transfer target) or completed (hangup the transfer initiator).
transfer = client.atxfer(sipSession: SipSession);
// Start the transfer to a phone number, starts a new SIP session in the process
transfer.init(target: string)
// Get the new SIP session to the target of the transfer
targetSession = transfer.newSession
// Complete the transfer.
// transfer.init(...) must be called first.
transfer.complete()
// Cancel the transfer.
// transfer.init(...) must be called first.
transfer.cancel()
Use this method to send the dual-tone multi-frequency from the phone keypad.
client.sendDTMF(sipSession: SipSession, tone: string);
client.message(destination: string, message: string);
Stores a value between 0 and 1, which can be used to on your audio element
phone.changeAudioOutputVolume(volume: number);
Stores a value between 0 and 1, which can be used to on your audio element
phone.changeAudioRingVolume(volume: number);
Use this method to put an end to an RTC connection.
client.close();
Higher level of abstraction to use the WebRtcClient
.
import { WebRTCClient, WebRTCPhone } from '@wazo/sdk';
const webRtcClient = new WebRTCClient({/* See above for parameters */});
const phone = new WebRTCPhone(
webRtcClient: WebRTCClient, // Instance of WebRTCClient
audioDeviceOutput: string, // The output device used to play audio
allowVideo: boolean, // Allow to send and receive video
audioDeviceRing, // The output device used to play ringtones
);
Voice
Video
Chat
Use this method to dial a number.
const callSession = await phone.makeCall(
number: string, // The number to dial
line: // Not used
enableVideo: boolean // Optional (default to false) when we want to make a video call
);
Use this method to stop a call
phone.hangup(
callSession: CallSession, // The callSession to stop
);
Use this method to accept (answer) an incoming call
phone.accept(
callSession: CallSession, // The callSession to accept
cameraEnabled?: boolean // Should we accept the call with video
);
Use this method to reject an incoming call
phone.reject(
callSession: CallSession // The callSession to reject
);
Use this method to put a running call on hold.
phone.hold(
callSession: CallSession, // The call session to put on hold
withEvent: boolean = true // Should the phone triggers event
);
Use this method to resume a running call.
phone.resume(callSession: CallSession);
Please note that phone.resume()
is the preferred method
phone.unhold(callSession: CallSession); // deprecated
Use this method to mute yourself in a running call.
phone.mute(
callSession: CallSession, // The call session to mute
withEvent: boolean = true // Should the phone triggers event
);
Use this method to unmute yourself in a running call.
phone.unmute(callSession: CallSession);
Use this method to mute your camera in a running call.
phone.turnCameraOff(callSession: CallSession);
Use this method to unmute your camera in a running call.
phone.turnCameraOn(callSession: CallSession);
Use this method to unmute yourself in a running call.
phone.sendKey(callSession: CallSession, tone: string);
Use this method to transfer a call directly to another extension, without introduction
phone.transfer(
callSession: CallSession, // The call session to transfer
target: string // The extension where to transfer to call
);
Use this method to transfer a call to another extension by allowing to speak with the other participant first and validate the transfer after that.
You have to run makeCall
first on the target to be able to confirm the transfer with this method.
phone.indirectTransfer(
callSession: CallSession, // The call session to transfer
target: string // The extension where to transfer to call
);
const screenShareStream: MediaStream = await phone.startScreenSharing({
audio: true,
video: true,
/* See webRtc media constraints */
});
phone.stopScreenSharing();
Voice
Video
Chat
Use this method to start an ad-hoc conference.
phone.startConference(participants: CallSession[]);
phone.addToConference(participant: CallSession);
phone.holdConference(participants: CallSession[]);
phone.resumeConference(participants: CallSession[]);
phone.muteConference(participants: CallSession[]);
phone.unmuteConference(participants: CallSession[]);
phone.removeFromConference(participants: CallSession[]);
phone.hangupConference(participants: CallSession[]);
Voice
Video
Chat
Sends a SIP REGISTER
payload
phone.register();
phone.isRegistered();
Sends a SIP UNREGISTER
payload
phone.unregister();
phone.changeAudioDevice(someDevice: string);
phone.changeRingDevice(someDevice: string);
phone.changeAudioInputDevice(someDevice: string, session: ?Inviter, force: ?boolean);
phone.changeVideoInputDevice(someDevice: string);
phone.hasAnActiveCall(): boolean;
phone.callCount(): number;
Sends a SIP MESSAGE in a session.
Use phone.currentSipSession
to retrieve the current sipSession
.
phone.sendMessage(
sipSession: SipSession = null, The sip session where to send to message
body: string, // The message to SEND
);
Disconnect the SIP webSocket transport.
phone.stop();
Sends a SIP OPTIONS
every X seconds, Y times and timeout after Z seconds.
See webrtcClient's heartbeatDelay
, heartbeatTimeout
, maxHeartbeats
, configuration.
phone.startHeartbeat();
phone.stopHeartbeat();
You can use the Wazo WebSocket to listen for real-time events (eg: receiving a chat message, a presential update...)
Voice
Video
Chat
Fax
Status
import { WebSocketClient } from '@wazo/sdk';
const ws = new WebSocketClient({
host: '', // wazo websocket host
token: '', // valid Wazo token
events: [''], // List of events you want to receive (use `['*']` as wildcard).
version: 2, // Use version 2 of the Wazo WebSocket protocol to be informed when the token will expire.
}, {
// see https://github.com/pladaria/reconnecting-websocket#available-options
});
ws.connect();
import { USERS_SERVICES_DND_UPDATED, AUTH_SESSION_EXPIRE_SOON } from '@wazo/sdk/lib/websocket-client';
// eventName can be on the of events here: http://documentation.wazo.community/en/stable/api_sdk/websocket.html
ws.on('eventName', (data: mixed) => {
});
ws.on(USERS_SERVICES_DND_UPDATED, ({ enabled }) => {
// Do something with the new do not disturb value.
});
ws.on(AUTH_SESSION_EXPIRE_SOON, (data) => {
// Called when the user's token will expire soon.
// You should refresh it at this point (eg: by using a refreshToken).
});
You can update a new token to avoid being disconnected when the old one will expire.
ws.updateToken(newToken: string);
ws.close();
As Webpack 5 dropped some polyfills, you have to add them manually:
yarn add -D assert buffer https-browserify url stream-http stream-browserify browserify-zlib process
If you have used create-react-app
to create your app, you can customize the Webpack configuration with react-app-rewired
:
yarn add -D react-app-rewired
Create a config-overrides.js
file :
const webpack = require('webpack');
module.exports = function override(config, env) {
config.resolve.fallback = {
...config.resolve.fallback,
assert: require.resolve("assert"),
buffer: require.resolve('buffer'),
https: require.resolve('https-browserify'),
url: require.resolve('url'),
http: require.resolve('stream-http'),
stream: require.resolve('stream-browserify'),
zlib: require.resolve('browserify-zlib'),
};
config.plugins.push(
new webpack.ProvidePlugin({
process: 'process/browser',
Buffer: ['buffer', 'Buffer'],
}),
);
config.module.rules.push({
test: /\.m?js/,
resolve: {
fullySpecified: false
}
})
return config;
}
Then edit in package.json
:
"scripts": {
// ...
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test",
"eject": "react-app-rewired eject"
// ...
},
Please refer to https://github.com/facebook/create-react-app/issues/11756 for more details.
FAQs
Wazo's JavaScript Software Development Kit.
The npm package @wazo/sdk receives a total of 199 weekly downloads. As such, @wazo/sdk popularity was classified as not popular.
We found that @wazo/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
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.