Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wazo/sdk

Package Overview
Dependencies
Maintainers
5
Versions
596
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wazo/sdk

Wazo's JavaScript Software Development Kit.

  • 0.4.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
213
increased by23.84%
Maintainers
5
Weekly downloads
 
Created
Source

Wazo's JavaScript Software Development Kit

npm version Greenkeeper badge

The Wazo JavaScript Software Development Kit is an API wrapper making it easy for you to communicate with your Wazo server. It allows you to add Wazo functionalities to any JavaScript application you are developing.

Usage

Install / Add

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

Content Delivery Networks

Alternatively, you may load the Wazo SDK from a CDN. Use one of the following Content Delivery Networks:

UNPKG
<script src="https://unpkg.com/@wazo/sdk"></script>
jsDelivr
<script src="https://cdn.jsdelivr.net/npm/@wazo/sdk"></script>

Require / Import

Depending on your preference, you may require or add the Wazo SDK to your own client application one of the following ways:

  • const { WazoApiClient } = require('@wazo/sdk');
  • import { WazoApiClient } from '@wazo/sdk';

Init

const client = new WazoApiClient({
  server: 'demo.wazo.community', // required string
  agent: null // http(s).Agent instance, allows custom proxy, unsecured https, certificate etc.
});

Log In

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
}).then(/* undefined if login failed, or : */{
  metadata: {
    username,
    uuid_tenant_uuid,
    xivo_user_uuid,
    groups,
    xivo_uuid,
    tenants: [{ uuid }],
    auth_id
  },
  token, // should be used for other request
  acls,
  utc_expires_at,
  xivo_uuid,
  issued_at,
  utc_issued_at,
  auth_id,
  expires_at,
  xivo_user_uuid
});
// or
const result = await client.auth.login(/* ... */);

Log Out

client.auth.logOut(token).then(/* ... */);
// or
await client.auth.logOut(token);

Check token

client.auth.checkToken(token).then(valid);
// or
const valid = await client.auth.checkToken(token);

Other auth methods

client.auth.listTenants(token);
client.auth.createTenant(token, name);
client.auth.deleteTenant(token, uuid);
client.auth.listUsers(token);
client.auth.listGroups(token);
client.auth.listPolicies(token);

Application

client.application.calls(token, applicationUuid); // list calls
client.application.hangupCall(token, applicationUuid, callId); // hangup a call
client.application.answerCall(token, applicationUuid, callId, context, exten, autoanswer);  // answer a call
client.application.listNodes(token, applicationUuid); // list nodes
client.application.listCallsNodes(token, applicationUuid, nodeUuid); // list calls in a node
client.application.removeCallNodes(token, applicationUuid, nodeUuid, callId); // remove call from node (no hangup)
client.application.addCallNodes(token, applicationUuid, nodeUuid, callId); // add call in a node
client.application.playCall(token, applicationUuid, callId, language, uri); // play a sound into a call

Confd

client.confd.listUsers(token);
client.confd.getUser(token, userUuid);
client.confd.getUserLineSip(token, userUuid, lineId);
client.confd.listApplications(token);

Accessd

client.accessd.listSubscriptions(token);
client.accessd.createSubscription(token, { productSku, name, startDate, contractDate, autoRenew, term });
client.accessd.getSubscription(token, uuid);
client.accessd.listAuthorizations(token);
client.accessd.getAuthorization(token, uuid);

WebRTCPhone

import { WazoWebRTCClient } from '@wazo/sdk';

const config = {
  wsServer: 'wss://path.to/asterisk/ws',
  displayName: 'My Display Name',
  authorizationUser: 'line username',
  password: 'line password',
  uri: 'user@server.com',
  media: {
    audio: document.getElementById('audio'), // Pointing to a `<audio id="audio" />` element
    video: document.getElementById('video'), // optional, pointing to a `<video id="video" />` element
    localVideo: document.getElementById('local-video') // optional, pointing to a `<video id="local-video" />` element
  }
};

const phone = new WazoWebRTCClient(config, callback);
// eventName can be on the of events here: https://sipjs.com/api/0.11.0/simple/#events
// You can also use a wildcard: phone.on('*', (event, eventName) => {}) to catch all events
phone.on('eventName', (event) => {
});

phone.call('1234');

Wazo Websocket

import { WazoWebSocketClient } from '@wazo/sdk';

const ws = new WazoWebSocket({
  host, // wazo websocket host
  token, // valid Wazo token
});

// eventName can be on the of events here: http://documentation.wazo.community/en/stable/api_sdk/websocket.html
// You can also use a wildcard: ws.on('*', (event, eventName) => {}) to catch all events
ws.on('eventName', (event) => {
});

ws.connect();

FAQs

Package last updated on 08 Oct 2018

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc