dymo-api 1.1.4 → 1.1.6

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.
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.extractWithTextly = exports.getRandom = exports.sendEmail = exports.isValidData = void 0;
39
+ exports.extractWithTextly = exports.getRandom = exports.sendEmail = exports.isValidEmail = exports.isValidData = void 0;
40
40
  const path_1 = __importDefault(require("path"));
41
41
  const react_1 = __importDefault(require("react"));
42
42
  const promises_1 = __importDefault(require("fs/promises"));
@@ -81,6 +81,73 @@ const isValidData = async (token, data) => {
81
81
  }
82
82
  };
83
83
  exports.isValidData = isValidData;
84
+ /**
85
+ * Validates an email using a secure verification endpoint.
86
+ *
87
+ * @param {string | null} token - Authentication token (required).
88
+ * @param {Interfaces.EmailValidator} email - Email to validate.
89
+ * @param {Interfaces.EmailValidatorRules} [rules] - Deny rules. Defaults to ["FRAUD", "INVALID", "NO_MX_RECORDS", "NO_REPLY_EMAIL"].
90
+ *
91
+ * Deny rules (some are premium ⚠️):
92
+ * - "FRAUD", "INVALID", "NO_MX_RECORDS" ⚠️, "PROXIED_EMAIL" ⚠️, "FREE_SUBDOMAIN" ⚠️,
93
+ * "PERSONAL_EMAIL", "CORPORATE_EMAIL", "NO_REPLY_EMAIL", "ROLE_ACCOUNT", "NO_REACHABLE", "HIGH_RISK_SCORE" ⚠️
94
+ *
95
+ * @returns {Promise<boolean>} True if the email passes all deny rules, false otherwise.
96
+ * @throws Error if token is null, rules are empty, or request fails.
97
+ *
98
+ * @example
99
+ * const valid = await isValidEmail(apiToken, "user@example.com", { deny: ["FRAUD", "NO_MX_RECORDS"] });
100
+ */
101
+ const isValidEmail = async (token, email, rules = {
102
+ deny: [
103
+ "FRAUD", "INVALID", "NO_MX_RECORDS", "NO_REPLY_EMAIL"
104
+ ]
105
+ }) => {
106
+ if (token === null)
107
+ throw customError(3000, "Invalid private token.");
108
+ if (rules.deny.length === 0)
109
+ throw customError(1500, "You must provide at least one deny rule.");
110
+ try {
111
+ const responseEmail = (await config_1.axiosApiUrl.post("/private/secure/verify", {
112
+ email,
113
+ plugins: [
114
+ rules.deny.includes("NO_MX_RECORDS") ? "mxRecords" : undefined,
115
+ rules.deny.includes("NO_REACHABLE") ? "reachability" : undefined,
116
+ rules.deny.includes("HIGH_RISK_SCORE") ? "riskScore" : undefined
117
+ ]
118
+ }, { headers: { "Content-Type": "application/json", "Authorization": token } })).data.email;
119
+ if (rules.deny.includes("INVALID") && !responseEmail.valid)
120
+ return false;
121
+ if (rules.deny.includes("FRAUD") && responseEmail.fraud)
122
+ return false;
123
+ if (rules.deny.includes("PROXIED_EMAIL") && responseEmail.proxiedEmail)
124
+ return false;
125
+ if (rules.deny.includes("FREE_SUBDOMAIN") && responseEmail.freeSubdomain)
126
+ return false;
127
+ if (rules.deny.includes("PERSONAL_EMAIL") && !responseEmail.corporate)
128
+ return false;
129
+ if (rules.deny.includes("CORPORATE_EMAIL") && responseEmail.corporate)
130
+ return false;
131
+ if (rules.deny.includes("NO_MX_RECORDS") && responseEmail.plugins.mxRecords.length === 0)
132
+ return false;
133
+ if (rules.deny.includes("NO_REPLY_EMAIL") && responseEmail.noReply)
134
+ return false;
135
+ if (rules.deny.includes("ROLE_ACCOUNT") && responseEmail.plugins.roleAccount)
136
+ return false;
137
+ if (rules.deny.includes("NO_REACHABLE") && !responseEmail.plugins.reachable)
138
+ return false;
139
+ if (rules.deny.includes("HIGH_RISK_SCORE") && responseEmail.plugins.riskScore >= 80)
140
+ return false;
141
+ return true;
142
+ }
143
+ catch (error) {
144
+ const statusCode = error.response?.status || 500;
145
+ const errorMessage = error.response?.data?.message || error.message;
146
+ const errorDetails = JSON.stringify(error.response?.data || {});
147
+ throw customError(5000, `Error ${statusCode}: ${errorMessage}. Details: ${errorDetails}`);
148
+ }
149
+ };
150
+ exports.isValidEmail = isValidEmail;
84
151
  /**
85
152
  * Sends an email using a secure sending endpoint.
86
153
  *
@@ -64,6 +64,7 @@ class DymoAPI {
64
64
  this.baseUrl = baseUrl;
65
65
  (0, config_1.setBaseUrl)(baseUrl);
66
66
  }
67
+ ;
67
68
  // FUNCTIONS / Private.
68
69
  /**
69
70
  * Validates the given data against the configured validation settings.
@@ -89,6 +90,29 @@ class DymoAPI {
89
90
  async isValidData(data) {
90
91
  return await PrivateAPI.isValidData(this.rootApiKey || this.apiKey, data);
91
92
  }
93
+ ;
94
+ /**
95
+ * Validates the given email against the configured rules.
96
+ *
97
+ * This method requires either the root API key or the API key to be set.
98
+ * If neither is set, it will throw an error.
99
+ *
100
+ * @param {string} [email] - Optional email address to validate.
101
+ * @param {NegativeEmailRules[]} [rules] - Optional rules for validation. Some rules are premium features.
102
+ * @important
103
+ * **⚠️ NO_MX_RECORDS, HIGH_RISK_SCORE and NO_REACHABLE are [PREMIUM](https://docs.tpeoficial.com/docs/dymo-api/private/data-verifier) features.**
104
+ * @returns {Promise<Interfaces.EmailValidatorResponse>} Resolves with the validation response.
105
+ * @throws Will throw an error if validation cannot be performed.
106
+ *
107
+ * @example
108
+ * const valid = await dymoClient.isValidEmail("user@example.com", { deny: ["FRAUD", "NO_MX_RECORDS"] });
109
+ *
110
+ * @see [Documentation](https://docs.tpeoficial.com/docs/dymo-api/private/data-verifier)
111
+ */
112
+ async isValidEmail(email, rules) {
113
+ return await PrivateAPI.isValidEmail(this.rootApiKey || this.apiKey, email, rules);
114
+ }
115
+ ;
92
116
  /**
93
117
  * Sends an email using the configured email client settings.
94
118
  *
@@ -120,6 +144,7 @@ class DymoAPI {
120
144
  console.error(`[${config_1.default.lib.name}] You must configure the email client settings.`);
121
145
  return await PrivateAPI.sendEmail(this.rootApiKey || this.apiKey, { serverEmailConfig: this.serverEmailConfig, ...data });
122
146
  }
147
+ ;
123
148
  /**
124
149
  * Generates a random number between the provided min and max values.
125
150
  *
@@ -138,6 +163,7 @@ class DymoAPI {
138
163
  async getRandom(data) {
139
164
  return await PrivateAPI.getRandom(this.rootApiKey || this.apiKey, data);
140
165
  }
166
+ ;
141
167
  /**
142
168
  * Extracts structured data from a given string using Textly.
143
169
  *
@@ -153,6 +179,7 @@ class DymoAPI {
153
179
  async extractWithTextly(data) {
154
180
  return await PrivateAPI.extractWithTextly(this.rootApiKey || this.apiKey, data);
155
181
  }
182
+ ;
156
183
  // FUNCTIONS / Public.
157
184
  /**
158
185
  * Retrieves the prayer times for the given location.
@@ -171,6 +198,7 @@ class DymoAPI {
171
198
  async getPrayerTimes(data) {
172
199
  return await PublicAPI.getPrayerTimes(data);
173
200
  }
201
+ ;
174
202
  /**
175
203
  * Satinizes the input, replacing any special characters with their HTML
176
204
  * entities.
@@ -185,6 +213,7 @@ class DymoAPI {
185
213
  async satinizer(data) {
186
214
  return await PublicAPI.satinizer(data);
187
215
  }
216
+ ;
188
217
  /**
189
218
  * Validates a password based on the given parameters.
190
219
  *
@@ -213,5 +242,7 @@ class DymoAPI {
213
242
  async isValidPwd(data) {
214
243
  return await PublicAPI.isValidPwd(data);
215
244
  }
245
+ ;
216
246
  }
247
+ ;
217
248
  exports.default = DymoAPI;
@@ -1,9 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- ;
4
- ;
5
- ;
6
- ;
7
- ;
8
- ;
9
- ;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ ;
18
+ ;
19
+ ;
20
+ ;
21
+ ;
22
+ __exportStar(require("./data-verifier.cjs"), exports);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -41,6 +41,72 @@ export const isValidData = async (token, data) => {
41
41
  throw customError(5000, `Error ${statusCode}: ${errorMessage}. Details: ${errorDetails}`);
42
42
  }
43
43
  };
44
+ /**
45
+ * Validates an email using a secure verification endpoint.
46
+ *
47
+ * @param {string | null} token - Authentication token (required).
48
+ * @param {Interfaces.EmailValidator} email - Email to validate.
49
+ * @param {Interfaces.EmailValidatorRules} [rules] - Deny rules. Defaults to ["FRAUD", "INVALID", "NO_MX_RECORDS", "NO_REPLY_EMAIL"].
50
+ *
51
+ * Deny rules (some are premium ⚠️):
52
+ * - "FRAUD", "INVALID", "NO_MX_RECORDS" ⚠️, "PROXIED_EMAIL" ⚠️, "FREE_SUBDOMAIN" ⚠️,
53
+ * "PERSONAL_EMAIL", "CORPORATE_EMAIL", "NO_REPLY_EMAIL", "ROLE_ACCOUNT", "NO_REACHABLE", "HIGH_RISK_SCORE" ⚠️
54
+ *
55
+ * @returns {Promise<boolean>} True if the email passes all deny rules, false otherwise.
56
+ * @throws Error if token is null, rules are empty, or request fails.
57
+ *
58
+ * @example
59
+ * const valid = await isValidEmail(apiToken, "user@example.com", { deny: ["FRAUD", "NO_MX_RECORDS"] });
60
+ */
61
+ export const isValidEmail = async (token, email, rules = {
62
+ deny: [
63
+ "FRAUD", "INVALID", "NO_MX_RECORDS", "NO_REPLY_EMAIL"
64
+ ]
65
+ }) => {
66
+ if (token === null)
67
+ throw customError(3000, "Invalid private token.");
68
+ if (rules.deny.length === 0)
69
+ throw customError(1500, "You must provide at least one deny rule.");
70
+ try {
71
+ const responseEmail = (await axiosApiUrl.post("/private/secure/verify", {
72
+ email,
73
+ plugins: [
74
+ rules.deny.includes("NO_MX_RECORDS") ? "mxRecords" : undefined,
75
+ rules.deny.includes("NO_REACHABLE") ? "reachability" : undefined,
76
+ rules.deny.includes("HIGH_RISK_SCORE") ? "riskScore" : undefined
77
+ ]
78
+ }, { headers: { "Content-Type": "application/json", "Authorization": token } })).data.email;
79
+ if (rules.deny.includes("INVALID") && !responseEmail.valid)
80
+ return false;
81
+ if (rules.deny.includes("FRAUD") && responseEmail.fraud)
82
+ return false;
83
+ if (rules.deny.includes("PROXIED_EMAIL") && responseEmail.proxiedEmail)
84
+ return false;
85
+ if (rules.deny.includes("FREE_SUBDOMAIN") && responseEmail.freeSubdomain)
86
+ return false;
87
+ if (rules.deny.includes("PERSONAL_EMAIL") && !responseEmail.corporate)
88
+ return false;
89
+ if (rules.deny.includes("CORPORATE_EMAIL") && responseEmail.corporate)
90
+ return false;
91
+ if (rules.deny.includes("NO_MX_RECORDS") && responseEmail.plugins.mxRecords.length === 0)
92
+ return false;
93
+ if (rules.deny.includes("NO_REPLY_EMAIL") && responseEmail.noReply)
94
+ return false;
95
+ if (rules.deny.includes("ROLE_ACCOUNT") && responseEmail.plugins.roleAccount)
96
+ return false;
97
+ if (rules.deny.includes("NO_REACHABLE") && !responseEmail.plugins.reachable)
98
+ return false;
99
+ if (rules.deny.includes("HIGH_RISK_SCORE") && responseEmail.plugins.riskScore >= 80)
100
+ return false;
101
+ return true;
102
+ }
103
+ catch (error) {
104
+ const statusCode = error.response?.status || 500;
105
+ const errorMessage = error.response?.data?.message || error.message;
106
+ const errorDetails = JSON.stringify(error.response?.data || {});
107
+ throw customError(5000, `Error ${statusCode}: ${errorMessage}. Details: ${errorDetails}`);
108
+ }
109
+ };
44
110
  /**
45
111
  * Sends an email using a secure sending endpoint.
46
112
  *
@@ -29,6 +29,7 @@ class DymoAPI {
29
29
  this.baseUrl = baseUrl;
30
30
  setBaseUrl(baseUrl);
31
31
  }
32
+ ;
32
33
  // FUNCTIONS / Private.
33
34
  /**
34
35
  * Validates the given data against the configured validation settings.
@@ -54,6 +55,29 @@ class DymoAPI {
54
55
  async isValidData(data) {
55
56
  return await PrivateAPI.isValidData(this.rootApiKey || this.apiKey, data);
56
57
  }
58
+ ;
59
+ /**
60
+ * Validates the given email against the configured rules.
61
+ *
62
+ * This method requires either the root API key or the API key to be set.
63
+ * If neither is set, it will throw an error.
64
+ *
65
+ * @param {string} [email] - Optional email address to validate.
66
+ * @param {NegativeEmailRules[]} [rules] - Optional rules for validation. Some rules are premium features.
67
+ * @important
68
+ * **⚠️ NO_MX_RECORDS, HIGH_RISK_SCORE and NO_REACHABLE are [PREMIUM](https://docs.tpeoficial.com/docs/dymo-api/private/data-verifier) features.**
69
+ * @returns {Promise<Interfaces.EmailValidatorResponse>} Resolves with the validation response.
70
+ * @throws Will throw an error if validation cannot be performed.
71
+ *
72
+ * @example
73
+ * const valid = await dymoClient.isValidEmail("user@example.com", { deny: ["FRAUD", "NO_MX_RECORDS"] });
74
+ *
75
+ * @see [Documentation](https://docs.tpeoficial.com/docs/dymo-api/private/data-verifier)
76
+ */
77
+ async isValidEmail(email, rules) {
78
+ return await PrivateAPI.isValidEmail(this.rootApiKey || this.apiKey, email, rules);
79
+ }
80
+ ;
57
81
  /**
58
82
  * Sends an email using the configured email client settings.
59
83
  *
@@ -85,6 +109,7 @@ class DymoAPI {
85
109
  console.error(`[${config.lib.name}] You must configure the email client settings.`);
86
110
  return await PrivateAPI.sendEmail(this.rootApiKey || this.apiKey, { serverEmailConfig: this.serverEmailConfig, ...data });
87
111
  }
112
+ ;
88
113
  /**
89
114
  * Generates a random number between the provided min and max values.
90
115
  *
@@ -103,6 +128,7 @@ class DymoAPI {
103
128
  async getRandom(data) {
104
129
  return await PrivateAPI.getRandom(this.rootApiKey || this.apiKey, data);
105
130
  }
131
+ ;
106
132
  /**
107
133
  * Extracts structured data from a given string using Textly.
108
134
  *
@@ -118,6 +144,7 @@ class DymoAPI {
118
144
  async extractWithTextly(data) {
119
145
  return await PrivateAPI.extractWithTextly(this.rootApiKey || this.apiKey, data);
120
146
  }
147
+ ;
121
148
  // FUNCTIONS / Public.
122
149
  /**
123
150
  * Retrieves the prayer times for the given location.
@@ -136,6 +163,7 @@ class DymoAPI {
136
163
  async getPrayerTimes(data) {
137
164
  return await PublicAPI.getPrayerTimes(data);
138
165
  }
166
+ ;
139
167
  /**
140
168
  * Satinizes the input, replacing any special characters with their HTML
141
169
  * entities.
@@ -150,6 +178,7 @@ class DymoAPI {
150
178
  async satinizer(data) {
151
179
  return await PublicAPI.satinizer(data);
152
180
  }
181
+ ;
153
182
  /**
154
183
  * Validates a password based on the given parameters.
155
184
  *
@@ -178,5 +207,7 @@ class DymoAPI {
178
207
  async isValidPwd(data) {
179
208
  return await PublicAPI.isValidPwd(data);
180
209
  }
210
+ ;
181
211
  }
212
+ ;
182
213
  export default DymoAPI;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ ;
2
+ ;
3
+ ;
4
+ ;
5
+ ;
6
+ export * from "./data-verifier";
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import * as Interfaces from "../lib/interfaces";
1
+ import * as Interfaces from "../lib/types/interfaces";
2
2
  /**
3
3
  * Validates the provided data using a secure verification endpoint.
4
4
  *
@@ -12,6 +12,24 @@ import * as Interfaces from "../lib/interfaces";
12
12
  * or if an error occurs during the verification request.
13
13
  */
