dymo-api 1.2.0 → 1.2.2

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.
@@ -113,57 +113,31 @@ const isValidEmail = async (token, email, rules) => {
113
113
  ]
114
114
  }, { headers: { "Content-Type": "application/json", "Authorization": token } })).data.email;
115
115
  let reasons = [];
116
- function isValidEmailInRules(email) {
117
- if (rules.deny.includes("INVALID") && !responseEmail.valid) {
118
- reasons.push("INVALID");
119
- return false;
120
- }
121
- if (rules.deny.includes("FRAUD") && responseEmail.fraud) {
122
- reasons.push("FRAUD");
123
- return false;
124
- }
125
- if (rules.deny.includes("PROXIED_EMAIL") && responseEmail.proxiedEmail) {
126
- reasons.push("PROXIED_EMAIL");
127
- return false;
128
- }
129
- if (rules.deny.includes("FREE_SUBDOMAIN") && responseEmail.freeSubdomain) {
130
- reasons.push("FREE_SUBDOMAIN");
131
- return false;
132
- }
133
- if (rules.deny.includes("PERSONAL_EMAIL") && !responseEmail.corporate) {
134
- reasons.push("PERSONAL_EMAIL");
135
- return false;
136
- }
137
- if (rules.deny.includes("CORPORATE_EMAIL") && responseEmail.corporate) {
138
- reasons.push("CORPORATE_EMAIL");
139
- return false;
140
- }
141
- if (rules.deny.includes("NO_MX_RECORDS") && responseEmail.plugins.mxRecords.length === 0) {
142
- reasons.push("NO_MX_RECORDS");
143
- return false;
144
- }
145
- if (rules.deny.includes("NO_REPLY_EMAIL") && responseEmail.noReply) {
146
- reasons.push("NO_REPLY_EMAIL");
147
- return false;
148
- }
149
- if (rules.deny.includes("ROLE_ACCOUNT") && responseEmail.plugins.roleAccount) {
150
- reasons.push("ROLE_ACCOUNT");
151
- return false;
152
- }
153
- if (rules.deny.includes("NO_REACHABLE") && !responseEmail.plugins.reachable) {
154
- reasons.push("NO_REACHABLE");
155
- return false;
156
- }
157
- if (rules.deny.includes("HIGH_RISK_SCORE") && responseEmail.plugins.riskScore >= 80) {
158
- reasons.push("HIGH_RISK_SCORE");
159
- return false;
160
- }
161
- return true;
162
- }
163
- ;
116
+ if (rules.deny.includes("INVALID") && !responseEmail.valid)
117
+ reasons.push("INVALID");
118
+ if (rules.deny.includes("FRAUD") && responseEmail.fraud)
119
+ reasons.push("FRAUD");
120
+ if (rules.deny.includes("PROXIED_EMAIL") && responseEmail.proxiedEmail)
121
+ reasons.push("PROXIED_EMAIL");
122
+ if (rules.deny.includes("FREE_SUBDOMAIN") && responseEmail.freeSubdomain)
123
+ reasons.push("FREE_SUBDOMAIN");
124
+ if (rules.deny.includes("PERSONAL_EMAIL") && !responseEmail.corporate)
125
+ reasons.push("PERSONAL_EMAIL");
126
+ if (rules.deny.includes("CORPORATE_EMAIL") && responseEmail.corporate)
127
+ reasons.push("CORPORATE_EMAIL");
128
+ if (rules.deny.includes("NO_MX_RECORDS") && responseEmail.plugins.mxRecords.length === 0)
129
+ reasons.push("NO_MX_RECORDS");
130
+ if (rules.deny.includes("NO_REPLY_EMAIL") && responseEmail.noReply)
131
+ reasons.push("NO_REPLY_EMAIL");
132
+ if (rules.deny.includes("ROLE_ACCOUNT") && responseEmail.plugins.roleAccount)
133
+ reasons.push("ROLE_ACCOUNT");
134
+ if (rules.deny.includes("NO_REACHABLE") && !responseEmail.plugins.reachable)
135
+ reasons.push("NO_REACHABLE");
136
+ if (rules.deny.includes("HIGH_RISK_SCORE") && responseEmail.plugins.riskScore >= 80)
137
+ reasons.push("HIGH_RISK_SCORE");
164
138
  return {
165
139
  email: responseEmail.email,
166
- resolution: isValidEmailInRules(email),
140
+ allow: reasons.length === 0,
167
141
  reasons,
168
142
  response: responseEmail
169
143
  };
@@ -73,57 +73,31 @@ export const isValidEmail = async (token, email, rules) => {
73
73
  ]
74
74
  }, { headers: { "Content-Type": "application/json", "Authorization": token } })).data.email;
75
75
  let reasons = [];
