-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
80 lines (68 loc) · 2.09 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
"use strict"
const fetch = require('node-fetch');
/** This function only checks the email accross a database
to see if there is a record of it being breached **/
exports.checkEmail = function(email) {
return new Promise(resolve => {
if (!email)
resolve(false);
else
var urlencoded = new URLSearchParams();
urlencoded.append("apiKEY", "YEqWsRCHDaw8WcFUsQWKmO"); //API Key from account.verified.ly
urlencoded.append("email", email);
var requestOptions = {
method: 'POST',
body: urlencoded,
redirect: 'follow'
};
fetch("https://api.verified.ly/v1/pwned", requestOptions)
.then(response => response.text())
.then((result) => {
const res = JSON.parse(result)
// console.log(res.statusCode)
if (res.statusCode == 0) {
resolve(false);
} else {
resolve(true);
}
})
.catch(error => {
console.log('error', error)
resolve(false);
});
});
},
/** This function only checks both the email and password
* accross a database to see if there is a record of it
* being breached **/
exports.checkEmailPassword = function(email, password) {
return new Promise(resolve => {
if (!email && !password)
resolve(false);
else
var urlencoded = new URLSearchParams();
urlencoded.append("apiKEY", "YEqWsRCHDaw8WcFUsQWKmO"); //API Key from account.verified.ly
urlencoded.append("email", email);
urlencoded.append("password", password);
var requestOptions = {
method: 'POST',
body: urlencoded,
redirect: 'follow'
};
fetch("https://api.verified.ly/v1/pwned", requestOptions)
.then(response => response.text())
.then(result => {
// console.log(result)
const res = JSON.parse(result)
if (res.statusCode == 0) {
resolve(false);
} else {
resolve(true);
}
})
.catch(error => {
console.log('error', error)
resolve(false);
});
});
}