dymo-api 1.1.7 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -112,29 +112,35 @@ const isValidEmail = async (token, email, rules) => {
|
|
|
112
112
|
rules.deny.includes("HIGH_RISK_SCORE") ? "riskScore" : undefined
|
|
113
113
|
]
|
|
114
114
|
}, { headers: { "Content-Type": "application/json", "Authorization": token } })).data.email;
|
|
115
|
+
let reasons = [];
|
|
115
116
|
if (rules.deny.includes("INVALID") && !responseEmail.valid)
|
|
116
|
-
|
|
117
|
+
reasons.push("INVALID");
|
|
117
118
|
if (rules.deny.includes("FRAUD") && responseEmail.fraud)
|
|
118
|
-
|
|
119
|
+
reasons.push("FRAUD");
|
|
119
120
|
if (rules.deny.includes("PROXIED_EMAIL") && responseEmail.proxiedEmail)
|
|
120
|
-
|
|
121
|
+
reasons.push("PROXIED_EMAIL");
|
|
121
122
|
if (rules.deny.includes("FREE_SUBDOMAIN") && responseEmail.freeSubdomain)
|
|
122
|
-
|
|
123
|
+
reasons.push("FREE_SUBDOMAIN");
|
|
123
124
|
if (rules.deny.includes("PERSONAL_EMAIL") && !responseEmail.corporate)
|
|
124
|
-
|
|
125
|
+
reasons.push("PERSONAL_EMAIL");
|
|
125
126
|
if (rules.deny.includes("CORPORATE_EMAIL") && responseEmail.corporate)
|
|
126
|
-
|
|
127
|
+
reasons.push("CORPORATE_EMAIL");
|
|
127
128
|
if (rules.deny.includes("NO_MX_RECORDS") && responseEmail.plugins.mxRecords.length === 0)
|
|
128
|
-
|
|
129
|
+
reasons.push("NO_MX_RECORDS");
|
|
129
130
|
if (rules.deny.includes("NO_REPLY_EMAIL") && responseEmail.noReply)
|
|
130
|
-
|
|
131
|
+
reasons.push("NO_REPLY_EMAIL");
|
|
131
132
|
if (rules.deny.includes("ROLE_ACCOUNT") && responseEmail.plugins.roleAccount)
|
|
132
|
-
|
|
133
|
+
reasons.push("ROLE_ACCOUNT");
|
|
133
134
|
if (rules.deny.includes("NO_REACHABLE") && !responseEmail.plugins.reachable)
|
|
134
|
-
|
|
135
|
+
reasons.push("NO_REACHABLE");
|
|
135
136
|
if (rules.deny.includes("HIGH_RISK_SCORE") && responseEmail.plugins.riskScore >= 80)
|
|
136
|
-
|
|
137
|
-
return
|
|
137
|
+
reasons.push("HIGH_RISK_SCORE");
|
|
138
|
+
return {
|
|
139
|
+
email: responseEmail.email,
|
|
140
|
+
allow: reasons.length === 0,
|
|
141
|
+
reasons,
|
|
142
|
+
response: responseEmail
|
|
143
|
+
};
|
|
138
144
|
}
|
|
139
145
|
catch (error) {
|
|
140
146
|
const statusCode = error.response?.status || 500;
|
|
@@ -72,29 +72,35 @@ export const isValidEmail = async (token, email, rules) => {
|
|
|
72
72
|
rules.deny.includes("HIGH_RISK_SCORE") ? "riskScore" : undefined
|
|
73
73
|
]
|
|
74
74
|
}, { headers: { "Content-Type": "application/json", "Authorization": token } })).data.email;
|
|
75
|
+
let reasons = [];
|
|
75
76
|
if (rules.deny.includes("INVALID") && !responseEmail.valid)
|
|
76
|
-
|
|
77
|
+
reasons.push("INVALID");
|
|
77
78
|
if (rules.deny.includes("FRAUD") && responseEmail.fraud)
|
|
78
|
-
|
|
79
|
+
reasons.push("FRAUD");
|
|
79
80
|
if (rules.deny.includes("PROXIED_EMAIL") && responseEmail.proxiedEmail)
|
|
80
|
-
|
|
81
|
+
reasons.push("PROXIED_EMAIL");
|
|
81
82
|
if (rules.deny.includes("FREE_SUBDOMAIN") && responseEmail.freeSubdomain)
|
|
82
|
-
|
|
83
|
+
reasons.push("FREE_SUBDOMAIN");
|
|
83
84
|
if (rules.deny.includes("PERSONAL_EMAIL") && !responseEmail.corporate)
|
|
84
|
-
|
|
85
|
+
reasons.push("PERSONAL_EMAIL");
|
|
85
86
|
if (rules.deny.includes("CORPORATE_EMAIL") && responseEmail.corporate)
|
|
86
|
-
|
|
87
|
+
reasons.push("CORPORATE_EMAIL");
|
|
87
88
|
if (rules.deny.includes("NO_MX_RECORDS") && responseEmail.plugins.mxRecords.length === 0)
|
|
88
|
-
|
|
89
|
+
reasons.push("NO_MX_RECORDS");
|
|
89
90
|
if (rules.deny.includes("NO_REPLY_EMAIL") && responseEmail.noReply)
|
|
90
|
-
|
|
91
|
+
reasons.push("NO_REPLY_EMAIL");
|
|
91
92
|
if (rules.deny.includes("ROLE_ACCOUNT") && responseEmail.plugins.roleAccount)
|
|
92
|
-
|
|
93
|
+
reasons.push("ROLE_ACCOUNT");
|
|
93
94
|
if (rules.deny.includes("NO_REACHABLE") && !responseEmail.plugins.reachable)
|
|
94
|
-
|
|
95
|
+
reasons.push("NO_REACHABLE");
|
|
95
96
|
if (rules.deny.includes("HIGH_RISK_SCORE") && responseEmail.plugins.riskScore >= 80)
|
|
96
|
-
|
|
97
|
-
return
|
|
97
|
+
reasons.push("HIGH_RISK_SCORE");
|
|
98
|
+
return {
|
|
99
|
+
email: responseEmail.email,
|
|
100
|
+
allow: reasons.length === 0,
|
|
101
|
+
reasons,
|
|
102
|
+
response: responseEmail
|
|
103
|
+
};
|
|
98
104
|
}
|
|
99
105
|
catch (error) {
|
|
100
106
|
const statusCode = error.response?.status || 500;
|
|
@@ -26,7 +26,36 @@ export type NegativeEmailRules = "FRAUD" | "INVALID" | "NO_MX_RECORDS" | "PROXIE
|
|
|
26
26
|
export interface EmailValidatorRules {
|
|
27
27
|
deny: NegativeEmailRules[];
|
|
28
28
|
}
|
|
29
|
-
export type EmailValidatorResponse =
|
|
29
|
+
export type EmailValidatorResponse = {
|
|
30
|
+
email: string;
|
|
31
|
+
allow: boolean;
|
|
32
|
+
reasons: NegativeEmailRules[];
|
|
33
|
+
response: DataEmailValidationAnalysis;
|
|
34
|
+
};
|
|
35
|
+
interface DataEmailValidationAnalysis {
|
|
36
|
+
valid: boolean;
|
|
37
|
+
fraud: boolean;
|
|
38
|
+
proxiedEmail: boolean;
|
|
39
|
+
freeSubdomain: boolean;
|
|
40
|
+
corporate: boolean;
|
|
41
|
+
email: string;
|
|
42
|
+
realUser: string;
|
|
43
|
+
didYouMean: string | null;
|
|
44
|
+
noReply: boolean;
|
|
45
|
+
customTLD: boolean;
|
|
46
|
+
domain: string;
|
|
47
|
+
roleAccount: boolean;
|
|
48
|
+
plugins: {
|
|
49
|
+
blocklist?: boolean;
|
|
50
|
+
compromiseDetector?: boolean;
|
|
51
|
+
nsfw?: boolean;
|
|
52
|
+
reputation?: TyposquattingPlugin;
|
|
53
|
+
riskScore?: number;
|
|
54
|
+
torNetwork?: boolean;
|
|
55
|
+
typosquatting?: TyposquattingPlugin;
|
|
56
|
+
urlShortener?: boolean;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
30
59
|
export interface DataValidationAnalysis {
|
|
31
60
|
url: {
|
|
32
61
|
valid: boolean;
|
|
@@ -47,30 +76,7 @@ export interface DataValidationAnalysis {
|
|
|
47
76
|
urlShortener?: boolean;
|
|
48
77
|
};
|
|
49
78
|
};
|
|
50
|
-
email:
|
|
51
|
-
valid: boolean;
|
|
52
|
-
fraud: boolean;
|
|
53
|
-
proxiedEmail: boolean;
|
|
54
|
-
freeSubdomain: boolean;
|
|
55
|
-
corporate: boolean;
|
|
56
|
-
email: string;
|
|
57
|
-
realUser: string;
|
|
58
|
-
didYouMean: string | null;
|
|
59
|
-
noReply: boolean;
|
|
60
|
-
customTLD: boolean;
|
|
61
|
-
domain: string;
|
|
62
|
-
roleAccount: boolean;
|
|
63
|
-
plugins: {
|
|
64
|
-
blocklist?: boolean;
|
|
65
|
-
compromiseDetector?: boolean;
|
|
66
|
-
nsfw?: boolean;
|
|
67
|
-
reputation?: TyposquattingPlugin;
|
|
68
|
-
riskScore?: number;
|
|
69
|
-
torNetwork?: boolean;
|
|
70
|
-
typosquatting?: TyposquattingPlugin;
|
|
71
|
-
urlShortener?: boolean;
|
|
72
|
-
};
|
|
73
|
-
};
|
|
79
|
+
email: DataEmailValidationAnalysis;
|
|
74
80
|
phone: {
|
|
75
81
|
valid: boolean;
|
|
76
82
|
fraud: boolean;
|
|
@@ -183,3 +189,4 @@ export interface DataValidationAnalysis {
|
|
|
183
189
|
};
|
|
184
190
|
};
|
|
185
191
|
}
|
|
192
|
+
export {};
|