dymo-api 1.2.5 → 1.2.7
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/extractWithTextly/index.cjs +33 -0
- package/dist/cjs/branches/private/functions/getRandom/index.cjs +37 -0
- package/dist/cjs/branches/private/functions/isValidData/index.cjs +33 -0
- package/dist/cjs/branches/private/functions/isValidEmail/index.cjs +82 -0
- package/dist/cjs/branches/private/functions/protectReq/index.cjs +74 -0
- package/dist/cjs/branches/private/functions/protectReq/requestHandler.cjs +22 -0
- package/dist/cjs/branches/private/functions/sendEmail/index.cjs +88 -0
- package/dist/cjs/branches/private/index.cjs +22 -0
- package/dist/cjs/branches/public/functions/getPrayerTimes/index.cjs +31 -0
- package/dist/cjs/branches/public/functions/isValidPwd/index.cjs +65 -0
- package/dist/cjs/branches/public/functions/satinize/index.cjs +26 -0
- package/dist/cjs/branches/public/index.cjs +19 -0
- package/dist/cjs/config/index.cjs +0 -21
- package/dist/cjs/dymo-api.cjs +68 -16
- package/dist/cjs/lib/types/interfaces.cjs +2 -1
- package/dist/cjs/lib/types/well-known-bots.cjs +739 -0
- package/dist/cjs/utils/basics.cjs +18 -0
- package/dist/esm/branches/private/functions/extractWithTextly/index.js +29 -0
- package/dist/esm/branches/private/functions/getRandom/index.js +33 -0
- package/dist/esm/branches/private/functions/isValidData/index.js +29 -0
- package/dist/esm/branches/private/functions/isValidEmail/index.js +78 -0
- package/dist/esm/branches/private/functions/protectReq/index.js +37 -0
- package/dist/esm/branches/private/functions/protectReq/requestHandler.js +18 -0
- package/dist/esm/branches/private/functions/sendEmail/index.js +81 -0
- package/dist/esm/branches/private/index.js +6 -0
- package/dist/esm/branches/public/functions/getPrayerTimes/index.js +27 -0
- package/dist/esm/branches/{public.js → public/functions/isValidPwd/index.js} +28 -30
- package/dist/esm/branches/public/functions/satinize/index.js +22 -0
- package/dist/esm/branches/public/index.js +3 -0
- package/dist/esm/config/index.js +0 -15
- package/dist/esm/dymo-api.js +65 -16
- package/dist/esm/lib/types/interfaces.js +2 -1
- package/dist/esm/lib/types/well-known-bots.js +736 -0
- package/dist/esm/utils/basics.js +10 -0
- package/dist/types/branches/private/functions/extractWithTextly/index.d.ts +16 -0
- package/dist/types/branches/private/functions/getRandom/index.d.ts +16 -0
- package/dist/types/branches/private/functions/isValidData/index.d.ts +15 -0
- package/dist/types/branches/private/functions/isValidEmail/index.d.ts +20 -0
- package/dist/types/branches/private/functions/protectReq/index.d.ts +3 -0
- package/dist/types/branches/private/functions/protectReq/requestHandler.d.ts +22 -0
- package/dist/types/branches/private/functions/sendEmail/index.d.ts +18 -0
- package/dist/types/branches/private/index.d.ts +6 -0
- package/dist/types/branches/public/functions/getPrayerTimes/index.d.ts +17 -0
- package/dist/types/branches/public/functions/isValidPwd/index.d.ts +28 -0
- package/dist/types/branches/public/functions/satinize/index.d.ts +12 -0
- package/dist/types/branches/public/index.d.ts +3 -0
- package/dist/types/config/index.d.ts +0 -4
- package/dist/types/dymo-api.d.ts +38 -3
- package/dist/types/lib/types/interfaces.d.ts +2 -3
- package/dist/types/lib/types/primitives.d.ts +7 -0
- package/dist/types/lib/types/rules.d.ts +12 -0
- package/dist/types/lib/types/well-known-bots.d.ts +4 -0
- package/dist/types/utils/basics.d.ts +2 -0
- package/package.json +13 -5
- package/dist/cjs/branches/private.cjs +0 -284
- package/dist/cjs/branches/public.cjs +0 -102
- package/dist/esm/branches/private.js +0 -240
- package/dist/types/branches/private.d.ts +0 -76
- package/dist/types/branches/public.d.ts +0 -4
package/dist/cjs/dymo-api.cjs
CHANGED
|
@@ -32,10 +32,15 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
35
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
const config_1 =
|
|
37
|
-
const PublicAPI = __importStar(require("./branches/public.cjs"));
|
|
38
|
-
const PrivateAPI = __importStar(require("./branches/private.cjs"));
|
|
39
|
+
const config_1 = __importDefault(require("./config/index.cjs"));
|
|
40
|
+
const PublicAPI = __importStar(require("./branches/public/index.cjs"));
|
|
41
|
+
const PrivateAPI = __importStar(require("./branches/private/index.cjs"));
|
|
42
|
+
const axios_1 = __importDefault(require("axios"));
|
|
43
|
+
const basics_1 = require("./utils/basics.cjs");
|
|
39
44
|
const customError = (code, message) => {
|
|
40
45
|
return Object.assign(new Error(), { code, message: `[${config_1.default.lib.name}] ${message}` });
|
|
41
46
|
};
|
|
@@ -54,20 +59,30 @@ class DymoAPI {
|
|
|
54
59
|
* @example
|
|
55
60
|
* const dymoApi = new DymoAPI({
|
|
56
61
|
* rootApiKey: "6bfb7675-6b69-4f8d-9f43-5a6f7f02c6c5",
|
|
57
|
-
* apiKey: "
|
|
62
|
+
* apiKey: "dm_4c8b7675-6b69-4f8d-9f43-5a6f7f02c6c5"
|
|
58
63
|
* });
|
|
59
64
|
*/
|
|
60
65
|
constructor({ rootApiKey = null, apiKey = null, baseUrl = "https://api.tpeoficial.com", serverEmailConfig = undefined, rules = {} } = {}) {
|
|
61
66
|
this.rules = {
|
|
62
|
-
email: { deny: ["FRAUD", "INVALID", "NO_MX_RECORDS", "NO_REPLY_EMAIL"] },
|
|
63
|
-
sensitiveInfo: { deny: ["EMAIL", "PHONE", "CREDIT_CARD"] },
|
|
67
|
+
email: { mode: "LIVE", deny: ["FRAUD", "INVALID", "NO_MX_RECORDS", "NO_REPLY_EMAIL"] },
|
|
68
|
+
sensitiveInfo: { mode: "LIVE", deny: ["EMAIL", "PHONE", "CREDIT_CARD"] },
|
|
69
|
+
waf: { mode: "LIVE", allowBots: ["CURL", "CATEGORY:SEARCH_ENGINE", "CATEGORY:PREVIEW"], deny: ["FRAUD", "TOR_NETWORK"] },
|
|
64
70
|
...rules
|
|
65
71
|
};
|
|
66
72
|
this.rootApiKey = rootApiKey;
|
|
67
73
|
this.apiKey = apiKey;
|
|
68
74
|
this.serverEmailConfig = serverEmailConfig;
|
|
69
75
|
this.baseUrl = baseUrl;
|
|
70
|
-
|
|
76
|
+
// We created the Axios client with the appropriate settings.
|
|
77
|
+
this.axiosClient = axios_1.default.create({
|
|
78
|
+
baseURL: `${(0, basics_1.validBaseURL)(this.baseUrl)}/v1`,
|
|
79
|
+
headers: {
|
|
80
|
+
"User-Agent": "DymoAPISDK/1.0.0"
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
// We set the authorization in the Axios client to make requests.
|
|
84
|
+
if (this.rootApiKey || this.apiKey)
|
|
85
|
+
this.axiosClient.defaults.headers.Authorization = `Bearer ${this.rootApiKey || this.apiKey}`;
|
|
71
86
|
}
|
|
72
87
|
;
|
|
73
88
|
// FUNCTIONS / Private.
|
|
@@ -93,7 +108,7 @@ class DymoAPI {
|
|
|
93
108
|
* [Documentation](https://docs.tpeoficial.com/docs/dymo-api/private/data-verifier)
|
|
94
109
|
*/
|
|
95
110
|
async isValidData(data) {
|
|
96
|
-
return await PrivateAPI.isValidData(this.
|
|
111
|
+
return await PrivateAPI.isValidData(this.axiosClient, data);
|
|
97
112
|
}
|
|
98
113
|
;
|
|
99
114
|
/**
|
|
@@ -112,12 +127,33 @@ class DymoAPI {
|
|
|
112
127
|
* @example
|
|
113
128
|
* const valid = await dymoClient.isValidEmail("user@example.com", { deny: ["FRAUD", "NO_MX_RECORDS"] });
|
|
114
129
|
*
|
|
115
|
-
* @see [Documentation](https://docs.tpeoficial.com/docs/dymo-api/private/
|
|
130
|
+
* @see [Documentation](https://docs.tpeoficial.com/docs/dymo-api/private/request-verifier)
|
|
116
131
|
*/
|
|
117
132
|
async isValidEmail(email, rules = this.rules.email) {
|
|
118
|
-
return await PrivateAPI.isValidEmail(this.
|
|
133
|
+
return await PrivateAPI.isValidEmail(this.axiosClient, email, rules);
|
|
119
134
|
}
|
|
120
135
|
;
|
|
136
|
+
/**
|
|
137
|
+
* Protects the given request against the configured rules.
|
|
138
|
+
*
|
|
139
|
+
* This method requires either the root API key or the API key to be set.
|
|
140
|
+
* If neither is set, it will throw an error.
|
|
141
|
+
*
|
|
142
|
+
* @param {Object} req - The request object to be protected.
|
|
143
|
+
* @param {Interfaces.WafRules} [rules] - Optional rules for protection. Some rules are premium features.
|
|
144
|
+
* @returns {Promise<Interfaces.HTTPRequest>} Resolves with the protected request.
|
|
145
|
+
* @important
|
|
146
|
+
* **⚠️ This is a [PREMIUM](https://docs.tpeoficial.com/docs/dymo-api/private/data-verifier) and BETA feature.**
|
|
147
|
+
* @throws Will throw an error if protection cannot be performed.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* const protectedReq = await dymoClient.protectReq(req);
|
|
151
|
+
*
|
|
152
|
+
* @see [Documentation](https://docs.tpeoficial.com/docs/dymo-api/private/data-verifier)
|
|
153
|
+
*/
|
|
154
|
+
async protectReq(req, rules = this.rules.waf) {
|
|
155
|
+
return await PrivateAPI.protectReq(this.axiosClient, req, rules);
|
|
156
|
+
}
|
|
121
157
|
/**
|
|
122
158
|
* Sends an email using the configured email client settings.
|
|
123
159
|
*
|
|
@@ -147,7 +183,7 @@ class DymoAPI {
|
|
|
147
183
|
async sendEmail(data) {
|
|
148
184
|
if (!this.serverEmailConfig && !this.rootApiKey)
|
|
149
185
|
console.error(`[${config_1.default.lib.name}] You must configure the email client settings.`);
|
|
150
|
-
return await PrivateAPI.sendEmail(this.
|
|
186
|
+
return await PrivateAPI.sendEmail(this.axiosClient, { serverEmailConfig: this.serverEmailConfig, ...data });
|
|
151
187
|
}
|
|
152
188
|
;
|
|
153
189
|
/**
|
|
@@ -166,7 +202,7 @@ class DymoAPI {
|
|
|
166
202
|
* [Documentation](https://docs.tpeoficial.com/docs/dymo-api/private/secure-random-number-generator)
|
|
167
203
|
*/
|
|
168
204
|
async getRandom(data) {
|
|
169
|
-
return await PrivateAPI.getRandom(this.
|
|
205
|
+
return await PrivateAPI.getRandom(this.axiosClient, data);
|
|
170
206
|
}
|
|
171
207
|
;
|
|
172
208
|
/**
|
|
@@ -182,7 +218,7 @@ class DymoAPI {
|
|
|
182
218
|
* [Documentation](https://docs.tpeoficial.com/docs/dymo-api/private/textly/text-extraction)
|
|
183
219
|
*/
|
|
184
220
|
async extractWithTextly(data) {
|
|
185
|
-
return await PrivateAPI.extractWithTextly(this.
|
|
221
|
+
return await PrivateAPI.extractWithTextly(this.axiosClient, data);
|
|
186
222
|
}
|
|
187
223
|
;
|
|
188
224
|
// FUNCTIONS / Public.
|
|
@@ -201,13 +237,14 @@ class DymoAPI {
|
|
|
201
237
|
* [Documentation](https://docs.tpeoficial.com/docs/dymo-api/public/prayertimes)
|
|
202
238
|
*/
|
|
203
239
|
async getPrayerTimes(data) {
|
|
204
|
-
return await PublicAPI.getPrayerTimes(data);
|
|
240
|
+
return await PublicAPI.getPrayerTimes(this.axiosClient, data);
|
|
205
241
|
}
|
|
206
242
|
;
|
|
207
243
|
/**
|
|
208
244
|
* Satinizes the input, replacing any special characters with their HTML
|
|
209
245
|
* entities.
|
|
210
246
|
*
|
|
247
|
+
* @deprecated Use `satinize` instead. This feature will be removed soon.
|
|
211
248
|
* @param {Object} data - The data to be sent.
|
|
212
249
|
* @param {string} data.input - The input to be satinized.
|
|
213
250
|
* @returns {Promise<Interfaces.SatinizedInputAnalysis>} A promise that resolves to the response from the server.
|
|
@@ -216,7 +253,22 @@ class DymoAPI {
|
|
|
216
253
|
* [Documentation](https://docs.tpeoficial.com/docs/dymo-api/public/input-satinizer)
|
|
217
254
|
*/
|
|
218
255
|
async satinizer(data) {
|
|
219
|
-
return await PublicAPI.
|
|
256
|
+
return await PublicAPI.satinize(this.axiosClient, data.input);
|
|
257
|
+
}
|
|
258
|
+
;
|
|
259
|
+
/**
|
|
260
|
+
* Satinizes the input, replacing any special characters with their HTML
|
|
261
|
+
* entities.
|
|
262
|
+
*
|
|
263
|
+
* @param {Object} data - The data to be sent.
|
|
264
|
+
* @param {string} data.input - The input to be satinized.
|
|
265
|
+
* @returns {Promise<Interfaces.SatinizedInputAnalysis>} A promise that resolves to the response from the server.
|
|
266
|
+
* @throws Will throw an error if there is an issue with the satinization process.
|
|
267
|
+
*
|
|
268
|
+
* [Documentation](https://docs.tpeoficial.com/docs/dymo-api/public/input-satinizer)
|
|
269
|
+
*/
|
|
270
|
+
async satinize(input) {
|
|
271
|
+
return await PublicAPI.satinize(this.axiosClient, input);
|
|
220
272
|
}
|
|
221
273
|
;
|
|
222
274
|
/**
|
|
@@ -245,7 +297,7 @@ class DymoAPI {
|
|
|
245
297
|
* [Documentation](https://docs.tpeoficial.com/docs/dymo-api/public/password-validator)
|
|
246
298
|
*/
|
|
247
299
|
async isValidPwd(data) {
|
|
248
|
-
return await PublicAPI.isValidPwd(data);
|
|
300
|
+
return await PublicAPI.isValidPwd(this.axiosClient, data);
|
|
249
301
|
}
|
|
250
302
|
;
|
|
251
303
|
}
|
|
@@ -18,6 +18,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
;
|
|
19
19
|
;
|
|
20
20
|
;
|
|
21
|
-
;
|
|
22
21
|
__exportStar(require("./rules.cjs"), exports);
|
|
22
|
+
__exportStar(require("./primitives.cjs"), exports);
|
|
23
23
|
__exportStar(require("./data-verifier.cjs"), exports);
|
|
24
|
+
__exportStar(require("./well-known-bots.cjs"), exports);
|