2factor
Advanced tools
Comparing version 1.0.4 to 1.0.5
{ | ||
"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) => { |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
218196
19
756
86
0
3
1