76
- function isValidEmailInRules(email) {
77
- if (rules.deny.includes("INVALID") && !responseEmail.valid) {
78
- reasons.push("INVALID");
79
- return false;
80
- }
81
- if (rules.deny.includes("FRAUD") && responseEmail.fraud) {
82
- reasons.push("FRAUD");
83
- return false;
84
- }
85
- if (rules.deny.includes("PROXIED_EMAIL") && responseEmail.proxiedEmail) {
86
- reasons.push("PROXIED_EMAIL");
87
- return false;
88
- }
89
- if (rules.deny.includes("FREE_SUBDOMAIN") && responseEmail.freeSubdomain) {
90
- reasons.push("FREE_SUBDOMAIN");
91
- return false;
92
- }
93
- if (rules.deny.includes("PERSONAL_EMAIL") && !responseEmail.corporate) {
94
- reasons.push("PERSONAL_EMAIL");
95
- return false;
96
- }
97
- if (rules.deny.includes("CORPORATE_EMAIL") && responseEmail.corporate) {
98
- reasons.push("CORPORATE_EMAIL");
99
- return false;
100
- }
101
- if (rules.deny.includes("NO_MX_RECORDS") && responseEmail.plugins.mxRecords.length === 0) {
102
- reasons.push("NO_MX_RECORDS");
103
- return false;
104
- }
105
- if (rules.deny.includes("NO_REPLY_EMAIL") && responseEmail.noReply) {
106
- reasons.push("NO_REPLY_EMAIL");
107
- return false;
108
- }
109
- if (rules.deny.includes("ROLE_ACCOUNT") && responseEmail.plugins.roleAccount) {
110
- reasons.push("ROLE_ACCOUNT");
111
- return false;
112
- }
113
- if (rules.deny.includes("NO_REACHABLE") && !responseEmail.plugins.reachable) {
114
- reasons.push("NO_REACHABLE");
115
- return false;
116
- }
117
- if (rules.deny.includes("HIGH_RISK_SCORE") && responseEmail.plugins.riskScore >= 80) {
118
- reasons.push("HIGH_RISK_SCORE");
119
- return false;
120
- }
121
- return true;
122
- }
123
- ;
76
+ if (rules.deny.includes("INVALID") && !responseEmail.valid)
77
+ reasons.push("INVALID");
78
+ if (rules.deny.includes("FRAUD") && responseEmail.fraud)
79
+ reasons.push("FRAUD");
80
+ if (rules.deny.includes("PROXIED_EMAIL") && responseEmail.proxiedEmail)
81
+ reasons.push("PROXIED_EMAIL");
82
+ if (rules.deny.includes("FREE_SUBDOMAIN") && responseEmail.freeSubdomain)
83
+ reasons.push("FREE_SUBDOMAIN");
84
+ if (rules.deny.includes("PERSONAL_EMAIL") && !responseEmail.corporate)
85
+ reasons.push("PERSONAL_EMAIL");
86
+ if (rules.deny.includes("CORPORATE_EMAIL") && responseEmail.corporate)
87
+ reasons.push("CORPORATE_EMAIL");
88
+ if (rules.deny.includes("NO_MX_RECORDS") && responseEmail.plugins.mxRecords.length === 0)
89
+ reasons.push("NO_MX_RECORDS");
90
+ if (rules.deny.includes("NO_REPLY_EMAIL") && responseEmail.noReply)
91
+ reasons.push("NO_REPLY_EMAIL");
92
+ if (rules.deny.includes("ROLE_ACCOUNT") && responseEmail.plugins.roleAccount)
93
+ reasons.push("ROLE_ACCOUNT");
94
+ if (rules.deny.includes("NO_REACHABLE") && !responseEmail.plugins.reachable)
95
+ reasons.push("NO_REACHABLE");
96
+ if (rules.deny.includes("HIGH_RISK_SCORE") && responseEmail.plugins.riskScore >= 80)
97
+ reasons.push("HIGH_RISK_SCORE");
124
98
  return {
125
99
  email: responseEmail.email,
126
- resolution: isValidEmailInRules(email),
100
+ allow: reasons.length === 0,
127
101
  reasons,
128
102
  response: responseEmail
129
103
  };
@@ -28,7 +28,7 @@ export interface EmailValidatorRules {
28
28
  }
29
29
  export type EmailValidatorResponse = {
30
30
  email: string;
31
- resolution: boolean;
31
+ allow: boolean;
32
32
  reasons: NegativeEmailRules[];
33
33
  response: DataEmailValidationAnalysis;
34
34
  };
@@ -48,6 +48,7 @@ interface DataEmailValidationAnalysis {
48
48
  plugins: {
49
49
  blocklist?: boolean;
50
50
  compromiseDetector?: boolean;
51
+ mxRecords: MxRecord[];
51
52
  nsfw?: boolean;
52
53
  reputation?: TyposquattingPlugin;
53
54
  riskScore?: number;
@@ -106,6 +107,7 @@ export interface DataValidationAnalysis {
106
107
  plugins: {
107
108
  blocklist?: boolean;
108
109
  compromiseDetector?: boolean;
110
+ mxRecords: MxRecord[];
109
111
  nsfw?: boolean;
110
112
  reputation?: "low" | "medium" | "high" | "very-high" | "education" | "governmental" | "unknown";
111
113
  riskScore?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dymo-api",
3
- "version": "1.2.0",
3
+ "version": "1.2.02",
4
4
  "description": "Flow system for Dymo API.",
5
5
  "main": "dist/cjs/dymo-api.js",
6
6
  "module": "dist/esm/dymo-api.js",