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

node-red-contrib-wazo-platform

Package Overview
Dependencies
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-red-contrib-wazo-platform - npm Package Compare versions

Comparing version 1.0.14 to 1.0.15

4

nodes/add_to_node.js

@@ -20,3 +20,3 @@ module.exports = function (RED) {

try {
const { ...callNode} = await node.client.addCallNodes(application_uuid, node.node_uuid, call_id);
const callNode = await node.client.addCallNodes(application_uuid, node.node_uuid, call_id);
node.log(`Add call to existing node ${node.node_uuid}`);

@@ -40,2 +40,2 @@ msg.payload.call_id = call_id;

}
};

@@ -33,2 +33,2 @@ module.exports = function (RED) {

}
};

@@ -26,3 +26,3 @@ module.exports = function (RED) {

callerId = msg.payload.call.displayed_caller_id_number || msg.payload.displayed_caller_id_number;
autoAnswer = node.auto_answer || msg.payload.auto_answer;;
autoAnswer = node.auto_answer || msg.payload.auto_answer;

@@ -32,3 +32,3 @@ if (call_id && application_uuid) {

try {
const { ...bridgeCall } = await node.client.bridgeCall(application_uuid, call_id, context, exten, autoAnswer, callerId);
const bridgeCall = await node.client.bridgeCall(application_uuid, call_id, context, exten, autoAnswer, callerId);
msg.payload.call_id = call_id;

@@ -59,3 +59,3 @@ msg.payload.applicaton_uuid = application_uuid;

return fetch(url, options).then(response => response.json()).then(data => data);
}
};

@@ -70,3 +70,3 @@ RED.httpAdmin.post('/wazo-platform/contexts', async (req, res) => {

try {
const { ...authentication } = await client.auth.refreshToken(req.body.refreshToken);
const authentication = await client.auth.refreshToken(req.body.refreshToken);
client.setToken(authentication.token);

@@ -78,3 +78,3 @@ try {

const url = `https://${req.body.host}:${req.body.port}/api/confd/1.1/contexts`;
const { ...trunks } = await listContexts(url, authentication.token);
const trunks = await listContexts(url, authentication.token);

@@ -97,2 +97,2 @@ res.json(trunks);

}
};

@@ -28,3 +28,3 @@ module.exports = function (RED) {

const url = `https://${node.conn.host}:${node.conn.port}/api/calld/1.0/applications/${application_uuid}/nodes`;
const { ...nodeCreated} = await createNodeAddCall(url, token, call_id);
const nodeCreated = await createNodeAddCall(url, token, call_id);
node_uuid = nodeCreated.uuid;

@@ -35,3 +35,3 @@ }

try {
const { ...call_user} = await initiateCallUser(url, token, node.user_uuid);
const call_user = await initiateCallUser(url, token, node.user_uuid);
node.log(`Call user ${node.user_uuid} to node ${node_uuid}`);

@@ -57,3 +57,3 @@ msg.payload.call_id = call_id;

user_uuid: user_uuid
}
};

@@ -68,6 +68,6 @@ const options = {

}
}
};
return fetch(url, options).then(response => response.json()).then(data => data);
}
};

@@ -86,3 +86,3 @@ // FIXME: Remove when SDK will be ready

return fetch(url, options).then(response => response.json()).then(data => data);
}
};

@@ -95,3 +95,3 @@ // FIXME: Remove when SDK will be ready

}]
}
};

@@ -106,6 +106,6 @@ const options = {

}
}
};
return fetch(url, options).then(response => response.json()).then(data => data);
}
};

@@ -120,6 +120,6 @@ RED.httpAdmin.post('/wazo-platform/users', async (req, res) => {

try {
const { ...auth } = await client.auth.refreshToken(req.body.refreshToken);
const auth = await client.auth.refreshToken(req.body.refreshToken);
client.setToken(auth.token);
try {
const { ...users } = await client.confd.listUsers();
const users = await client.confd.listUsers();
res.json(users);

@@ -140,2 +140,2 @@ }

}
};

@@ -24,4 +24,4 @@ module.exports = function (RED) {

try {
//const {...room } = await node.client.createRoom(room_name, [{uuid: user_uuid}, {uuid: bot_uuid}]);
const {...room } = await node.client.createRoom(room_name, [{uuid: user_uuid}]);
//const room = await node.client.createRoom(room_name, [{uuid: user_uuid}, {uuid: bot_uuid}]);
const room = await node.client.createRoom(room_name, [{uuid: user_uuid}]);
node.room_uuid = room.uuid;

@@ -34,3 +34,3 @@ return room.uuid;

}
}
};

