Socket
Socket
Sign inDemoInstall

2factor

Package Overview
Dependencies
47
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.4 to 1.0.5

.nyc_output/09a20652-1a9f-491f-87b9-2aa86665888a.json

8

package.json
{
"name": "2factor",
"version": "1.0.4",
"version": "1.0.5",
"description": "Simple node library for sending transactional/otp/promotional SMS in India using the 2factor.in APIs",

@@ -11,3 +11,4 @@ "main": "index.js",

"test": "mocha tests",
"test-module": "set APIKEY=<REPLACE WITH API KEY> && set TESTPHONE=<PHONE TO USE AS RECIPIENT> && mocha tests"
"test-module": "set APIKEY=<REPLACE WITH API KEY> && set TESTPHONE=<PHONE TO USE AS RECIPIENT> && mocha tests",
"coverage": "nyc mocha tests"
},

@@ -43,3 +44,4 @@ "repository": {

"chai": "^4.1.2",
"mocha": "^5.1.1"
"mocha": "^5.1.1",
"nyc": "^13.1.0"
},

@@ -46,0 +48,0 @@ "dependencies": {

@@ -15,8 +15,19 @@ # 2factor-node

## Usage
Include 2Factor in a script
The module exports a constructor that returns new TwoFactor instances.
The constructor expects the `api key` to be passed to it.
~~~~
const TwoFactor = require('2factor')
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)
~~~~
To get your balance -
### To get your balance -
The `balance()` method takes a single string parameter for the type of balance you want to retrieve.

@@ -32,3 +43,3 @@ To get all balances, specify type as `ALL` or omit the parameter.

To send an sms otp -
### To send an sms otp -
Simply call the `sendOTP` function with a phone number and options object containing the

@@ -45,3 +56,3 @@ otp and template fields. It will return a `Promise` that resolves with the sessionId

To verify an sms otp -
### To verify an sms otp -
Call `verifyOTP()` with the sessionId returned from the `sendOTP` function and the otp

@@ -58,3 +69,3 @@ you want to check. If the otp was correct, it will resolve with a success message else

To send a template SMS to a single user
### To send a template SMS to a single user
~~~~

@@ -68,3 +79,3 @@ TwoFactor.sendTemplate('123456789', 'YOUR SENDER ID', ['VAR1','VAR2', 'VAR3']).then((response) => {

To send a template SMS to a single user
### To send a template SMS to a single user
~~~~

@@ -71,0 +82,0 @@ TwoFactor.sendTemplate(['123456789','987654321'], 'YOUR SENDER ID', ['VAR1','VAR2', 'VAR3']).then((response) => {

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc