1.0.0 • Published 2 years ago
psms-client v1.0.0
PSMS Client
PSMS Client is the client for PSMS(Private SMS), which is a lightweight server connected physically to a GSM board for creating your own secure SMS API.
Installation
npm install psms-client
Usage
The client is extremely simple and wasn't build for error-checking, as I've mostly created this project in one night to both skirt the costs of services like Twilio, have personal phone numbers that are unblocked, and for fun. If the project gets traction, I'll consider rewriting it to have callbacks from the main server unique to each emitted event.
All-inclusive example
const PSMSClient = require('psms-client');
const fs = require('fs');
let publicKey = fs.readFileSync('./public.pem');//Public key generated by the server
let client = new PSMSClient("127.0.0.1", 8080, publicKey, "SomeSecurePhrase");
client.open(() => {
console.log("Ready for messaging and receiving");
client.on('onNewMessage', (data) => {
console.log("Got new message: ");
console.log(data);
});
client.on('onStoredMessages', (data) => {//Received event after calling requestStoredMessages
console.log("Received stored messages: ");
console.log(data);
});
console.log("Asking for stored messages, all");
client.requestStoredMessages();//Also can take in an integer parameter to only receive X last messages
client.sendSMS("+1323XXXXXXX", "Howdy!");//Send an SMS
});
The open callback will fire once the PSMSClient has connected to the PSMS Server and sent the encrypted handshake details. By default, the server disconnects any clients that have not authenticated themselves < 5 seconds.
1.0.0
2 years ago