two-auth
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -10,11 +10,11 @@ // Takes in a userID and phone number associated with that user | ||
return new Promise((resolve, reject) => { | ||
if (typeof phone !== 'string') { | ||
reject(new Error('typeof phone must be string')); | ||
if (typeof phone !== "string") { | ||
reject(new Error("typeof phone must be string")); | ||
} | ||
if (phone.substring(0, 2) !== '+1') { | ||
reject(new Error('phone must be string formatted as such: +1XXXXXXXXXX')); | ||
if (phone.substring(0, 2) !== "+1") { | ||
reject(new Error("phone must be string formatted as such: +1XXXXXXXXXX")); | ||
} | ||
client.verify.services | ||
.create({ friendlyName: `${appName}` }) | ||
.then((service) => { | ||
.then(service => { | ||
const { sid } = service; | ||
@@ -24,8 +24,8 @@ TwoAuthUser.create({ | ||
sid, | ||
phone, | ||
phone | ||
}) | ||
.then((user) => { | ||
.then(user => { | ||
resolve(user); | ||
}) | ||
.catch((err) => { | ||
.catch(err => { | ||
reject(err); | ||
@@ -32,0 +32,0 @@ }); |
42
index.js
@@ -21,4 +21,22 @@ const twilio = require("twilio"); | ||
const connect = (AccSID, AuthToken, mongoURI = null) => { | ||
return new Client(AccSID, AuthToken, mongoURI); | ||
const connect = ( | ||
AccSID, | ||
AuthToken, | ||
options = { | ||
appName: "", | ||
connectionURI: null, | ||
isPostgres: false | ||
} | ||
) => { | ||
if (typeof options === "string") | ||
throw new Error( | ||
"Options config must be an object, as specified in the documentation." | ||
); | ||
if (!options.hasOwnProperty("isPostgres")) { | ||
options.isPostgres = false; | ||
} | ||
if (!options.hasOwnProperty("appName")) { | ||
options.appName = ""; | ||
} | ||
return new Client(AccSID, AuthToken, options); | ||
}; | ||
@@ -33,21 +51,3 @@ | ||
class Client { | ||
constructor( | ||
AccSID, | ||
AuthToken, | ||
options = { | ||
appName: "", | ||
connectionURI: null, | ||
isPostgres: false | ||
} | ||
) { | ||
if (typeof options === "string") | ||
throw new Error( | ||
"Options config must be an object, as specified in the documentation." | ||
); | ||
if (!options.hasOwnProperty("isPostgres")) { | ||
options.isPostgres = false; | ||
} | ||
if (!options.hasOwnProperty("appName")) { | ||
options.appName = ""; | ||
} | ||
constructor(AccSID, AuthToken, options) { | ||
this.appName = options.appName; | ||
@@ -54,0 +54,0 @@ this.AccSID = AccSID; |
{ | ||
"name": "two-auth", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Implement two-factor SMS authentication with the Twilio API in three lines of code.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
0
33991