Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
The documentation for the TNZ API can be found here.
tnzapi
uses a modified version of Semantic Versioning for all changes. See this document for details.
This library supports the following NodeJS implementations:
Install from npm using npm, a package manager for NodeJS.
npm i tnzapi
You may need to run the above commands with sudo
.
Getting started with the TNZ API couldn't be easier. Create a
Client
and you're ready to go.
The TNZAPI
needs your TNZ API credentials. You can either pass these
directly to the constructor (see the code below) or via environment variables.
const TNZAPI = require('tnzapi');
const client = new TNZAPI({
"AuthToken": "[Your Auth Token]"
});
...
Send SMS/Email/Voice/Fax through tnzapi
library.
const TNZAPI = require('tnzapi');
const client = new TNZAPI({
"AuthToken": "[Your Auth Token]"
});
var callback = function(data) {
console.log("Response: ",JSON.stringify(data, null, " "));
};
client.Messaging.SMS.SendMessage({
Reference: "Test", // Optional
Message: "Test SMS", // SMS Message
Destinations: [ // SMS Recipients
{ Recipient: "+64211111111" },
{ Recipient: "+64222222222" }
]
}).then(callback); // Send Message
const TNZAPI = require('tnzapi');
const client = new TNZAPI({
"AuthToken": "[Your Auth Token]"
});
var callback = function(data) {
console.log("Response: ",JSON.stringify(data, null, " "));
};
client.Messaging.Email.SendMessage({
FromEmail: "from@test.com", // Optional : Sets From Email Address - leave blank to use your api username as email sender
EmailSubject: "Test Email", // Email Subject
MessagePlain: "Test Email Body", // Email Body
Destinations: [ // Email Recipients
{ Recipient: "email.one@test.com" },
{ Recipient: "email.two@test.com" }
]
}).then(callback); // Send Message
const TNZAPI = require('tnzapi');
const client = new TNZAPI({
"AuthToken": "[Your Auth Token]"
});
var callback = function(data) {
console.log("Response:",JSON.stringify(data, null, " "));
};
client.Messaging.Fax.SendMessage({
Reference: "Test", // Optional
Destinations: [ // Fax Numbers
{ Recipient:"+6491111111" },
{ Recipient:"+6492222222" }
],
Attachments: [
"D:/File1.pdf"
]
}).then(callback);
const TNZAPI = require('tnzapi');
const client = new TNZAPI({
"AuthToken": "[Your Auth Token]"
});
var callback = function(data) {
console.log("Response:",JSON.stringify(data, null, " "));
}
client.Messaging.TTS.SendMessage({
MessageToPeople: "Hi there!", // Message to play
Destinations: [ // Recipients
{ Recipient: "+6491111111" },
{ Recipient: "+6492222222" }
]
}).then(callback);
const TNZAPI = require('tnzapi');
const client = new TNZAPI({
"AuthToken": "[Your Auth Token]"
});
var callback = function(data) {
console.log("Response:",JSON.stringify(data, null, " "));
};
client.Messaging.Voice.SendMessage({
Destinations: [ // Phone numbers to call
{ Recipient: "+6491111111" },
{ Recipient: "+6492222222" }
],
// Message to play - WAV format, 16-bit, 8000hz recommended
VoiceFiles: [
{
Name: "MessageToPeople",
File: "D:/File1.wav"
}
]
}).then(callback);
Retrieve your message status using tnzapi
library.
const TNZAPI = require('tnzapi');
const client = new TNZAPI({
AuthToken: "[Your Auth Token]" // Auth Token
});
var callback = function(data) {
console.log("Response:",JSON.stringify(data, null, " "));
}
client.Reports.Status.Poll({
MessageID: "ID123456", // MessageID generated from system OR your message ID if specified
}).then(callback);
const TNZAPI = require('tnzapi');
const client = new TNZAPI({
AuthToken: "[Your Auth Token]" // Auth Token
});
request.Poll(callback);
var callback = function(data) {
console.log("Response:",JSON.stringify(data, null, " "));
}
client.Reports.SMSReply.Poll({
MessageID: "ID123456", // MessageID generated from system OR your message ID if specified
Page: 1 // Current location
}).then(callback);
const TNZAPI = require('tnzapi');
const client = new TNZAPI({
AuthToken: "[Your Auth Token]" // Auth Token
});
var callback = function(data) {
console.log("Response:",JSON.stringify(data, null, " "));
}
client.Reports.SMSReceived.Poll({
TimePeriod: 1440 // Return results from the last x minutes
RecordsPerPage: 10,
Page: 1
}).then(callback);
Amend your message using tnzapi
library.
const TNZAPI = require('tnzapi');
const client = new TNZAPI({
AuthToken: "[Your Auth Token]" // Auth Token
});
var callback = function(data) {
console.log("Response:",JSON.stringify(data, null, " "));
}
client.Actions.Abort.SendRequest({
MessageID: "ID123456" // MessageID generated from system OR your message ID if specified
}).then(callback);
const TNZAPI = require('tnzapi');
const client = new TNZAPI({
AuthToken: "[Your Auth Token]" // Auth Token
});
var callback = function(data) {
console.log("Response:",JSON.stringify(data, null, " "));
}
client.Actions.Resubmit.SendRequest({
MessageID: "ID123456", // MessageID generated from system OR your message ID if specified
}).then(callback);
const TNZAPI = require('tnzapi');
const client = new TNZAPI({
AuthToken: "[Your Auth Token]" // Auth Token
});
var callback = function(data) {
console.log("Response:",JSON.stringify(data, null, " "));
}
client.Actions.Reschedule.SendRequest({
MessageID: "ID123456", // MessageID generated from system OR your message ID if specified
SendTime: "2023-09-01T00:00" // New Date/Time
}).then(callback);
const TNZAPI = require('tnzapi');
const client = new TNZAPI({
AuthToken: "[Your Auth Token]" // Auth Token
});
var callback = function(data) {
console.log("Response:",JSON.stringify(data, null, " "));
}
client.Actions.Pacing.SendRequest({
MessageID: "ID123456", // MessageID generated from system OR your message ID if specified
NumberOfOperators: 1 // No of operators
}).then(callback);
Manage your contacts using tnzapi
library.
const TNZAPI = require('tnzapi');
const client = new TNZAPI({
AuthToken: "[Your Auth Token]" // Auth Token
});
var callback = function(data) {
console.log("Response:",JSON.stringify(data, null, " "));
}
client.Addressbook.Contact.List({
RecordsPerPage: 10,
Page: 1
}).then(callback);
const TNZAPI = require('tnzapi');
const client = new TNZAPI({
AuthToken: "[Your Auth Token]" // Auth Token
});
var callback = function(data) {
console.log("Response:",JSON.stringify(data, null, " "));
}
client.Addressbook.Contact.Detail({
ContactID: "[Contact ID]"
}).then(callback);
const TNZAPI = require('tnzapi');
const client = new TNZAPI({
AuthToken: "[Your Auth Token]" // Auth Token
});
var callback = function(data) {
console.log("Response:",JSON.stringify(data, null, " "));
}
client.Addressbook.Contact.Create({
Title: "Mr",
Company: "TNZ Group",
FirstName: "First",
LastName: "Last",
MobilePhone: "+6421000001",
ViewBy: "Account",
EditBy: "Account"
}).then(callback);
const TNZAPI = require('tnzapi');
const client = new TNZAPI({
AuthToken: "[Your Auth Token]" // Auth Token
});
var callback = function(data) {
console.log("Response:",JSON.stringify(data, null, " "));
}
client.Addressbook.Contact.Update({
ContactID: "[Contact ID]",
Attention: "Test Attention"
Title: "Mr",
Company: "TNZ Group",
FirstName: "First",
LastName: "Last",
MobilePhone: "+64212223333",
ViewPublic: "Account",
EditPublid: "Account"
}).then(callback);
const TNZAPI = require('tnzapi');
const client = new TNZAPI({
AuthToken: "[Your Auth Token]" // Auth Token
});
var callback = function(data) {
console.log("Response:",JSON.stringify(data, null, " "));
}
client.Addressbook.Contact.Delete({
ContactID: "[Contact ID]"
}).then(callback);
Manage your contact group relationship using tnzapi
library.
const TNZAPI = require('tnzapi');
const client = new TNZAPI({
AuthToken: "[Your Auth Token]" // Auth Token
});
var callback = function(data) {
console.log("Response:",JSON.stringify(data, null, " "));
}
client.Addressbook.ContactGroup.List({
ContactID: "[Contact ID]",
RecordsPerPage: 10,
Page: 1
}).then(callback);
const TNZAPI = require('tnzapi');
const client = new TNZAPI({
AuthToken: "[Your Auth Token]" // Auth Token
});
var callback = function(data) {
console.log("Response:",JSON.stringify(data, null, " "));
}
client.Addressbook.ContactGroup.Detail({
ContactID: "[Contact ID]",
GroupCode: "[Group Code]"
}).then(callback);
const TNZAPI = require('tnzapi');
const client = new TNZAPI({
AuthToken: "[Your Auth Token]" // Auth Token
});
var callback = function(data) {
console.log("Response:",JSON.stringify(data, null, " "));
}
client.Addressbook.ContactGroup.Create({
ContactID: "[Contact ID]",
GroupCode: "[Group Code]"
}).then(callback);
const TNZAPI = require('tnzapi');
const client = new TNZAPI({
AuthToken: "[Your Auth Token]" // Auth Token
});
var callback = function(data) {
console.log("Response:",JSON.stringify(data, null, " "));
}
client.Addressbook.ContactGroup.Delete({
ContactID: "[Contact ID]",
GroupCode: "[Group Code]"
}).then(callback);
Manage your group using tnzapi
library.
const TNZAPI = require('tnzapi');
const client = new TNZAPI({
AuthToken: "[Your Auth Token]" // Auth Token
});
var callback = function(data) {
console.log("Response:",JSON.stringify(data, null, " "));
}
client.Addressbook.Group.List({
RecordsPerPage: 10,
Page: 1
}).then(callback);
const TNZAPI = require('tnzapi');
const client = new TNZAPI({
AuthToken: "[Your Auth Token]" // Auth Token
});
var callback = function(data) {
console.log("Response:",JSON.stringify(data, null, " "));
}
client.Addressbook.Group.Detail({
GroupCode: "[Group Code]"
}).then(callback);
const TNZAPI = require('tnzapi');
const client = new TNZAPI({
AuthToken: "[Your Auth Token]" // Auth Token
});
var callback = function(data) {
console.log("Response:",JSON.stringify(data, null, " "));
}
client.Addressbook.Group.Create({
GroupName: "Test Group",
ViewEditBy: "Account"
}).then(callback);
const TNZAPI = require('tnzapi');
const client = new TNZAPI({
AuthToken: "[Your Auth Token]" // Auth Token
});
var callback = function(data) {
console.log("Response:",JSON.stringify(data, null, " "));
}
client.Addressbook.Group.Update({
GroupCode: "[Group Code]",
GroupName: "Test Group 123",
SubAccount: "Test",
ViewEditBy: "Account"
}).then(callback);
const TNZAPI = require('tnzapi');
const client = new TNZAPI({
AuthToken: "[Your Auth Token]" // Auth Token
});
var callback = function(data) {
console.log("Response:",JSON.stringify(data, null, " "));
}
client.Addressbook.Group.Delete({
GroupCode: "[Group Code]"
}).then(callback);
Manage your group contact relationship using tnzapi
library.
const TNZAPI = require('tnzapi');
const client = new TNZAPI({
AuthToken: "[Your Auth Token]" // Auth Token
});
var callback = function(data) {
console.log("Response:",JSON.stringify(data, null, " "));
}
client.Addressbook.GroupContact.List({
GroupCode: "[Group Code]",
RecordsPerPage: 10,
Page: 1
}).then(callback);
const TNZAPI = require('tnzapi');
const client = new TNZAPI({
AuthToken: "[Your Auth Token]" // Auth Token
});
var callback = function(data) {
console.log("Response:",JSON.stringify(data, null, " "));
}
client.Addressbook.ContactGroup.Create({
ContactID: "[Contact ID]",
GroupCode: "[Group Code]"
}).then(callback);
const TNZAPI = require('tnzapi');
const client = new TNZAPI({
AuthToken: "[Your Auth Token]" // Auth Token
});
var callback = function(data) {
console.log("Response:",JSON.stringify(data, null, " "));
}
client.Addressbook.GroupContact.Create({
GroupCode: "[Group Code]",
ContactID: "[Contact ID]"
}).then(callback);
const TNZAPI = require('tnzapi');
const client = new TNZAPI({
AuthToken: "[Your Auth Token]" // Auth Token
});
var callback = function(data) {
console.log("Response:",JSON.stringify(data, null, " "));
}
client.Addressbook.GroupContact.Delete({
GroupCode: "[Group Code]",
ContactID: "[Contact ID]"
}).then(callback);
If you need help installing or using the library, please check the TNZ Contact if you don't find an answer to your question.
FAQs
Node.js Library for TNZ Group REST API
The npm package tnzapi receives a total of 925 weekly downloads. As such, tnzapi popularity was classified as not popular.
We found that tnzapi 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.