dymo-api 1.1.6 → 1.2.0
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.
- package/dist/cjs/branches/private.cjs +56 -28
- package/dist/cjs/dymo-api.cjs +9 -2
- package/dist/cjs/lib/types/interfaces.cjs +1 -0
- package/dist/cjs/lib/types/rules.cjs +3 -0
- package/dist/esm/branches/private.js +56 -28
- package/dist/esm/dymo-api.js +9 -2
- package/dist/esm/lib/types/interfaces.js +1 -0
- package/dist/esm/lib/types/rules.js +2 -0
- package/dist/types/branches/private.d.ts +1 -1
- package/dist/types/dymo-api.d.ts +3 -1
- package/dist/types/lib/types/data-verifier.d.ts +32 -25
- package/dist/types/lib/types/interfaces.d.ts +1 -0
- package/dist/types/lib/types/rules.d.ts +6 -0
- package/package.json +1 -1
|
@@ -98,11 +98,7 @@ exports.isValidData = isValidData;
|
|
|
98
98
|
* @example
|
|
99
99
|
* const valid = await isValidEmail(apiToken, "user@example.com", { deny: ["FRAUD", "NO_MX_RECORDS"] });
|
|
100
100
|
*/
|
|
101
|
-
const isValidEmail = async (token, email, rules
|
|
102
|
-
deny: [
|
|
103
|
-
"FRAUD", "INVALID", "NO_MX_RECORDS", "NO_REPLY_EMAIL"
|
|
104
|
-
]
|
|
105
|
-
}) => {
|
|
101
|
+
const isValidEmail = async (token, email, rules) => {
|
|
106
102
|
if (token === null)
|
|
107
103
|
throw customError(3000, "Invalid private token.");
|
|
108
104
|
if (rules.deny.length === 0)
|
|
@@ -116,29 +112,61 @@ const isValidEmail = async (token, email, rules = {
|
|
|
116
112
|
rules.deny.includes("HIGH_RISK_SCORE") ? "riskScore" : undefined
|
|
117
113
|
]
|
|
118
114
|
}, { headers: { "Content-Type": "application/json", "Authorization": token } })).data.email;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
+
;
|
|
164
|
+
return {
|
|
165
|
+
email: responseEmail.email,
|
|
166
|
+
resolution: isValidEmailInRules(email),
|
|
167
|
+
reasons,
|
|
168
|
+
response: responseEmail
|
|
169
|
+
};
|
|
142
170
|
}
|
|
143
171
|
catch (error) {
|
|
144
172
|
const statusCode = error.response?.status || 500;
|
package/dist/cjs/dymo-api.cjs
CHANGED
|
@@ -57,10 +57,17 @@ class DymoAPI {
|
|
|
57
57
|
* apiKey: "4c8b7675-6b69-4f8d-9f43-5a6f7f02c6c5"
|
|
58
58
|
* });
|
|
59
59
|
*/
|
|
60
|
-
constructor({ rootApiKey = null, apiKey = null, baseUrl = "https://api.tpeoficial.com", serverEmailConfig = undefined
|
|
60
|
+
constructor({ rootApiKey = null, apiKey = null, baseUrl = "https://api.tpeoficial.com", serverEmailConfig = undefined, rules = {
|
|
61
|
+
email: {
|
|
62
|
+
deny: [
|
|
63
|
+
"FRAUD", "INVALID", "NO_MX_RECORDS", "NO_REPLY_EMAIL"
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
} } = {}) {
|
|
61
67
|
this.rootApiKey = rootApiKey;
|
|
62
68
|
this.apiKey = apiKey;
|
|
63
69
|
this.serverEmailConfig = serverEmailConfig;
|
|
70
|
+
this.rules = rules;
|
|
64
71
|
this.baseUrl = baseUrl;
|
|
65
72
|
(0, config_1.setBaseUrl)(baseUrl);
|
|
66
73
|
}
|
|
@@ -109,7 +116,7 @@ class DymoAPI {
|
|
|
109
116
|
*
|
|
110
117
|
* @see [Documentation](https://docs.tpeoficial.com/docs/dymo-api/private/data-verifier)
|
|
111
118
|
*/
|
|
112
|
-
async isValidEmail(email, rules) {
|
|
119
|
+
async isValidEmail(email, rules = this.rules.email) {
|
|
113
120
|
return await PrivateAPI.isValidEmail(this.rootApiKey || this.apiKey, email, rules);
|
|
114
121
|
}
|
|
115
122
|
;
|
|
@@ -58,11 +58,7 @@ export const isValidData = async (token, data) => {
|
|
|
58
58
|
* @example
|
|
59
59
|
* const valid = await isValidEmail(apiToken, "user@example.com", { deny: ["FRAUD", "NO_MX_RECORDS"] });
|
|
60
60
|
*/
|
|
61
|
-
export const isValidEmail = async (token, email, rules
|
|
62
|
-
deny: [
|
|
63
|
-
"FRAUD", "INVALID", "NO_MX_RECORDS", "NO_REPLY_EMAIL"
|
|
64
|
-
]
|
|
65
|
-
}) => {
|
|
61
|
+
export const isValidEmail = async (token, email, rules) => {
|
|
66
62
|
if (token === null)
|
|
67
63
|
throw customError(3000, "Invalid private token.");
|
|
68
64
|
if (rules.deny.length === 0)
|
|
@@ -76,29 +72,61 @@ export const isValidEmail = async (token, email, rules = {
|
|
|
76
72
|
rules.deny.includes("HIGH_RISK_SCORE") ? "riskScore" : undefined
|
|
77
73
|
]
|
|
78
74
|
}, { headers: { "Content-Type": "application/json", "Authorization": token } })).data.email;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
+
;
|
|
124
|
+
return {
|
|
125
|
+
email: responseEmail.email,
|
|
126
|
+
resolution: isValidEmailInRules(email),
|
|
127
|
+
reasons,
|
|
128
|
+
response: responseEmail
|
|
129
|
+
};
|
|
102
130
|
}
|
|
103
131
|
catch (error) {
|
|
104
132
|
const statusCode = error.response?.status || 500;
|
package/dist/esm/dymo-api.js
CHANGED
|
@@ -22,10 +22,17 @@ class DymoAPI {
|
|
|
22
22
|
* apiKey: "4c8b7675-6b69-4f8d-9f43-5a6f7f02c6c5"
|
|
23
23
|
* });
|
|
24
24
|
*/
|
|
25
|
-
constructor({ rootApiKey = null, apiKey = null, baseUrl = "https://api.tpeoficial.com", serverEmailConfig = undefined
|
|
25
|
+
constructor({ rootApiKey = null, apiKey = null, baseUrl = "https://api.tpeoficial.com", serverEmailConfig = undefined, rules = {
|
|
26
|
+
email: {
|
|
27
|
+
deny: [
|
|
28
|
+
"FRAUD", "INVALID", "NO_MX_RECORDS", "NO_REPLY_EMAIL"
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
} } = {}) {
|
|
26
32
|
this.rootApiKey = rootApiKey;
|
|
27
33
|
this.apiKey = apiKey;
|
|
28
34
|
this.serverEmailConfig = serverEmailConfig;
|
|
35
|
+
this.rules = rules;
|
|
29
36
|
this.baseUrl = baseUrl;
|
|
30
37
|
setBaseUrl(baseUrl);
|
|
31
38
|
}
|
|
@@ -74,7 +81,7 @@ class DymoAPI {
|
|
|
74
81
|
*
|
|
75
82
|
* @see [Documentation](https://docs.tpeoficial.com/docs/dymo-api/private/data-verifier)
|
|
76
83
|
*/
|
|
77
|
-
async isValidEmail(email, rules) {
|
|
84
|
+
async isValidEmail(email, rules = this.rules.email) {
|
|
78
85
|
return await PrivateAPI.isValidEmail(this.rootApiKey || this.apiKey, email, rules);
|
|
79
86
|
}
|
|
80
87
|
;
|
|
@@ -29,7 +29,7 @@ export declare const isValidData: (token: string | null, data: Interfaces.Valida
|
|
|
29
29
|
* @example
|
|
30
30
|
* const valid = await isValidEmail(apiToken, "user@example.com", { deny: ["FRAUD", "NO_MX_RECORDS"] });
|
|
31
31
|
*/
|
|
32
|
-
export declare const isValidEmail: (token: string | null, email: Interfaces.EmailValidator, rules
|
|
32
|
+
export declare const isValidEmail: (token: string | null, email: Interfaces.EmailValidator, rules: Interfaces.EmailValidatorRules) => Promise<any>;
|
|
33
33
|
/**
|
|
34
34
|
* Sends an email using a secure sending endpoint.
|
|
35
35
|
*
|
package/dist/types/dymo-api.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ declare class DymoAPI {
|
|
|
3
3
|
private rootApiKey;
|
|
4
4
|
private apiKey;
|
|
5
5
|
private serverEmailConfig?;
|
|
6
|
+
private rules;
|
|
6
7
|
private baseUrl;
|
|
7
8
|
/**
|
|
8
9
|
* @param {Object} options - Options to create the DymoAPI instance.
|
|
@@ -21,11 +22,12 @@ declare class DymoAPI {
|
|
|
21
22
|
* apiKey: "4c8b7675-6b69-4f8d-9f43-5a6f7f02c6c5"
|
|
22
23
|
* });
|
|
23
24
|
*/
|
|
24
|
-
constructor({ rootApiKey, apiKey, baseUrl, serverEmailConfig }?: {
|
|
25
|
+
constructor({ rootApiKey, apiKey, baseUrl, serverEmailConfig, rules }?: {
|
|
25
26
|
rootApiKey?: string | null;
|
|
26
27
|
apiKey?: string | null;
|
|
27
28
|
baseUrl?: string;
|
|
28
29
|
serverEmailConfig?: Interfaces.ServerEmailConfig;
|
|
30
|
+
rules?: Interfaces.Rules;
|
|
29
31
|
});
|
|
30
32
|
/**
|
|
31
33
|
* Validates the given data against the configured validation settings.
|
|
@@ -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
|
+
resolution: 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 {};
|