Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Simple node library for sending transactional/otp/promotional SMS in India using the 2factor.in APIs
NodeJS module for using the 2factor.in APIs for sending transactional and OTP sms in india
To install the library use
$ npm i 2factor --save
To install the library and save it as a dependency in package.json use
$ npm i 2factor --save
The module exports a constructor that returns new TwoFactor instances.
The constructor expects the api key
to be passed to it.
const TwoFactor = new (require('2factor'))(<your api key>)
Note - You shouldn't store your API key in your code or in text files you will commit to your repositories. Ideally, you want to use environment variables as given below -
let APIKEY = process.env.my_api_key || ''
if (APIKEY === '') {
throw new Error('Missing 2Factor api key in environment')
}
const TwoFactor = new(require('2factor'))(APIKEY)
The balance()
method takes a single string parameter for the type of balance you want to retrieve.
To get all balances, specify type as ALL
or omit the parameter.
TwoFactor.balance().then((response) => {
console.log(response)
}, (error) => {
console.log(error)
})
Simply call the sendOTP
function with a phone number and options object containing the
otp and template fields. It will return a Promise
that resolves with the sessionId
or reject with the reason for failure.
TwoFactor.sendOTP(<phone number>, {otp: <otp code>, template: <template_name>}).then((sessionId) => {
console.log(sessionId)
}, (error) => {
console.log(error)
})
Call verifyOTP()
with the sessionId returned from the sendOTP
function and the otp
you want to check. If the otp was correct, it will resolve with a success message else
it will reject with the response from 2Factor.in
TwoFactor.verifyOTP(sessionId, otp).then((response) => {
console.log(response)
}, (error) => {
console.log(error)
})
TwoFactor.sendTemplate('123456789', 'YOUR SENDER ID', ['VAR1','VAR2', 'VAR3']).then((response) => {
console.log(response)
}, (error) => {
console.log(error)
})
TwoFactor.sendTemplate(['123456789','987654321'], 'YOUR SENDER ID', ['VAR1','VAR2', 'VAR3']).then((response) => {
console.log(response)
}, (error) => {
console.log(error)
})
Hanut Singh Gusain hanutsingh@gmail.com [http://www.hanutsingh.in]
FAQs
Simple node library for sending transactional/otp/promotional SMS in India using the 2factor.in APIs
We found that 2factor demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.