@@ -49,7 +49,7 @@ const send_message = async (message) => {

type: "ChatMessage"
}
};
const result = await node.client.sendRoomMessage(node.room_uuid, data);
return result;
}
}
};

@@ -60,2 +60,2 @@ }

}
};

@@ -43,9 +43,7 @@ module.exports = function(RED) {

this.authenticate = async function() {
node.log(`Connection to ${node.host} to get token`);
try {
const check = await node.client.auth.checkToken(node.token);
if (check !== true) {
node.log(`Get a valid token`);
const { ...auth} = await node.client.auth.refreshToken(node.refreshToken, null, node.expiration);
node.log(`Connection to ${node.host} to get a valid token`);
const auth = await node.client.auth.refreshToken(node.refreshToken, null, node.expiration);
node.token = auth.token;

@@ -64,3 +62,4 @@ node.sessionUuid = auth.sessionUuid;

this.websocket = createClient(node);
node.setMaxListeners(0);
const websocket = createClient(node);

@@ -70,4 +69,5 @@ }

const createClient = async (node) => {
node.log(`Create websocket on ${node.host}`);
if (node.insecure) {
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0;
}

@@ -104,3 +104,3 @@

payload: message.data
}
};

@@ -136,3 +136,3 @@ node.emit('onmessage', msg);

}
}
};

@@ -151,3 +151,3 @@ // FIXME: Remove when SDK will be ready

return fetch(url, options).then(response => response.json()).then(data => data);
}
};

@@ -184,3 +184,3 @@ RED.httpAdmin.post('/wazo-platform/auth', async (req, res) => {

try {
const { ...authentication } = await client.auth.refreshToken(req.body.refreshToken);
const authentication = await client.auth.refreshToken(req.body.refreshToken);
client.setToken(authentication.token);

@@ -190,3 +190,3 @@

const url = `https://${req.body.host}:${req.body.port}/api/auth/0.1/users/me/tokens`;
const { ...refreshToken } = await listRefreshToken(url, authentication.token);
const refreshToken = await listRefreshToken(url, authentication.token);
res.json(refreshToken);

@@ -216,2 +216,2 @@ }

}
};

@@ -27,3 +27,3 @@ module.exports = function (RED) {

const url = `https://${conn.host}:${conn.port}/api/calld/1.0/applications/${application_uuid}/nodes`;
const { ...nodeCreated} = await createNodeAddCall(url, token, call_id);
const nodeCreated = await createNodeAddCall(url, token, call_id);
node.log(`Add call to node ${nodeCreated.uuid}`);

@@ -51,3 +51,3 @@ msg.payload.call_id = call_id;

}]
}
};

@@ -62,9 +62,9 @@ const options = {

}
}
};
return fetch(url, options).then(response => response.json()).then(data => data);
}
};
RED.nodes.registerType("wazo create_node", create_node);
}
};

@@ -18,3 +18,3 @@ module.exports = function (RED) {

try {
const { ...deleteNode} = await node.client.removeNode(application_uuid, node_uuid);
const deleteNode = await node.client.removeNode(application_uuid, node_uuid);
node.log(`Remove node ${node_uuid}`);

@@ -37,2 +37,2 @@ msg.payload.application_uuid = application_uuid;

}
};

@@ -69,6 +69,6 @@ module.exports = function (RED) {

const { ...authentication } = await client.auth.refreshToken(req.body.refreshToken);
const authentication = await client.auth.refreshToken(req.body.refreshToken);
client.setToken(authentication.token);
const { ...applications } = await client.confd.listApplications();
const applications = await client.confd.listApplications();

@@ -80,2 +80,2 @@ res.json(applications);

}
};

@@ -62,3 +62,3 @@ module.exports = function (RED) {

}
}
};

@@ -72,3 +72,3 @@ const getVoicemail = async (msg, voicemail_id, message_id, user_uuid) => {

getVoicemailRecording(msg, url, voicemail_id, message_id, token, node, user_uuid);
}
};

@@ -86,3 +86,3 @@ }

}
}
};

@@ -93,3 +93,3 @@ const chunks = [];

