tfa-node-sdk
Advanced tools
Comparing version 1.6.2 to 2.6.2
@@ -1,1 +0,3 @@ | ||
module.exports = require('./lib/tfa'); | ||
import TFA from "./lib/tfa.js"; | ||
export default TFA; |
@@ -1,36 +0,30 @@ | ||
const axios = require('axios'); | ||
import API from "./api/index.js"; | ||
class TFA { | ||
constructor(access_token) { | ||
this.access_token = access_token; | ||
this.baseUrl = "http://localhost:9000/api/auth"; | ||
this.baseUrl = "https://tfasoft-api.herokuapp.com/api/auth"; | ||
} | ||
authUser(user_token) { | ||
const data = { | ||
"access_token": this.access_token, | ||
"user_token": user_token, | ||
} | ||
constructor(access_token) { | ||
this.access_token = access_token; | ||
} | ||
return axios.post(`${this.baseUrl}/auth/access`, data) | ||
.then((response) => { | ||
const data = { | ||
status: response.status, | ||
data: response.data, | ||
} | ||
async authUser(user_token) { | ||
const data = { | ||
access_token: this.access_token, | ||
user_token: user_token, | ||
}; | ||
return data; | ||
}) | ||
.catch((error) => { | ||
const data = { | ||
status: error.response.status, | ||
data: error.response.data, | ||
} | ||
try { | ||
const response = await API.post("access", data); | ||
return data; | ||
}); | ||
return { | ||
status: response.status, | ||
data: response.data, | ||
}; | ||
} catch (error) { | ||
return { | ||
status: error.response.status, | ||
data: error.response.data, | ||
}; | ||
} | ||
} | ||
} | ||
module.exports = TFA; | ||
export default TFA; |
{ | ||
"name": "tfa-node-sdk", | ||
"version": "1.6.2", | ||
"version": "2.6.2", | ||
"description": "Telegram Factor Authentication node library", | ||
"main": "index.js", | ||
"type": "module", | ||
"scripts": { | ||
@@ -34,2 +35,2 @@ "start": "node index.js" | ||
} | ||
} | ||
} |
@@ -1,17 +0,13 @@ | ||
const tfa = require('tfa-node-sdk'); | ||
import tfa from "tfa-node-sdk"; | ||
const auth = new tfa('itEvNsiSpmQFNDiOQtKHCVtDc'); | ||
const auth = new tfa("rglscfrrdqdjvalsyvwzelrab"); | ||
const result = auth.authUser('uAMGSFEFDQUevEHWulAMHIBtz'); | ||
const result = auth.authUser("csxieuilrszyhzudxdjqhhhyl"); | ||
result.then((result) => { | ||
const data = result.data; | ||
const statCode = result.status; | ||
if (statCode === 200) { | ||
const user = data.user; | ||
console.log(user); | ||
} else { | ||
console.log(data.message); | ||
} | ||
}); | ||
if (result.status === 200) { | ||
console.log({ user: result.data }); | ||
} else { | ||
console.log({ message: result.data.message }); | ||
} | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Yes
6278
42