14
14
  export declare const isValidData: (token: string | null, data: Interfaces.Validator) => Promise<any>;
15
+ /**
16
+ * Validates an email using a secure verification endpoint.
17
+ *
18
+ * @param {string | null} token - Authentication token (required).
19
+ * @param {Interfaces.EmailValidator} email - Email to validate.
20
+ * @param {Interfaces.EmailValidatorRules} [rules] - Deny rules. Defaults to ["FRAUD", "INVALID", "NO_MX_RECORDS", "NO_REPLY_EMAIL"].
21
+ *
22
+ * Deny rules (some are premium ⚠️):
23
+ * - "FRAUD", "INVALID", "NO_MX_RECORDS" ⚠️, "PROXIED_EMAIL" ⚠️, "FREE_SUBDOMAIN" ⚠️,
24
+ * "PERSONAL_EMAIL", "CORPORATE_EMAIL", "NO_REPLY_EMAIL", "ROLE_ACCOUNT", "NO_REACHABLE", "HIGH_RISK_SCORE" ⚠️
25
+ *
26
+ * @returns {Promise<boolean>} True if the email passes all deny rules, false otherwise.
27
+ * @throws Error if token is null, rules are empty, or request fails.
28
+ *
29
+ * @example
30
+ * const valid = await isValidEmail(apiToken, "user@example.com", { deny: ["FRAUD", "NO_MX_RECORDS"] });
31
+ */
32
+ export declare const isValidEmail: (token: string | null, email: Interfaces.EmailValidator, rules?: Interfaces.EmailValidatorRules) => Promise<any>;
15
33
  /**
16
34
  * Sends an email using a secure sending endpoint.
17
35
  *
@@ -1,4 +1,4 @@
1
- import * as Interfaces from "../lib/interfaces";
1
+ import * as Interfaces from "../lib/types/interfaces";
2
2
  export declare const getPrayerTimes: (data: Interfaces.PrayerTimesData) => Promise<any>;
3
3
  export declare const satinizer: (data: Interfaces.InputSatinizerData) => Promise<any>;
4
4
  export declare const isValidPwd: (data: Interfaces.IsValidPwdData) => Promise<any>;
@@ -1,4 +1,4 @@
1
- import * as Interfaces from "./lib/interfaces";
1
+ import * as Interfaces from "./lib/types/interfaces";
2
2
  declare class DymoAPI {
3
3
  private rootApiKey;
4
4
  private apiKey;
@@ -49,6 +49,25 @@ declare class DymoAPI {
49
49
  * [Documentation](https://docs.tpeoficial.com/docs/dymo-api/private/data-verifier)
50
50
  */