sendReq.on('data', chunk => chunks.push(Buffer.from(chunk))).on('end', () => {
const buffer = Buffer.concat(chunks);
let buffer = Buffer.concat(chunks);

@@ -112,3 +112,3 @@ if (node.base64) {

file: dest
}
};
node.send(msg);

@@ -129,6 +129,6 @@ } else {

}
};
RED.nodes.registerType("wazo fetch voicemail", fetch_voicemail);
}
};

@@ -26,2 +26,2 @@ module.exports = function (RED) {

RED.nodes.registerType("wazo hangup", hangup);
}
};

@@ -32,2 +32,2 @@ module.exports = function (RED) {

}
};

@@ -17,3 +17,3 @@ module.exports = function (RED) {

try {
const { ...callsNode } = await node.client.listCallsNodes(application_uuid, node_uuid);
const callsNode = await node.client.listCallsNodes(application_uuid, node_uuid);
node.log(`List calls node ${node_uuid}`);

@@ -36,2 +36,2 @@ msg.payload.application_uuid = application_uuid;

}
};

@@ -52,3 +52,3 @@ module.exports = function (RED) {

return fetch(url, options).then(response => response.json()).then(data => data);
}
};

@@ -70,3 +70,3 @@ RED.httpAdmin.post('/wazo-platform/moh', async function(req, res) {

const url = `https://${req.body.host}:${req.body.port}/api/confd/1.1/moh`;
const { ...moh } = await confdListMoh(url, auth.token);
const moh = await confdListMoh(url, auth.token);
res.json(moh);

@@ -87,2 +87,2 @@ }

}
};

@@ -33,2 +33,2 @@ module.exports = function (RED) {

}
};

@@ -20,3 +20,3 @@ module.exports = function (RED) {

try {
const { ...new_call_node} = await node.client.addNewCallNodes(application_uuid, node_uuid, context, exten, autoAnswer);
const new_call_node = await node.client.addNewCallNodes(application_uuid, node_uuid, context, exten, autoAnswer);
msg.payload.application_uuid = application_uuid;

@@ -39,2 +39,2 @@ msg.payload.node_uuid = node_uuid;

}
};

@@ -29,8 +29,8 @@ module.exports = function (RED) {

variables: msg.payload.variables || {}
}
};
const url = `https://${node.conn.host}:${node.conn.port}/api/calld/1.0/applications/${application_uuid}/calls`;
const token = await node.conn.authenticate();
const { ...new_call} = await createNewCall(url, token, call);
const new_call = await createNewCall(url, token, call);
msg.payload.application_uuid = application_uuid;
msg.payload.call_id = new_call.id;;
msg.payload.call_id = new_call.id;
msg.payload.data = new_call;

@@ -58,9 +58,9 @@ node.send(msg);

}
}
};
return fetch(url, options).then(response => response.json()).then(data => data);
}
};
RED.nodes.registerType("wazo new_call", new_call);
}
};

@@ -27,3 +27,3 @@ module.exports = function (RED) {

catch(err) {
node.error(err)
node.error(err);
throw err;

@@ -37,2 +37,2 @@ }

}
};

@@ -31,3 +31,3 @@ module.exports = function (RED) {

}
msg.payload['user_uuid'] = user_uuid;
msg.payload.user_uuid = user_uuid;
node.send(msg);

@@ -38,3 +38,3 @@ }

const setNodeStatus = (state, status) => {
node.status({fill:"blue", shape:"dot", text: `state: ${state} - status: ${status}`})
node.status({fill:"blue", shape:"dot", text: `state: ${state} - status: ${status}`});
};

@@ -46,3 +46,3 @@

setNodeStatus(presence.state, presence.status);
}
};

@@ -59,3 +59,3 @@ const changeState = async (user_uuid, state) => {

}
}
};

@@ -72,3 +72,3 @@ const changeStatus = async (user_uuid, state, status) => {

}
}
};

@@ -80,2 +80,2 @@ initState();

}
};

@@ -26,2 +26,2 @@ module.exports = function (RED) {

RED.nodes.registerType("wazo progress", progress);
}
};

@@ -16,3 +16,3 @@ module.exports = function (RED) {

if (call_id && application_uuid && node_uuid) {
const { ...result } = await node.client.removeCallNodes(application_uuid, node_uuid, call_id);
const result = await node.client.removeCallNodes(application_uuid, node_uuid, call_id);
node.log('Remove call from node');

@@ -29,2 +29,2 @@ msg.payload.call_id = call_id;

RED.nodes.registerType("wazo remove_call", remove_call);
}
};

