dymo-api 1.2.20 → 1.2.23
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/functions/isValidPhone/index.cjs +69 -0
- package/dist/cjs/branches/private/index.cjs +1 -0
- package/dist/cjs/dymo-api.cjs +26 -3
- package/dist/esm/branches/private/functions/isValidPhone/index.js +65 -0
- package/dist/esm/branches/private/index.js +1 -0
- package/dist/esm/dymo-api.js +26 -3
- package/dist/types/branches/private/functions/isValidPhone/index.d.ts +19 -0
- package/dist/types/branches/private/index.d.ts +1 -0
- package/dist/types/dymo-api.d.ts +22 -3
- package/dist/types/lib/types/data-verifier.d.ts +62 -37
- package/dist/types/lib/types/primitives.d.ts +10 -7
- package/dist/types/lib/types/rules.d.ts +6 -1
- package/package.json +13 -2
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isValidPhone = void 0;
|
|
4
|
+
const basics_1 = require("../../../../utils/basics.cjs");
|
|
5
|
+
/**
|
|
6
|
+
* Validates an phone using a secure verification endpoint.
|
|
7
|
+
*
|
|
8
|
+
* @param {string | null} token - Authentication token (required).
|
|
9
|
+
* @param {Interfaces.PhoneValidator} phone - Phone to validate.
|
|
10
|
+
* @param {Interfaces.PhoneValidatorRules} [rules] - Deny rules. Defaults to ["FRAUD", "INVALID"].
|
|
11
|
+
*
|
|
12
|
+
* Deny rules (some are premium ⚠️):
|
|
13
|
+
* - "FRAUD", "INVALID", "HIGH_RISK_SCORE" ⚠️
|
|
14
|
+
*
|
|
15
|
+
* @returns {Promise<boolean>} True if the phone passes all deny rules, false otherwise.
|
|
16
|
+
* @throws Error if token is null, rules are empty, or request fails.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* const valid = await isValidPhone(apiToken, "+34617509462", { deny: ["FRAUD", "INVALID" });
|
|
20
|
+
*/
|
|
21
|
+
const isValidPhone = async (axiosClient, phone, rules) => {
|
|
22
|
+
if (!axiosClient.defaults.headers?.Authorization)
|
|
23
|
+
throw (0, basics_1.customError)(3000, "Invalid private token.");
|
|
24
|
+
if (rules.deny.length === 0)
|
|
25
|
+
throw (0, basics_1.customError)(1500, "You must provide at least one deny rule.");
|
|
26
|
+
if (rules.mode === "DRY_RUN") {
|
|
27
|
+
console.warn("[Dymo API] DRY_RUN mode is enabled. No requests with real data will be processed until you switch to LIVE mode.");
|
|
28
|
+
return {
|
|
29
|
+
phone,
|
|
30
|
+
allow: true,
|
|
31
|
+
reasons: [],
|
|
32
|
+
response: "CHANGE TO LIVE MODE"
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
const responsePhone = (await axiosClient.post("/private/secure/verify", {
|
|
37
|
+
phone,
|
|
38
|
+
plugins: [
|
|
39
|
+
rules.deny.includes("HIGH_RISK_SCORE") ? "riskScore" : undefined
|
|
40
|
+
].filter(Boolean)
|
|
41
|
+
}, { headers: { "Content-Type": "application/json" } })).data.phone;
|
|
42
|
+
let reasons = [];
|
|
43
|
+
if (rules.deny.includes("INVALID") && !responsePhone.valid) {
|
|
44
|
+
return {
|
|
45
|
+
phone: responsePhone.phone,
|
|
46
|
+
allow: false,
|
|
47
|
+
reasons: ["INVALID"],
|
|
48
|
+
response: responsePhone
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
if (rules.deny.includes("FRAUD") && responsePhone.fraud)
|
|
52
|
+
reasons.push("FRAUD");
|
|
53
|
+
if (rules.deny.includes("HIGH_RISK_SCORE") && responsePhone.plugins.riskScore >= 80)
|
|
54
|
+
reasons.push("HIGH_RISK_SCORE");
|
|
55
|
+
return {
|
|
56
|
+
phone: responsePhone.phone,
|
|
57
|
+
allow: reasons.length === 0,
|
|
58
|
+
reasons,
|
|
59
|
+
response: responsePhone
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
const statusCode = error.response?.status || 500;
|
|
64
|
+
const errorMessage = error.response?.data?.message || error.message;
|
|
65
|
+
const errorDetails = JSON.stringify(error.response?.data || {});
|
|
66
|
+
throw (0, basics_1.customError)(5000, `Error ${statusCode}: ${errorMessage}. Details: ${errorDetails}`);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
exports.isValidPhone = isValidPhone;
|
|
@@ -18,5 +18,6 @@ __exportStar(require("./functions/extractWithTextly/index.cjs"), exports);
|
|
|
18
18
|
__exportStar(require("./functions/getRandom/index.cjs"), exports);
|
|
19
19
|
__exportStar(require("./functions/isValidDataRaw/index.cjs"), exports);
|
|
20
20
|
__exportStar(require("./functions/isValidEmail/index.cjs"), exports);
|
|
21
|
+
__exportStar(require("./functions/isValidPhone/index.cjs"), exports);
|
|
21
22
|
__exportStar(require("./functions/protectReq/index.cjs"), exports);
|
|
22
23
|
__exportStar(require("./functions/sendEmail/index.cjs"), exports);
|
package/dist/cjs/dymo-api.cjs
CHANGED
|
@@ -62,6 +62,7 @@ class DymoAPI {
|
|
|
62
62
|
constructor({ rootApiKey = null, apiKey = null, baseUrl = "https://api.tpeoficial.com", serverEmailConfig = undefined, rules = {} } = {}) {
|
|
63
63
|
this.rules = {
|
|
64
64
|
email: { mode: "LIVE", deny: ["FRAUD", "INVALID", "NO_MX_RECORDS", "NO_REPLY_EMAIL"] },
|
|
65
|
+
phone: { mode: "LIVE", deny: ["FRAUD", "INVALID"] },
|
|
65
66
|
sensitiveInfo: { mode: "LIVE", deny: ["EMAIL", "PHONE", "CREDIT_CARD"] },
|
|
66
67
|
waf: { mode: "LIVE", allowBots: ["CURL", "CATEGORY:SEARCH_ENGINE", "CATEGORY:PREVIEW"], deny: ["FRAUD", "TOR_NETWORK"] },
|
|
67
68
|
...rules
|
|
@@ -76,7 +77,7 @@ class DymoAPI {
|
|
|
76
77
|
headers: {
|
|
77
78
|
"User-Agent": "DymoAPISDK/1.0.0",
|
|
78
79
|
"X-Dymo-SDK-Env": "Node",
|
|
79
|
-
"X-Dymo-SDK-Version": "1.2.
|
|
80
|
+
"X-Dymo-SDK-Version": "1.2.23"
|
|
80
81
|
}
|
|
81
82
|
});
|
|
82
83
|
// We set the authorization in the Axios client to make requests.
|
|
@@ -144,7 +145,7 @@ class DymoAPI {
|
|
|
144
145
|
* This method requires either the root API key or the API key to be set.
|
|
145
146
|
* If neither is set, it will throw an error.
|
|
146
147
|
*
|
|
147
|
-
* @param {string} [email] -
|
|
148
|
+
* @param {string} [email] - Email address to validate.
|
|
148
149
|
* @param {NegativeEmailRules[]} [rules] - Optional rules for validation. Some rules are premium features.
|
|
149
150
|
* @important
|
|
150
151
|
* **⚠️ NO_MX_RECORDS, HIGH_RISK_SCORE and NO_REACHABLE are [PREMIUM](https://docs.tpeoficial.com/docs/dymo-api/private/data-verifier) features.**
|
|
@@ -154,12 +155,34 @@ class DymoAPI {
|
|
|
154
155
|
* @example
|
|
155
156
|
* const valid = await dymoClient.isValidEmail("user@example.com", { deny: ["FRAUD", "NO_MX_RECORDS"] });
|
|
156
157
|
*
|
|
157
|
-
* @see [Documentation](https://docs.tpeoficial.com/docs/dymo-api/private/
|
|
158
|
+
* @see [Documentation](https://docs.tpeoficial.com/docs/dymo-api/private/email-validation)
|
|
158
159
|
*/
|
|
159
160
|
async isValidEmail(email, rules = this.rules.email) {
|
|
160
161
|
return await PrivateAPI.isValidEmail(this.axiosClient, email, rules);
|
|
161
162
|
}
|
|
162
163
|
;
|
|
164
|
+
/**
|
|
165
|
+
* Validates the given email against the configured rules.
|
|
166
|
+
*
|
|
167
|
+
* This method requires either the root API key or the API key to be set.
|
|
168
|
+
* If neither is set, it will throw an error.
|
|
169
|
+
*
|
|
170
|
+
* @param {string} [phone] - Phone number to validate.
|
|
171
|
+
* @param {NegativePhoneRules[]} [rules] - Optional rules for validation. Some rules are premium features.
|
|
172
|
+
* @important
|
|
173
|
+
* **⚠️ HIGH_RISK_SCORE is a [PREMIUM](https://docs.tpeoficial.com/docs/dymo-api/private/data-verifier) feature.**
|
|
174
|
+
* @returns {Promise<Interfaces.EmailValidatorResponse>} Resolves with the validation response.
|
|
175
|
+
* @throws Will throw an error if validation cannot be performed.
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* const valid = await dymoClient.isValidPhone("+34617509462", { deny: ["FRAUD", "INVALID"] });
|
|
179
|
+
*
|
|
180
|
+
* @see [Documentation](https://docs.tpeoficial.com/docs/dymo-api/private/phone-validation)
|
|
181
|
+
*/
|
|
182
|
+
async isValidPhone(phone, rules = this.rules.phone) {
|
|
183
|
+
return await PrivateAPI.isValidPhone(this.axiosClient, phone, rules);
|
|
184
|
+
}
|
|
185
|
+
;
|
|
163
186
|
/**
|
|
164
187
|
* Protects the given request against the configured rules.
|
|
165
188
|
*
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { customError } from "../../../../utils/basics.js";
|
|
2
|
+
/**
|
|
3
|
+
* Validates an phone using a secure verification endpoint.
|
|
4
|
+
*
|
|
5
|
+
* @param {string | null} token - Authentication token (required).
|
|
6
|
+
* @param {Interfaces.PhoneValidator} phone - Phone to validate.
|
|
7
|
+
* @param {Interfaces.PhoneValidatorRules} [rules] - Deny rules. Defaults to ["FRAUD", "INVALID"].
|
|
8
|
+
*
|
|
9
|
+
* Deny rules (some are premium ⚠️):
|
|
10
|
+
* - "FRAUD", "INVALID", "HIGH_RISK_SCORE" ⚠️
|
|
11
|
+
*
|
|
12
|
+
* @returns {Promise<boolean>} True if the phone passes all deny rules, false otherwise.
|
|
13
|
+
* @throws Error if token is null, rules are empty, or request fails.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* const valid = await isValidPhone(apiToken, "+34617509462", { deny: ["FRAUD", "INVALID" });
|
|
17
|
+
*/
|
|
18
|
+
export const isValidPhone = async (axiosClient, phone, rules) => {
|
|
19
|
+
if (!axiosClient.defaults.headers?.Authorization)
|
|
20
|
+
throw customError(3000, "Invalid private token.");
|
|
21
|
+
if (rules.deny.length === 0)
|
|
22
|
+
throw customError(1500, "You must provide at least one deny rule.");
|
|
23
|
+
if (rules.mode === "DRY_RUN") {
|
|
24
|
+
console.warn("[Dymo API] DRY_RUN mode is enabled. No requests with real data will be processed until you switch to LIVE mode.");
|
|
25
|
+
return {
|
|
26
|
+
phone,
|
|
27
|
+
allow: true,
|
|
28
|
+
reasons: [],
|
|
29
|
+
response: "CHANGE TO LIVE MODE"
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
const responsePhone = (await axiosClient.post("/private/secure/verify", {
|
|
34
|
+
phone,
|
|
35
|
+
plugins: [
|
|
36
|
+
rules.deny.includes("HIGH_RISK_SCORE") ? "riskScore" : undefined
|
|
37
|
+
].filter(Boolean)
|
|
38
|
+
}, { headers: { "Content-Type": "application/json" } })).data.phone;
|
|
39
|
+
let reasons = [];
|
|
40
|
+
if (rules.deny.includes("INVALID") && !responsePhone.valid) {
|
|
41
|
+
return {
|
|
42
|
+
phone: responsePhone.phone,
|
|
43
|
+
allow: false,
|
|
44
|
+
reasons: ["INVALID"],
|
|
45
|
+
response: responsePhone
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
if (rules.deny.includes("FRAUD") && responsePhone.fraud)
|
|
49
|
+
reasons.push("FRAUD");
|
|
50
|
+
if (rules.deny.includes("HIGH_RISK_SCORE") && responsePhone.plugins.riskScore >= 80)
|
|
51
|
+
reasons.push("HIGH_RISK_SCORE");
|
|
52
|
+
return {
|
|
53
|
+
phone: responsePhone.phone,
|
|
54
|
+
allow: reasons.length === 0,
|
|
55
|
+
reasons,
|
|
56
|
+
response: responsePhone
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
const statusCode = error.response?.status || 500;
|
|
61
|
+
const errorMessage = error.response?.data?.message || error.message;
|
|
62
|
+
const errorDetails = JSON.stringify(error.response?.data || {});
|
|
63
|
+
throw customError(5000, `Error ${statusCode}: ${errorMessage}. Details: ${errorDetails}`);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
@@ -2,5 +2,6 @@ export * from "./functions/extractWithTextly";
|
|
|
2
2
|
export * from "./functions/getRandom";
|
|
3
3
|
export * from "./functions/isValidDataRaw";
|
|
4
4
|
export * from "./functions/isValidEmail";
|
|
5
|
+
export * from "./functions/isValidPhone";
|
|
5
6
|
export * from "./functions/protectReq";
|
|
6
7
|
export * from "./functions/sendEmail";
|
package/dist/esm/dymo-api.js
CHANGED
|
@@ -24,6 +24,7 @@ class DymoAPI {
|
|
|
24
24
|
constructor({ rootApiKey = null, apiKey = null, baseUrl = "https://api.tpeoficial.com", serverEmailConfig = undefined, rules = {} } = {}) {
|
|
25
25
|
this.rules = {
|
|
26
26
|
email: { mode: "LIVE", deny: ["FRAUD", "INVALID", "NO_MX_RECORDS", "NO_REPLY_EMAIL"] },
|
|
27
|
+
phone: { mode: "LIVE", deny: ["FRAUD", "INVALID"] },
|
|
27
28
|
sensitiveInfo: { mode: "LIVE", deny: ["EMAIL", "PHONE", "CREDIT_CARD"] },
|
|
28
29
|
waf: { mode: "LIVE", allowBots: ["CURL", "CATEGORY:SEARCH_ENGINE", "CATEGORY:PREVIEW"], deny: ["FRAUD", "TOR_NETWORK"] },
|
|
29
30
|
...rules
|
|
@@ -38,7 +39,7 @@ class DymoAPI {
|
|
|
38
39
|
headers: {
|
|
39
40
|
"User-Agent": "DymoAPISDK/1.0.0",
|
|
40
41
|
"X-Dymo-SDK-Env": "Node",
|
|
41
|
-
"X-Dymo-SDK-Version": "1.2.
|
|
42
|
+
"X-Dymo-SDK-Version": "1.2.23"
|
|
42
43
|
}
|
|
43
44
|
});
|
|
44
45
|
// We set the authorization in the Axios client to make requests.
|
|
@@ -106,7 +107,7 @@ class DymoAPI {
|
|
|
106
107
|
* This method requires either the root API key or the API key to be set.
|
|
107
108
|
* If neither is set, it will throw an error.
|
|
108
109
|
*
|
|
109
|
-
* @param {string} [email] -
|
|
110
|
+
* @param {string} [email] - Email address to validate.
|
|
110
111
|
* @param {NegativeEmailRules[]} [rules] - Optional rules for validation. Some rules are premium features.
|
|
111
112
|
* @important
|
|
112
113
|
* **⚠️ NO_MX_RECORDS, HIGH_RISK_SCORE and NO_REACHABLE are [PREMIUM](https://docs.tpeoficial.com/docs/dymo-api/private/data-verifier) features.**
|
|
@@ -116,12 +117,34 @@ class DymoAPI {
|
|
|
116
117
|
* @example
|
|
117
118
|
* const valid = await dymoClient.isValidEmail("user@example.com", { deny: ["FRAUD", "NO_MX_RECORDS"] });
|
|
118
119
|
*
|
|
119
|
-
* @see [Documentation](https://docs.tpeoficial.com/docs/dymo-api/private/
|
|
120
|
+
* @see [Documentation](https://docs.tpeoficial.com/docs/dymo-api/private/email-validation)
|
|
120
121
|
*/
|
|
121
122
|
async isValidEmail(email, rules = this.rules.email) {
|
|
122
123
|
return await PrivateAPI.isValidEmail(this.axiosClient, email, rules);
|
|
123
124
|
}
|
|
124
125
|
;
|
|
126
|
+
/**
|
|
127
|
+
* Validates the given email against the configured rules.
|
|
128
|
+
*
|
|
129
|
+
* This method requires either the root API key or the API key to be set.
|
|
130
|
+
* If neither is set, it will throw an error.
|
|
131
|
+
*
|
|
132
|
+
* @param {string} [phone] - Phone number to validate.
|
|
133
|
+
* @param {NegativePhoneRules[]} [rules] - Optional rules for validation. Some rules are premium features.
|
|
134
|
+
* @important
|
|
135
|
+
* **⚠️ HIGH_RISK_SCORE is a [PREMIUM](https://docs.tpeoficial.com/docs/dymo-api/private/data-verifier) feature.**
|
|
136
|
+
* @returns {Promise<Interfaces.EmailValidatorResponse>} Resolves with the validation response.
|
|
137
|
+
* @throws Will throw an error if validation cannot be performed.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* const valid = await dymoClient.isValidPhone("+34617509462", { deny: ["FRAUD", "INVALID"] });
|
|
141
|
+
*
|
|
142
|
+
* @see [Documentation](https://docs.tpeoficial.com/docs/dymo-api/private/phone-validation)
|
|
143
|
+
*/
|
|
144
|
+
async isValidPhone(phone, rules = this.rules.phone) {
|
|
145
|
+
return await PrivateAPI.isValidPhone(this.axiosClient, phone, rules);
|
|
146
|
+
}
|
|
147
|
+
;
|
|
125
148
|
/**
|
|
126
149
|
* Protects the given request against the configured rules.
|
|
127
150
|
*
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type AxiosInstance } from "axios";
|
|
2
|
+
import * as Interfaces from "../../../../lib/types/interfaces";
|
|
3
|
+
/**
|
|
4
|
+
* Validates an phone using a secure verification endpoint.
|
|
5
|
+
*
|
|
6
|
+
* @param {string | null} token - Authentication token (required).
|
|
7
|
+
* @param {Interfaces.PhoneValidator} phone - Phone to validate.
|
|
8
|
+
* @param {Interfaces.PhoneValidatorRules} [rules] - Deny rules. Defaults to ["FRAUD", "INVALID"].
|
|
9
|
+
*
|
|
10
|
+
* Deny rules (some are premium ⚠️):
|
|
11
|
+
* - "FRAUD", "INVALID", "HIGH_RISK_SCORE" ⚠️
|
|
12
|
+
*
|
|
13
|
+
* @returns {Promise<boolean>} True if the phone passes all deny rules, false otherwise.
|
|
14
|
+
* @throws Error if token is null, rules are empty, or request fails.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const valid = await isValidPhone(apiToken, "+34617509462", { deny: ["FRAUD", "INVALID" });
|
|
18
|
+
*/
|
|
19
|
+
export declare const isValidPhone: (axiosClient: AxiosInstance, phone: Interfaces.PhoneValidator, rules: Interfaces.PhoneValidatorRules) => Promise<any>;
|
|
@@ -2,5 +2,6 @@ export * from "./functions/extractWithTextly";
|
|
|
2
2
|
export * from "./functions/getRandom";
|
|
3
3
|
export * from "./functions/isValidDataRaw";
|
|
4
4
|
export * from "./functions/isValidEmail";
|
|
5
|
+
export * from "./functions/isValidPhone";
|
|
5
6
|
export * from "./functions/protectReq";
|
|
6
7
|
export * from "./functions/sendEmail";
|
package/dist/types/dymo-api.d.ts
CHANGED
|
@@ -83,7 +83,7 @@ declare class DymoAPI {
|
|
|
83
83
|
* This method requires either the root API key or the API key to be set.
|
|
84
84
|
* If neither is set, it will throw an error.
|
|
85
85
|
*
|
|
86
|
-
* @param {string} [email] -
|
|
86
|
+
* @param {string} [email] - Email address to validate.
|
|
87
87
|
* @param {NegativeEmailRules[]} [rules] - Optional rules for validation. Some rules are premium features.
|
|
88
88
|
* @important
|
|
89
89
|
* **⚠️ NO_MX_RECORDS, HIGH_RISK_SCORE and NO_REACHABLE are [PREMIUM](https://docs.tpeoficial.com/docs/dymo-api/private/data-verifier) features.**
|
|
@@ -93,9 +93,28 @@ declare class DymoAPI {
|
|
|
93
93
|
* @example
|
|
94
94
|
* const valid = await dymoClient.isValidEmail("user@example.com", { deny: ["FRAUD", "NO_MX_RECORDS"] });
|
|
95
95
|
*
|
|
96
|
-
* @see [Documentation](https://docs.tpeoficial.com/docs/dymo-api/private/
|
|
96
|
+
* @see [Documentation](https://docs.tpeoficial.com/docs/dymo-api/private/email-validation)
|
|
97
97
|
*/
|
|
98
98
|
isValidEmail(email: Interfaces.EmailValidator, rules?: Interfaces.EmailValidatorRules): Promise<Interfaces.EmailValidatorResponse>;
|
|
99
|
+
/**
|
|
100
|
+
* Validates the given email against the configured rules.
|
|
101
|
+
*
|
|
102
|
+
* This method requires either the root API key or the API key to be set.
|
|
103
|
+
* If neither is set, it will throw an error.
|
|
104
|
+
*
|
|
105
|
+
* @param {string} [phone] - Phone number to validate.
|
|
106
|
+
* @param {NegativePhoneRules[]} [rules] - Optional rules for validation. Some rules are premium features.
|
|
107
|
+
* @important
|
|
108
|
+
* **⚠️ HIGH_RISK_SCORE is a [PREMIUM](https://docs.tpeoficial.com/docs/dymo-api/private/data-verifier) feature.**
|
|
109
|
+
* @returns {Promise<Interfaces.EmailValidatorResponse>} Resolves with the validation response.
|
|
110
|
+
* @throws Will throw an error if validation cannot be performed.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* const valid = await dymoClient.isValidPhone("+34617509462", { deny: ["FRAUD", "INVALID"] });
|
|
114
|
+
*
|
|
115
|
+
* @see [Documentation](https://docs.tpeoficial.com/docs/dymo-api/private/phone-validation)
|
|
116
|
+
*/
|
|
117
|
+
isValidPhone(phone: Interfaces.PhoneValidator, rules?: Interfaces.PhoneValidatorRules): Promise<Interfaces.PhoneValidatorResponse>;
|
|
99
118
|
/**
|
|
100
119
|
* Protects the given request against the configured rules.
|
|
101
120
|
*
|
|
@@ -243,4 +262,4 @@ declare class DymoAPI {
|
|
|
243
262
|
isValidPwd(data: Interfaces.IsValidPwdData): Promise<Interfaces.PasswordValidationResult>;
|
|
244
263
|
}
|
|
245
264
|
export default DymoAPI;
|
|
246
|
-
export type { EmailValidatorRules,
|
|
265
|
+
export type { EmailValidatorRules, NegativeEmailRules, DataEmailValidationAnalysis, PhoneValidatorRules, NegativePhoneRules, DataPhoneValidationAnalysis, WafRules, SensitiveInfoRules } from "./lib/types/interfaces";
|
|
@@ -28,7 +28,7 @@ export interface Validator {
|
|
|
28
28
|
* Credit card number or object to validate.
|
|
29
29
|
* Checks for fraud, test cards, card type, and optional blocklist or risk score plugins.
|
|
30
30
|
*/
|
|
31
|
-
creditCard?:
|
|
31
|
+
creditCard?: CreditCard;
|
|
32
32
|
/**
|
|
33
33
|
* IP address to validate. Example: `192.168.0.1`.
|
|
34
34
|
* Validation includes type (IPv4/IPv6), class (A-E), geolocation, proxy/hosting detection, fraud, and plugins.
|
|
@@ -64,6 +64,14 @@ export type EmailValidator = Email;
|
|
|
64
64
|
* ⚠️ NO_MX_RECORDS, PROXIED_EMAIL, FREE_SUBDOMAIN, CORPORATE, NO_GRAVATAR, and HIGH_RISK_SCORE are premium features.
|
|
65
65
|
*/
|
|
66
66
|
export type NegativeEmailRules = "FRAUD" | "INVALID" | "NO_MX_RECORDS" | "PROXIED_EMAIL" | "FREE_SUBDOMAIN" | "PERSONAL_EMAIL" | "CORPORATE_EMAIL" | "NO_REPLY_EMAIL" | "ROLE_ACCOUNT" | "NO_GRAVATAR" | "NO_REACHABLE" | "HIGH_RISK_SCORE";
|
|
67
|
+
export type PhoneValidator = Phone;
|
|
68
|
+
/**
|
|
69
|
+
* @typedef {"FRAUD"|"INVALID"|"HIGH_RISK_SCORE"} NegativePhoneRules
|
|
70
|
+
* ⚠️ HIGH_RISK_SCORE is a premium feature.
|
|
71
|
+
* @description
|
|
72
|
+
* Values indicating why an phone is considered negative.
|
|
73
|
+
*/
|
|
74
|
+
export type NegativePhoneRules = "FRAUD" | "INVALID" | "HIGH_RISK_SCORE";
|
|
67
75
|
export type NegativeSensitiveInfoRules = "EMAIL" | "PHONE" | "CREDIT_CARD" | "URL" | "DOMAIN" | "IP" | "WALLET" | "USER_AGENT";
|
|
68
76
|
/**
|
|
69
77
|
* Response returned by the email validator.
|
|
@@ -78,6 +86,19 @@ export type EmailValidatorResponse = {
|
|
|
78
86
|
/** Detailed analysis of the email validation result. */
|
|
79
87
|
response: DataEmailValidationAnalysis;
|
|
80
88
|
};
|
|
89
|
+
/**
|
|
90
|
+
* Response returned by the phone validator.
|
|
91
|
+
*/
|
|
92
|
+
export type PhoneValidatorResponse = {
|
|
93
|
+
/** The validated phone number. */
|
|
94
|
+
phone: string;
|
|
95
|
+
/** Whether the email is allowed (not blocked/fraudulent). */
|
|
96
|
+
allow: boolean;
|
|
97
|
+
/** List of rules indicating why the email may be considered negative. */
|
|
98
|
+
reasons: NegativePhoneRules[];
|
|
99
|
+
/** Detailed analysis of the email validation result. */
|
|
100
|
+
response: DataPhoneValidationAnalysis;
|
|
101
|
+
};
|
|
81
102
|
/**
|
|
82
103
|
* Response returned by the sensitive info validator.
|
|
83
104
|
*/
|
|
@@ -141,6 +162,45 @@ export interface DataEmailValidationAnalysis {
|
|
|
141
162
|
urlShortener?: boolean;
|
|
142
163
|
};
|
|
143
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* Detailed analysis of an phone validation.
|
|
167
|
+
*/
|
|
168
|
+
export interface DataPhoneValidationAnalysis {
|
|
169
|
+
/** Whether the phone number is valid. */
|
|
170
|
+
valid: boolean;
|
|
171
|
+
/** Whether the phone number is fraudulent. */
|
|
172
|
+
fraud: boolean;
|
|
173
|
+
/** The phone number being analyzed. */
|
|
174
|
+
phone: string;
|
|
175
|
+
/** The country code for the phone number. */
|
|
176
|
+
prefix: string;
|
|
177
|
+
/** The line type for the phone number. */
|
|
178
|
+
number: string;
|
|
179
|
+
/** The line type for the phone number. */
|
|
180
|
+
lineType: "PREMIUM_RATE" | "TOLL_FREE" | "SHARED_COST" | "VOIP" | "PERSONAL_NUMBER" | "PAGER" | "UAN" | "VOICEMAIL" | "FIXED_LINE_OR_MOBILE" | "FIXED_LINE" | "MOBILE" | "Unknown";
|
|
181
|
+
/** The carrier information for the phone number. */
|
|
182
|
+
carrierInfo: {
|
|
183
|
+
/** The carrier name for the phone number. */
|
|
184
|
+
carrierName: string;
|
|
185
|
+
/** The accuracy of the carrier information. */
|
|
186
|
+
accuracy: number;
|
|
187
|
+
/** The carrier country for the phone number. */
|
|
188
|
+
carrierCountry: string;
|
|
189
|
+
/** The carrier country code for the phone number. */
|
|
190
|
+
carrierCountryCode: string;
|
|
191
|
+
};
|
|
192
|
+
/** The country for the phone number. */
|
|
193
|
+
country: string;
|
|
194
|
+
/** The country code for the phone number. */
|
|
195
|
+
countryCode: string;
|
|
196
|
+
/** Results from optional validation plugins. */
|
|
197
|
+
plugins: {
|
|
198
|
+
/** Whether the phone number is blocked by a blocklist. */
|
|
199
|
+
blocklist?: boolean;
|
|
200
|
+
/** The risk score for the phone number. */
|
|
201
|
+
riskScore?: number;
|
|
202
|
+
};
|
|
203
|
+
}
|
|
144
204
|
export interface DataValidationAnalysis {
|
|
145
205
|
/** URL validation result. */
|
|
146
206
|
url: {
|
|
@@ -181,42 +241,7 @@ export interface DataValidationAnalysis {
|
|
|
181
241
|
/** Email validation result. */
|
|
182
242
|
email: DataEmailValidationAnalysis;
|
|
183
243
|
/** Phone validation result. */
|
|
184
|
-
phone:
|
|
185
|
-
/** Whether the phone number is valid. */
|
|
186
|
-
valid: boolean;
|
|
187
|
-
/** Whether the phone number is fraudulent. */
|
|
188
|
-
fraud: boolean;
|
|
189
|
-
/** The phone number being analyzed. */
|
|
190
|
-
phone: string;
|
|
191
|
-
/** The country code for the phone number. */
|
|
192
|
-
prefix: string;
|
|
193
|
-
/** The line type for the phone number. */
|
|
194
|
-
number: string;
|
|
195
|
-
/** The line type for the phone number. */
|
|
196
|
-
lineType: "PREMIUM_RATE" | "TOLL_FREE" | "SHARED_COST" | "VOIP" | "PERSONAL_NUMBER" | "PAGER" | "UAN" | "VOICEMAIL" | "FIXED_LINE_OR_MOBILE" | "FIXED_LINE" | "MOBILE" | "Unknown";
|
|
197
|
-
/** The carrier information for the phone number. */
|
|
198
|
-
carrierInfo: {
|
|
199
|
-
/** The carrier name for the phone number. */
|
|
200
|
-
carrierName: string;
|
|
201
|
-
/** The accuracy of the carrier information. */
|
|
202
|
-
accuracy: number;
|
|
203
|
-
/** The carrier country for the phone number. */
|
|
204
|
-
carrierCountry: string;
|
|
205
|
-
/** The carrier country code for the phone number. */
|
|
206
|
-
carrierCountryCode: string;
|
|
207
|
-
};
|
|
208
|
-
/** The country for the phone number. */
|
|
209
|
-
country: string;
|
|
210
|
-
/** The country code for the phone number. */
|
|
211
|
-
countryCode: string;
|
|
212
|
-
/** Results from optional validation plugins. */
|
|
213
|
-
plugins: {
|
|
214
|
-
/** Whether the phone number is blocked by a blocklist. */
|
|
215
|
-
blocklist?: boolean;
|
|
216
|
-
/** The risk score for the phone number. */
|
|
217
|
-
riskScore?: number;
|
|
218
|
-
};
|
|
219
|
-
};
|
|
244
|
+
phone: DataPhoneValidationAnalysis;
|
|
220
245
|
/** Domain validation result. */
|
|
221
246
|
domain: {
|
|
222
247
|
/** Whether the domain is valid. */
|
|
@@ -1,28 +1,31 @@
|
|
|
1
|
-
export type Email = `${string}@${string}` | string;
|
|
1
|
+
export type Email = `${string}@${string}.${string}` | string;
|
|
2
|
+
type Digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
|
|
2
3
|
export type Phone = {
|
|
3
4
|
/** The country code of the phone number. */
|
|
4
5
|
iso: any;
|
|
5
6
|
/** The phone number. */
|
|
6
7
|
phone: string;
|
|
7
|
-
} | string;
|
|
8
|
-
|
|
8
|
+
} | `+${string}` | string;
|
|
9
|
+
type CvcString = `${Digit}${Digit}${Digit}` | string | number;
|
|
10
|
+
export type CreditCard = {
|
|
9
11
|
/** The credit card number. */
|
|
10
12
|
pan: string | number;
|
|
11
13
|
/** The expiration date of the credit card. */
|
|
12
14
|
expirationDate?: string;
|
|
13
15
|
/** The security code of the credit card. */
|
|
14
|
-
cvc?:
|
|
16
|
+
cvc?: CvcString;
|
|
15
17
|
/** The security code of the credit card. */
|
|
16
|
-
cvv?:
|
|
17
|
-
}
|
|
18
|
+
cvv?: CvcString;
|
|
19
|
+
} | string;
|
|
18
20
|
export interface HTTPRequest {
|
|
19
21
|
/** The URL to make the request to. */
|
|
20
22
|
url: string;
|
|
21
23
|
/** The HTTP method to use. */
|
|
22
|
-
method:
|
|
24
|
+
method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | string;
|
|
23
25
|
/** The headers to include in the request. */
|
|
24
26
|
headers?: Record<string, string>;
|
|
25
27
|
/** The body of the request. */
|
|
26
28
|
body?: string | object | null;
|
|
27
29
|
[key: string]: any;
|
|
28
30
|
}
|
|
31
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as WellKnownBots from "./well-known-bots";
|
|
2
|
-
import { NegativeEmailRules, NegativeSensitiveInfoRules } from "./data-verifier";
|
|
2
|
+
import { NegativeEmailRules, NegativePhoneRules, NegativeSensitiveInfoRules } from "./data-verifier";
|
|
3
3
|
type Mode = "LIVE" | "DRY_RUN";
|
|
4
4
|
export type NegativeWafRules = "FRAUD" | "VPN" | "PROXY" | "TOR_NETWORK";
|
|
5
5
|
export interface WafRules {
|
|
@@ -11,12 +11,17 @@ export interface EmailValidatorRules {
|
|
|
11
11
|
mode?: Mode;
|
|
12
12
|
deny: NegativeEmailRules[];
|
|
13
13
|
}
|
|
14
|
+
export interface PhoneValidatorRules {
|
|
15
|
+
mode?: Mode;
|
|
16
|
+
deny: NegativePhoneRules[];
|
|
17
|
+
}
|
|
14
18
|
export interface SensitiveInfoRules {
|
|
15
19
|
mode?: Mode;
|
|
16
20
|
deny: NegativeSensitiveInfoRules[];
|
|
17
21
|
}
|
|
18
22
|
export interface Rules {
|
|
19
23
|
email?: EmailValidatorRules;
|
|
24
|
+
phone?: PhoneValidatorRules;
|
|
20
25
|
sensitiveInfo?: SensitiveInfoRules;
|
|
21
26
|
waf?: WafRules;
|
|
22
27
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dymo-api",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.23",
|
|
4
4
|
"description": "Flow system for Dymo API.",
|
|
5
5
|
"main": "dist/cjs/dymo-api.js",
|
|
6
6
|
"module": "dist/esm/dymo-api.js",
|
|
@@ -39,7 +39,18 @@
|
|
|
39
39
|
"Dymo",
|
|
40
40
|
"Dymo API",
|
|
41
41
|
"TPEOficial",
|
|
42
|
-
"Ciphera"
|
|
42
|
+
"Ciphera",
|
|
43
|
+
"email verification",
|
|
44
|
+
"email validation",
|
|
45
|
+
"disposable email detector",
|
|
46
|
+
"disposable checker",
|
|
47
|
+
"fraud detection",
|
|
48
|
+
"anti fraud",
|
|
49
|
+
"multiaccount detection",
|
|
50
|
+
"fake user prevention",
|
|
51
|
+
"bot detection",
|
|
52
|
+
"spam protection",
|
|
53
|
+
"user validation"
|
|
43
54
|
],
|
|
44
55
|
"author": "TPEOficial LLC",
|
|
45
56
|
"license": "Apache-2.0",
|