51
51
  isValidData(data: Interfaces.Validator): Promise<Interfaces.DataValidationAnalysis>;
52
+ /**
53
+ * Validates the given email against the configured rules.
54
+ *
55
+ * This method requires either the root API key or the API key to be set.
56
+ * If neither is set, it will throw an error.
57
+ *
58
+ * @param {string} [email] - Optional email address to validate.
59
+ * @param {NegativeEmailRules[]} [rules] - Optional rules for validation. Some rules are premium features.
60
+ * @important
61
+ * **⚠️ NO_MX_RECORDS, HIGH_RISK_SCORE and NO_REACHABLE are [PREMIUM](https://docs.tpeoficial.com/docs/dymo-api/private/data-verifier) features.**
62
+ * @returns {Promise<Interfaces.EmailValidatorResponse>} Resolves with the validation response.
63
+ * @throws Will throw an error if validation cannot be performed.
64
+ *
65
+ * @example
66
+ * const valid = await dymoClient.isValidEmail("user@example.com", { deny: ["FRAUD", "NO_MX_RECORDS"] });
67
+ *
68
+ * @see [Documentation](https://docs.tpeoficial.com/docs/dymo-api/private/data-verifier)
69
+ */
70
+ isValidEmail(email: Interfaces.EmailValidator, rules?: Interfaces.EmailValidatorRules): Promise<Interfaces.EmailValidatorResponse>;
52
71
  /**
53
72
  * Sends an email using the configured email client settings.
54
73
  *
@@ -0,0 +1,185 @@
1
+ import { MxRecord } from "dns";
2
+ import { Email, Phone, CreditCard } from "./primitives";
3
+ export type VerifyPlugins = "blocklist" | "compromiseDetector" | "mxRecords" | "nsfw" | "reputation" | "riskScore" | "torNetwork" | "typosquatting" | "urlShortener";
4
+ export type ReputationPlugin = "low" | "medium" | "high" | "very-high" | "education" | "governmental" | "unknown";
5
+ export type TyposquattingPlugin = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
6
+ export interface Validator {
7
+ url?: string;
8
+ email?: string;
9
+ phone?: Phone;
10
+ domain?: string;
11
+ creditCard?: string | CreditCard;
12
+ ip?: string;
13
+ wallet?: string;
14
+ userAgent?: string;
15
+ plugins?: VerifyPlugins[];
16
+ }
17
+ export type EmailValidator = Email;
18
+ /**
19
+ * @typedef {"FRAUD"|"INVALID"|"NO_MX_RECORDS"|"PROXIED_EMAIL"|"FREE_SUBDOMAIN"|"PERSONAL"|"CORPORATE"|"NO_REPLY"|"ROLE_ACCOUNT"|"REACHABLE"|"HIGH_RISK_SCORE"} NegativeEmailRules
20
+ *
21
+ * @description
22
+ * Values indicating why an email is considered negative.
23
+ * ⚠️ NO_MX_RECORDS, PROXIED_EMAIL, FREE_SUBDOMAIN, CORPORATE, and HIGH_RISK_SCORE are premium features.
24
+ */
25
+ export type NegativeEmailRules = "FRAUD" | "INVALID" | "NO_MX_RECORDS" | "PROXIED_EMAIL" | "FREE_SUBDOMAIN" | "PERSONAL_EMAIL" | "CORPORATE_EMAIL" | "NO_REPLY_EMAIL" | "ROLE_ACCOUNT" | "NO_REACHABLE" | "HIGH_RISK_SCORE";
26
+ export interface EmailValidatorRules {
27
+ deny: NegativeEmailRules[];
28
+ }
29
+ export type EmailValidatorResponse = boolean;
30
+ export interface DataValidationAnalysis {
31
+ url: {
32
+ valid: boolean;
33
+ fraud: boolean;
34
+ freeSubdomain: boolean;
35
+ customTLD: boolean;
36
+ url: string;
37
+ domain: string;
38
+ plugins: {
39
+ blocklist?: boolean;
40
+ compromiseDetector?: boolean;
41
+ mxRecords: MxRecord[];
42
+ nsfw?: boolean;
43
+ reputation?: ReputationPlugin;
44
+ riskScore?: number;
45
+ torNetwork?: boolean;
46
+ typosquatting?: TyposquattingPlugin;
47
+ urlShortener?: boolean;
48
+ };
49
+ };
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
+ };
74
+ phone: {
75
+ valid: boolean;
76
+ fraud: boolean;
77
+ phone: string;
78
+ prefix: string;
79
+ number: string;
80
+ lineType: "PREMIUM_RATE" | "TOLL_FREE" | "SHARED_COST" | "VOIP" | "PERSONAL_NUMBER" | "PAGER" | "UAN" | "VOICEMAIL" | "FIXED_LINE_OR_MOBILE" | "FIXED_LINE" | "MOBILE" | "Unknown";
81
+ carrierInfo: {
82
+ carrierName: string;
83
+ accuracy: number;
84
+ carrierCountry: string;
85
+ carrierCountryCode: string;
86
+ };
87
+ country: string;
88
+ countryCode: string;
89
+ plugins: {
90
+ blocklist?: boolean;
91
+ riskScore?: number;
92
+ };
93
+ };
94
+ domain: {
95
+ valid: boolean;
96
+ fraud: boolean;
97
+ freeSubdomain: boolean;
98
+ customTLD: boolean;
99
+ domain: string;
100
+ plugins: {
101
+ blocklist?: boolean;
102
+ compromiseDetector?: boolean;
103
+ nsfw?: boolean;
104
+ reputation?: "low" | "medium" | "high" | "very-high" | "education" | "governmental" | "unknown";
105
+ riskScore?: number;
106
+ torNetwork?: boolean;
107
+ typosquatting?: TyposquattingPlugin;
108
+ urlShortener?: boolean;
109
+ };
110
+ };
111
+ creditCard: {
112
+ valid: boolean;
113
+ fraud: boolean;
114
+ test: boolean;
115
+ type: string;
116
+ creditCard: string;
117
+ plugins: {
118
+ blocklist?: boolean;
119
+ riskScore?: number;
120
+ };
121
+ };
122
+ ip: {
123
+ valid: boolean;
124
+ type: "IPv4" | "IPv6" | "Invalid";
125
+ class: "A" | "B" | "C" | "D" | "E" | "Unknown" | "None";
126
+ fraud: boolean;
127
+ ip: string;
128
+ continent: string;
129
+ continentCode: string;
130
+ country: string;
131
+ countryCode: string;
132
+ region: string;
133
+ regionName: string;
134
+ city: string;
135
+ district: string;
136
+ zipCode: string;
137
+ lat: number;
138
+ lon: number;
139
+ timezone: string;
140
+ offset: number;
141
+ currency: string;
142
+ isp: string;
143
+ org: string;
144
+ as: string;
145
+ asname: string;
146
+ mobile: boolean;
147
+ proxy: boolean;
148
+ hosting: boolean;
149
+ plugins: {
150
+ blocklist?: boolean;
151
+ riskScore?: number;
152
+ };
153
+ };
154
+ wallet: {
155
+ valid: boolean;
156
+ fraud: boolean;
157
+ wallet: string;
158
+ type: string;
159
+ plugins: {
160
+ blocklist?: boolean;
161
+ riskScore?: number;
162
+ torNetwork?: boolean;
163
+ };
164
+ };
165
+ userAgent: {
166
+ valid: boolean;
167
+ type?: string;
168
+ clientSlug?: string | null;
169
+ clientName?: string;
170
+ version?: string | null;
171
+ userAgent?: string;
172
+ fraud?: boolean;
173
+ bot?: boolean;
174
+ info?: string;
175
+ os?: string;
176
+ device: {
177
+ type?: string;
178
+ brand?: string;
179
+ };
180
+ plugins?: {
181
+ blocklist?: boolean;
182
+ riskScore?: number;
183
+ };
184
+ };
185
+ }
@@ -0,0 +1,168 @@
1
+ import type * as React from "react";
2
+ export interface SRNG {
3
+ min: number;
4
+ max: number;
5
+ quantity?: number;
6
+ }
7
+ export type Attachment = {
8
+ filename: string;
9
+ path?: string;
10
+ content?: string | Buffer;
11
+ cid?: string;
12
+ };
13
+ export interface ServerEmailConfig {
14
+ host: string;
15
+ port: number;
16
+ secure: boolean;
17
+ auth: {
18
+ user: string;
19
+ pass: string;
20
+ };
21
+ dkim?: {
22
+ domainName: string;
23
+ keySelector: string;
24
+ privateKey: string;
25
+ };
26
+ }
27
+ export type SendEmail = {
28
+ from: string;
29
+ to: string;
30
+ subject: string;
31
+ attachments?: Attachment[];
32
+ options?: {
33
+ priority?: "high" | "normal" | "low";
34
+ composeTailwindClasses?: boolean;
35
+ compileToCssSafe?: boolean;
36
+ onlyVerifiedEmails?: boolean;
37
+ };
38
+ } & ({
39
+ html: string;
40
+ react?: never;
41
+ } | {
42
+ react: React.ReactNode;
43
+ html?: never;
44
+ });
45
+ export interface PrayerTimesData {
46
+ lat?: number;
47
+ lon?: number;
48
+ }
49
+ export interface InputSatinizerData {
50
+ input?: string;
51
+ }
52
+ export interface IsValidPwdData {
53
+ email?: string;
54
+ password?: string;
55
+ bannedWords?: string | string[];
56
+ min?: number;
57
+ max?: number;
58
+ }
59
+ export interface SRNComponent {
60
+ integer: number;
61
+ float: number;
62
+ }
63
+ export interface SRNSummary {
64
+ values: SRNComponent[];
65
+ executionTime: number;
66
+ }
67
+ export interface CountryPrayerTimes {
68
+ country: string;
69
+ prayerTimesByTimezone: {
70
+ timezone: string;
71
+ prayerTimes: {
72
+ coordinates: string;
73
+ date: string;
74
+ calculationParameters: string;
75
+ fajr: string;
76
+ sunrise: string;
77
+ dhuhr: string;
78
+ asr: string;
79
+ sunset: string;
80
+ maghrib: string;
81
+ isha: string;
82
+ };
83
+ }[];
84
+ }
85
+ export interface SatinizedInputAnalysis {
86
+ input: string;
87
+ formats: {
88
+ ascii: boolean;
89
+ bitcoinAddress: boolean;
90
+ cLikeIdentifier: boolean;
91
+ coordinates: boolean;
92
+ crediCard: boolean;
93
+ date: boolean;
94
+ discordUsername: boolean;
95
+ doi: boolean;
96
+ domain: boolean;
97
+ e164Phone: boolean;
98
+ email: boolean;
99
+ emoji: boolean;
100
+ hanUnification: boolean;
101
+ hashtag: boolean;
102
+ hyphenWordBreak: boolean;
103
+ ipv6: boolean;
104
+ ip: boolean;
105
+ jiraTicket: boolean;
106
+ macAddress: boolean;
107
+ name: boolean;
108
+ number: boolean;
109
+ panFromGstin: boolean;
110
+ password: boolean;
111
+ port: boolean;
112
+ tel: boolean;
113
+ text: boolean;
114
+ semver: boolean;
115
+ ssn: boolean;
116
+ uuid: boolean;
117
+ url: boolean;
118
+ urlSlug: boolean;
119
+ username: boolean;
120
+ };
121
+ includes: {
122
+ spaces: boolean;
123
+ hasSql: boolean;
124
+ hasNoSql: boolean;
125
+ letters: boolean;
126
+ uppercase: boolean;
127
+ lowercase: boolean;
128
+ symbols: boolean;
129
+ digits: boolean;
130
+ };
131
+ }
132
+ export interface EmailStatus {
133
+ status: boolean;
134
+ error?: string;
135
+ }
136
+ export interface ValidationDetail {
137
+ validation: string;
138
+ message: string;
139
+ word?: string;
140
+ }
141
+ export interface PasswordValidationResult {
142
+ valid: boolean;
143
+ password: string;
144
+ details: ValidationDetail[];
145
+ }
146
+ export type SchemaType = "string" | "number" | "boolean" | "array" | "object";
147
+ export interface JsonSchemaProperty {
148
+ type: SchemaType;
149
+ items?: JsonSchemaProperty;
150
+ properties?: Record<string, JsonSchemaProperty>;
151
+ required?: string[];
152
+ description?: string;
153
+ format?: string;
154
+ enum?: unknown[];
155
+ minimum?: number;
156
+ maximum?: number;
157
+ minLength?: number;
158
+ maxLength?: number;
159
+ pattern?: string;
160
+ [key: string]: unknown;
161
+ }
162
+ export interface ExtractWithTextly {
163
+ data: string;
164
+ format: {
165
+ [key: string]: JsonSchemaProperty;
166
+ };
167
+ }
168
+ export * from "./data-verifier";
@@ -0,0 +1,11 @@
1
+ export type Email = `${string}@${string}` | string;
2
+ export type Phone = {
3
+ iso: any;
4
+ phone: string;
5
+ } | string;
6
+ export interface CreditCard {
7
+ pan: string | number;
8
+ expirationDate?: string;
9
+ cvc?: string | number;
10
+ cvv?: string | number;
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dymo-api",
3
- "version": "1.1.04",
3
+ "version": "1.1.06",
4
4
  "description": "Flow system for Dymo API.",
5
5
  "main": "dist/cjs/dymo-api.js",
6
6
  "module": "dist/esm/dymo-api.js",
@@ -26,7 +26,8 @@
26
26
  "build": "rimraf dist && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && node ./scripts/rename.js",
27
27
  "start": "ts-node src/dymo-api.ts",
28
28
  "prepublishOnly": "npm run build",
29
- "test": "node --max-old-space-size=4096 test/index.js"
29
+ "test": "jest --max-old-space-size=4096",
30
+ "test:watch": "jest --watch --max-old-space-size=4096"
30
31
  },