@@ -20,2 +20,3 @@ module.exports = function (RED) {

const endpoint = msg.payload.endpoint;
const query = msg.payload.query;
const body = msg.payload.body;

@@ -27,3 +28,3 @@ const url = `https://${node.conn.host}:${node.conn.port}/api/${node.serviceName}/${version}/${endpoint}`;

const token = await node.conn.authenticate();
const result = await apiRequest(url, method, token, body);
const result = await apiRequest(url, method, token, query, body);
msg.payload = result;

@@ -36,3 +37,3 @@ node.send(msg);

const apiRequest = (url, method, token, body) => {
const apiRequest = (url, method, token, query, body) => {
const options = {

@@ -43,2 +44,3 @@ method: method,

'content-type': 'application/json',
'accept': 'application/json',
'X-Auth-Token': token

@@ -49,7 +51,15 @@ }

if (body) {
options['body'] = JSON.stringify(body);
options.body = JSON.stringify(body);
}
return fetch(url, options).then(response => response.json()).then(data => data);
}
return fetch(url, options).then(response => {
if (response.status >= 400) {
return response.statusText;
}
else if (response.status >= 200 && response.status < 300) {
return response.json();
}
}).then(data => data);
};

@@ -73,2 +83,2 @@ RED.httpAdmin.get('/wazo-platform/service', (req, res) => {

}
};

@@ -35,2 +35,2 @@ module.exports = function (RED) {

}
};

@@ -24,3 +24,3 @@ module.exports = function (RED) {

catch(err) {
node.error(err)
node.error(err);
throw err;

@@ -34,2 +34,2 @@ }

}
};

@@ -26,2 +26,2 @@ module.exports = function (RED) {

RED.nodes.registerType("wazo stop_progress", stop_progress);
}
};

@@ -28,5 +28,5 @@ module.exports = function (RED) {

if (data.registered) {
node.status({fill:"green", shape:"dot", text: `register - calls: ${data.current_call_count}`})
node.status({fill:"green", shape:"dot", text: `register - calls: ${data.current_call_count}`});
} else {
node.status({fill:"red", shape:"dot", text: `unregister - calls: ${data.current_call_count}`})
node.status({fill:"red", shape:"dot", text: `unregister - calls: ${data.current_call_count}`});
}

@@ -43,3 +43,3 @@ };

});
}
};

@@ -61,3 +61,3 @@ initListTrunks();

return fetch(url, options).then(response => response.json()).then(data => data);
}
};

@@ -72,3 +72,3 @@ RED.httpAdmin.post('/wazo-platform/trunks', async function(req, res) {

try {
const { ...auth } = await client.auth.refreshToken(req.body.refreshToken);
const auth = await client.auth.refreshToken(req.body.refreshToken);
client.setToken(auth.token);

@@ -80,3 +80,3 @@ try {

const url = `https://${req.body.host}:${req.body.port}/api/confd/1.1/trunks`;
const { ...trunks } = await confdListTrunks(url, auth.token);
const trunks = await confdListTrunks(url, auth.token);
res.json(trunks);

@@ -97,2 +97,2 @@ }

}
};

@@ -33,2 +33,2 @@ module.exports = function (RED) {

}
};

@@ -33,2 +33,2 @@ module.exports = function (RED) {

}
};

@@ -61,3 +61,3 @@ module.exports = function (RED) {

});
}
};

@@ -102,7 +102,7 @@ const url = `https://${this.conn.host}:${this.conn.port}/api/calld/1.0/voicemails/${this.voicemail_id}`;

try {
const { ...authentication } = await client.auth.refreshToken(req.body.refreshToken);
client.setToken(authentication.token);
const auth = await client.auth.refreshToken(req.body.refreshToken);
client.setToken(auth.token);
try {
const url = `https://${req.body.host}:${req.body.port}/api/confd/1.1/voicemails`;
const { ...voicemails } = await listVoicemails(url, authentication.token);
const voicemails = await listVoicemails(url, auth.token);
res.json(voicemails);

@@ -123,2 +123,2 @@ }

}
};

@@ -64,2 +64,2 @@ module.exports = function (RED) {

RED.nodes.registerType("wazo websocket", websocket);
}
};
{
"name": "node-red-contrib-wazo-platform",
"version": "1.0.14",
"version": "1.0.15",
"description": "Node Red module for the Wazo Platform API",

@@ -5,0 +5,0 @@ "main": "index.js",

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