31
32
  "repository": {
32
33
  "url": "https://github.com/TPEOficial/dymo-api-node"
@@ -48,7 +49,6 @@
48
49
  "@types/react": "^18.3.5",
49
50
  "axios": "^1.6.8",
50
51
  "path": "^0.12.7",
51
- "rimraf": "^6.0.1",
52
52
  "tw-to-css": "0.0.12"
53
53
  },
54
54
  "contributors": [
@@ -57,8 +57,13 @@
57
57
  ],
58
58
  "devDependencies": {
59
59
  "@types/axios": "^0.9.36",
60
+ "@types/jest": "^30.0.0",
60
61
  "@types/node": "^22.9.3",
62
+ "dotenv": "^17.2.2",
63
+ "jest": "^30.1.3",
64
+ "rimraf": "^6.0.1",
65
+ "ts-jest": "^29.4.4",
61
66
  "ts-node": "^10.9.2",
62
67
  "typescript": "^5.5.4"
63
68
  }
64
- }
69
+ }
@@ -1,8 +0,0 @@
1
- ;
2
- ;
3
- ;
4
- ;
5
- ;
6
- ;
7
- ;
8
- export {};
@@ -1,342 +0,0 @@
1
- import type * as React from "react";
2
- export type PhoneData = {
3
- iso: any;
4
- phone: string;
5
- } | string;
6
- export interface CreditCardData {
7
- pan: string | number;
8
- expirationDate?: string;
9
- cvc?: string | number;
10
- cvv?: string | number;
11
- }
12
- export type VerifyPlugins = "blocklist" | "compromiseDetector" | "nsfw" | "reputation" | "riskScore" | "torNetwork" | "typosquatting" | "urlShortener";
13
- export interface Validator {
14
- url?: string;
15
- email?: string;
16
- phone?: PhoneData;
17
- domain?: string;
18
- creditCard?: string | CreditCardData;
19
- ip?: string;
20
- wallet?: string;
21
- userAgent?: string;
22
- plugins?: VerifyPlugins[];
23
- }
24
- export interface SRNG {
25
- min: number;
26
- max: number;
27
- quantity?: number;
28
- }
29
- export type Attachment = {
30
- filename: string;
31
- path?: string;
32
- content?: string | Buffer;
33
- cid?: string;
34
- };
35
- export interface ServerEmailConfig {
36
- host: string;
37
- port: number;
38
- secure: boolean;
39
- auth: {
40
- user: string;
41
- pass: string;
42
- };
43
- dkim?: {
44
- domainName: string;
45
- keySelector: string;
46
- privateKey: string;
47
- };
48
- }
49
- export type SendEmail = {
50
- from: string;
51
- to: string;
52
- subject: string;
53
- attachments?: Attachment[];
54
- options?: {
55
- priority?: "high" | "normal" | "low";
56
- composeTailwindClasses?: boolean;
57
- compileToCssSafe?: boolean;
58
- onlyVerifiedEmails?: boolean;
59
- };
60
- } & ({
61
- html: string;
62
- react?: never;
63
- } | {
64
- react: React.ReactNode;
65
- html?: never;
66
- });
67
- export interface PrayerTimesData {
68
- lat?: number;
69
- lon?: number;
70
- }
71
- export interface InputSatinizerData {
72
- input?: string;
73
- }
74
- export interface IsValidPwdData {
75
- email?: string;
76
- password?: string;
77
- bannedWords?: string | string[];
78
- min?: number;
79
- max?: number;
80
- }
81
- export interface SRNComponent {
82
- integer: number;
83
- float: number;
84
- }
85
- export interface SRNSummary {
86
- values: SRNComponent[];
87
- executionTime: number;
88
- }
89
- export interface CountryPrayerTimes {
90
- country: string;
91
- prayerTimesByTimezone: {
92
- timezone: string;
93
- prayerTimes: {
94
- coordinates: string;
95
- date: string;
96
- calculationParameters: string;
97
- fajr: string;
98
- sunrise: string;
99
- dhuhr: string;
100
- asr: string;
101
- sunset: string;
102
- maghrib: string;
103
- isha: string;
104
- };
105
- }[];
106
- }
107
- export interface SatinizedInputAnalysis {
108
- input: string;
109
- formats: {
110
- ascii: boolean;
111
- bitcoinAddress: boolean;
112
- cLikeIdentifier: boolean;
113
- coordinates: boolean;
114
- crediCard: boolean;
115
- date: boolean;
116
- discordUsername: boolean;
117
- doi: boolean;
118
- domain: boolean;
119
- e164Phone: boolean;
120
- email: boolean;
121
- emoji: boolean;
122
- hanUnification: boolean;
123
- hashtag: boolean;
124
- hyphenWordBreak: boolean;
125
- ipv6: boolean;
126
- ip: boolean;
127
- jiraTicket: boolean;
128
- macAddress: boolean;
129
- name: boolean;
130
- number: boolean;
131
- panFromGstin: boolean;
132
- password: boolean;
133
- port: boolean;
134
- tel: boolean;
135
- text: boolean;
136
- semver: boolean;
137
- ssn: boolean;
138
- uuid: boolean;
139
- url: boolean;
140
- urlSlug: boolean;
141
- username: boolean;
142
- };
143
- includes: {
144
- spaces: boolean;
145
- hasSql: boolean;
146
- hasNoSql: boolean;
147
- letters: boolean;
148
- uppercase: boolean;
149
- lowercase: boolean;
150
- symbols: boolean;
151
- digits: boolean;
152
- };
153
- }
154
- export interface EmailStatus {
155
- status: boolean;
156
- error?: string;
157
- }
158
- export interface ValidationDetail {
159
- validation: string;
160
- message: string;
161
- word?: string;
162
- }
163
- export interface PasswordValidationResult {
164
- valid: boolean;
165
- password: string;
166
- details: ValidationDetail[];
167
- }
168
- export interface DataValidationAnalysis {
169
- url: {
170
- valid: boolean;
171
- fraud: boolean;
172
- freeSubdomain: boolean;
173
- customTLD: boolean;
174
- url: string;
175
- domain: string;
176
- plugins: {
177
- blocklist?: boolean;
178
- compromiseDetector?: boolean;
179
- nsfw?: boolean;
180
- reputation?: "low" | "medium" | "high" | "very-high" | "education" | "governmental" | "unknown";
181
- riskScore?: number;
182
- torNetwork?: boolean;
183
- typosquatting?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
184
- urlShortener?: boolean;
185
- };
186
- };
187
- email: {
188
- valid: boolean;
189
- fraud: boolean;
190
- proxiedEmail: boolean;
191
- freeSubdomain: boolean;
192
- corporate: boolean;
193
- email: string;
194
- realUser: string;
195
- didYouMean: string | null;
196
- noReply: boolean;
197
- customTLD: boolean;
198
- domain: string;
199
- roleAccount: boolean;
200
- plugins: {
201
- blocklist?: boolean;
202
- compromiseDetector?: boolean;
203
- nsfw?: boolean;
204
- reputation?: "low" | "medium" | "high" | "very-high" | "education" | "governmental" | "unknown";
205
- riskScore?: number;
206
- torNetwork?: boolean;
207
- typosquatting?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
208
- urlShortener?: boolean;
209
- };
210
- };
211
- phone: {
212
- valid: boolean;
213
- fraud: boolean;
214
- phone: string;
215
- prefix: string;
216
- number: string;
217
- lineType: "PREMIUM_RATE" | "TOLL_FREE" | "SHARED_COST" | "VOIP" | "PERSONAL_NUMBER" | "PAGER" | "UAN" | "VOICEMAIL" | "FIXED_LINE_OR_MOBILE" | "FIXED_LINE" | "MOBILE" | "Unknown";
218
- carrierInfo: {
219
- carrierName: string;
220
- accuracy: number;
221
- carrierCountry: string;
222
- carrierCountryCode: string;
223
- };
224
- country: string;
225
- countryCode: string;
226
- plugins: {
227
- blocklist?: boolean;
228
- riskScore?: number;
229
- };
230
- };
231
- domain: {
232
- valid: boolean;
233
- fraud: boolean;
234
- freeSubdomain: boolean;
235
- customTLD: boolean;
236
- domain: string;
237
- plugins: {
238
- blocklist?: boolean;
239
- compromiseDetector?: boolean;
240
- nsfw?: boolean;
241
- reputation?: "low" | "medium" | "high" | "very-high" | "education" | "governmental" | "unknown";
242
- riskScore?: number;
243
- torNetwork?: boolean;
244
- typosquatting?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
245
- urlShortener?: boolean;
246
- };
247
- };
248
- creditCard: {
249
- valid: boolean;
250
- fraud: boolean;
251
- test: boolean;
252
- type: string;
253
- creditCard: string;
254
- plugins: {
255
- blocklist?: boolean;
256
- };
257
- };
258
- ip: {
259
- valid: boolean;
260
- type: "IPv4" | "IPv6" | "Invalid";
261
- class: "A" | "B" | "C" | "D" | "E" | "Unknown" | "None";
262
- fraud: boolean;
263
- ip: string;
264
- continent: string;
265
- continentCode: string;
266
- country: string;
267
- countryCode: string;
268
- region: string;
269
- regionName: string;
270
- city: string;
271
- district: string;
272
- zipCode: string;
273
- lat: number;
274
- lon: number;
275
- timezone: string;
276
- offset: number;
277
- currency: string;
278
- isp: string;
279
- org: string;
280
- as: string;
281
- asname: string;
282
- mobile: boolean;
283
- proxy: boolean;
284
- hosting: boolean;
285
- plugins: {
286
- blocklist?: boolean;
287
- };
288
- };
289
- wallet: {
290
- valid: boolean;
291
- fraud: boolean;
292
- wallet: string;
293
- type: string;
294
- plugins: {
295
- blocklist?: boolean;
296
- riskScore?: number;
297
- torNetwork?: boolean;
298
- };
299
- };
300
- userAgent: {
301
- valid: boolean;
302
- type?: string;
303
- clientSlug?: string | null;
304
- clientName?: string;
305
- version?: string | null;
306
- userAgent?: string;
307
- fraud?: boolean;
308
- bot?: boolean;
309
- info?: string;
310
- os?: string;
311
- device: {
312
- type?: string;
313
- brand?: string;
314
- };
315
- plugins?: {
316
- blocklist?: boolean;
317
- riskScore?: number;
318
- };
319
- };
320
- }
321
- export type SchemaType = "string" | "number" | "boolean" | "array" | "object";
322
- export interface JsonSchemaProperty {
323
- type: SchemaType;
324
- items?: JsonSchemaProperty;
325
- properties?: Record<string, JsonSchemaProperty>;
326
- required?: string[];
327
- description?: string;
328
- format?: string;
329
- enum?: unknown[];
330
- minimum?: number;
331
- maximum?: number;
332
- minLength?: number;
333
- maxLength?: number;
334
- pattern?: string;
335
- [key: string]: unknown;
336
- }
337
- export interface ExtractWithTextly {
338
- data: string;
339
- format: {
340
- [key: string]: JsonSchemaProperty;
341
- };
342
- }