dymo-api 1.0.80 → 1.0.81
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/public.cjs +1 -18
- package/dist/cjs/dymo-api.cjs +38 -38
- package/dist/cjs/lib/interfaces.cjs +4 -0
- package/dist/esm/branches/public.js +0 -16
- package/dist/esm/dymo-api.js +38 -38
- package/dist/esm/lib/interfaces.js +4 -0
- package/dist/types/branches/public.d.ts +4 -22
- package/dist/types/dymo-api.d.ts +32 -30
- package/dist/types/lib/interfaces.d.ts +184 -3
- package/package.json +1 -1
|
@@ -36,16 +36,12 @@ 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.
|
|
39
|
+
exports.isValidPwd = exports.satinizer = exports.getPrayerTimes = void 0;
|
|
40
40
|
const axios_1 = __importDefault(require("axios"));
|
|
41
41
|
const config_1 = __importStar(require("../config/index.cjs"));
|
|
42
42
|
const customError = (code, message) => {
|
|
43
43
|
return Object.assign(new Error(), { code, message: `[${config_1.default.lib.name}] ${message}` });
|
|
44
44
|
};
|
|
45
|
-
;
|
|
46
|
-
;
|
|
47
|
-
;
|
|
48
|
-
;
|
|
49
45
|
const getPrayerTimes = async (data) => {
|
|
50
46
|
const { lat, lon } = data;
|
|
51
47
|
if (lat === undefined || lon === undefined)
|
|
@@ -108,16 +104,3 @@ const isValidPwd = async (data) => {
|
|
|
108
104
|
}
|
|
109
105
|
};
|
|
110
106
|
exports.isValidPwd = isValidPwd;
|
|
111
|
-
const newURLEncrypt = async (data) => {
|
|
112
|
-
const { url } = data;
|
|
113
|
-
if (url === undefined || (!url.startsWith("https://") && !url.startsWith("http://")))
|
|
114
|
-
throw customError(1500, "You must provide a valid url.");
|
|
115
|
-
try {
|
|
116
|
-
const response = await axios_1.default.get(`${config_1.BASE_URL}/v1/public/url-encrypt`, { params: data });
|
|
117
|
-
return response.data;
|
|
118
|
-
}
|
|
119
|
-
catch (error) {
|
|
120
|
-
throw customError(5000, error.response?.data?.message || error.message);
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
exports.newURLEncrypt = newURLEncrypt;
|
package/dist/cjs/dymo-api.cjs
CHANGED
|
@@ -73,8 +73,7 @@ class DymoAPI {
|
|
|
73
73
|
this.local = rootApiKey ? local : false; // Only allow setting local if rootApiKey is defined.
|
|
74
74
|
(0, config_1.setBaseUrl)(this.local);
|
|
75
75
|
this.autoupdate();
|
|
76
|
-
|
|
77
|
-
this.initializeTokens();
|
|
76
|
+
this.initializeTokens(); // Calls the function to obtain tokens when creating the object.
|
|
78
77
|
}
|
|
79
78
|
/**
|
|
80
79
|
* Retrieves and caches authentication tokens.
|
|
@@ -86,17 +85,21 @@ class DymoAPI {
|
|
|
86
85
|
* The method also handles validation of root and API tokens, throwing errors if
|
|
87
86
|
* any of the tokens are invalid. Cached tokens are considered valid for 5 minutes.
|
|
88
87
|
*
|
|
89
|
-
* @returns {Promise<
|
|
88
|
+
* @returns {Promise<TokensResponse|undefined>} A promise that resolves to the tokens response
|
|
90
89
|
* if successful, or undefined if no tokens are available.
|
|
91
90
|
* @throws Will throw an error if token validation fails, or if there is an issue
|
|
92
91
|
* with the token retrieval process.
|
|
93
92
|
*/
|
|
94
|
-
|
|
93
|
+
async getTokens() {
|
|
94
|
+
if (DymoAPI.tokensResponse && DymoAPI.tokensVerified) {
|
|
95
|
+
console.log(`[${config_1.default.lib.name}] Using cached tokens response.`);
|
|
96
|
+
return DymoAPI.tokensResponse;
|
|
97
|
+
}
|
|
95
98
|
const tokens = {};
|
|
96
|
-
if (rootApiKey)
|
|
97
|
-
tokens.root = `Bearer ${rootApiKey}`;
|
|
98
|
-
if (apiKey)
|
|
99
|
-
tokens.api = `Bearer ${apiKey}`;
|
|
99
|
+
if (this.rootApiKey)
|
|
100
|
+
tokens.root = `Bearer ${this.rootApiKey}`;
|
|
101
|
+
if (this.apiKey)
|
|
102
|
+
tokens.api = `Bearer ${this.apiKey}`;
|
|
100
103
|
try {
|
|
101
104
|
if (Object.keys(tokens).length === 0)
|
|
102
105
|
return;
|
|
@@ -111,7 +114,8 @@ class DymoAPI {
|
|
|
111
114
|
return DymoAPI.tokensResponse;
|
|
112
115
|
}
|
|
113
116
|
catch (error) {
|
|
114
|
-
|
|
117
|
+
console.error(error.message);
|
|
118
|
+
throw new Error(error.message);
|
|
115
119
|
}
|
|
116
120
|
}
|
|
117
121
|
/**
|
|
@@ -125,13 +129,10 @@ class DymoAPI {
|
|
|
125
129
|
*/
|
|
126
130
|
async initializeTokens() {
|
|
127
131
|
try {
|
|
128
|
-
|
|
129
|
-
await DymoAPI.getTokens(this.rootApiKey, this.apiKey);
|
|
130
|
-
else
|
|
131
|
-
console.log(`[${config_1.default.lib.name}] Tokens already verified.`);
|
|
132
|
+
await this.getTokens();
|
|
132
133
|
}
|
|
133
134
|
catch (error) {
|
|
134
|
-
|
|
135
|
+
console.error(`Error initializing tokens: ${error.message}`);
|
|
135
136
|
}
|
|
136
137
|
}
|
|
137
138
|
/**
|
|
@@ -148,7 +149,7 @@ class DymoAPI {
|
|
|
148
149
|
await (0, autoupdate_1.checkForUpdates)();
|
|
149
150
|
}
|
|
150
151
|
catch (error) {
|
|
151
|
-
|
|
152
|
+
console.error(`Error checking the latest version in npmjs: ${error.message}`);
|
|
152
153
|
}
|
|
153
154
|
}
|
|
154
155
|
// FUNCTIONS / Private.
|
|
@@ -159,7 +160,14 @@ class DymoAPI {
|
|
|
159
160
|
* If neither is set, it will throw an error.
|
|
160
161
|
*
|
|
161
162
|
* @param {Object} data - The data to be validated.
|
|
162
|
-
* @
|
|
163
|
+
* @param {string} [data.email] - Optional email address to be validated.
|
|
164
|
+
* @param {Interfaces.PhoneData} [data.phone] - Optional phone number data to be validated.
|
|
165
|
+
* @param {string} [data.domain] - Optional domain name to be validated.
|
|
166
|
+
* @param {string|Interfaces.CreditCardData} [data.creditCard] - Optional credit card number or data to be validated.
|
|
167
|
+
* @param {string} [data.ip] - Optional IP address to be validated.
|
|
168
|
+
* @param {string} [data.wallet] - Optional wallet address to be validated.
|
|
169
|
+
* @param {Interfaces.VerifyPlugins[]} [data.plugins] - Optional array of verification plugins to be used.
|
|
170
|
+
* @returns {Promise<Interfaces.DataValidationAnalysis>} A promise that resolves to the response from the server.
|
|
163
171
|
* @throws Will throw an error if there is an issue with the validation process.
|
|
164
172
|
*/
|
|
165
173
|
async isValidData(data) {
|
|
@@ -186,12 +194,12 @@ class DymoAPI {
|
|
|
186
194
|
* @param {string} [data.attachments[].path] - The path or URL of the attached file. Either this or `content` must be provided.
|
|
187
195
|
* @param {Buffer} [data.attachments[].content] - The content of the attached file as a Buffer. Either this or `path` must be provided.
|
|
188
196
|
* @param {string} [data.attachments[].cid] - The CID (Content-ID) of the attached file, used for inline images.
|
|
189
|
-
* @returns {Promise<
|
|
197
|
+
* @returns {Promise<Interfaces.EmailStatus>} A promise that resolves to the response from the server.
|
|
190
198
|
* @throws Will throw an error if there is an issue with the email sending process.
|
|
191
199
|
*/
|
|
192
200
|
async sendEmail(data) {
|
|
193
201
|
if (!this.serverEmailConfig && !this.rootApiKey)
|
|
194
|
-
|
|
202
|
+
console.error("You must configure the email client settings.");
|
|
195
203
|
return await PrivateAPI.sendEmail(this.rootApiKey || this.apiKey, { serverEmailConfig: this.serverEmailConfig, ...data });
|
|
196
204
|
}
|
|
197
205
|
/**
|
|
@@ -200,10 +208,11 @@ class DymoAPI {
|
|
|
200
208
|
* This method requires either the root API key or the API key to be set.
|
|
201
209
|
* If neither is set, it will throw an error.
|
|
202
210
|
*
|
|
203
|
-
* @param {
|
|
211
|
+
* @param {Interfaces.SRNG} data - The data to be sent.
|
|
204
212
|
* @param {number} data.min - The minimum value of the range.
|
|
205
213
|
* @param {number} data.max - The maximum value of the range.
|
|
206
|
-
* @
|
|
214
|
+
* @param {number} [data.quantity] - The number of random values to generate. Defaults to 1 if not provided.
|
|
215
|
+
* @returns {Promise<Interfaces.SRNSummary>} A promise that resolves to the response from the server.
|
|
207
216
|
* @throws Will throw an error if there is an issue with the random number generation process.
|
|
208
217
|
*/
|
|
209
218
|
async getRandom(data) {
|
|
@@ -219,7 +228,7 @@ class DymoAPI {
|
|
|
219
228
|
* @param {Object} data - The data to be sent.
|
|
220
229
|
* @param {number} data.lat - The latitude of the location.
|
|
221
230
|
* @param {number} data.lon - The longitude of the location.
|
|
222
|
-
* @returns {Promise<
|
|
231
|
+
* @returns {Promise<Interfaces.CountryPrayerTimes | { error: string }>} A promise that resolves to the response from the server.
|
|
223
232
|
* @throws Will throw an error if there is an issue with the prayer times retrieval process.
|
|
224
233
|
*/
|
|
225
234
|
async getPrayerTimes(data) {
|
|
@@ -231,7 +240,7 @@ class DymoAPI {
|
|
|
231
240
|
*
|
|
232
241
|
* @param {Object} data - The data to be sent.
|
|
233
242
|
* @param {string} data.input - The input to be satinized.
|
|
234
|
-
* @returns {Promise<
|
|
243
|
+
* @returns {Promise<Interfaces.SatinizedInputAnalysis>} A promise that resolves to the response from the server.
|
|
235
244
|
* @throws Will throw an error if there is an issue with the satinization process.
|
|
236
245
|
*/
|
|
237
246
|
async satinizer(data) {
|
|
@@ -252,27 +261,18 @@ class DymoAPI {
|
|
|
252
261
|
* - The password must not contain any of the given banned words.
|
|
253
262
|
*
|
|
254
263
|
* @param {Object} data - The data to be sent.
|
|
264
|
+
* @param {number} [data.min] - Minimum length of the password. Defaults to 8 if not provided.
|
|
265
|
+
* @param {number} [data.max] - Maximum length of the password. Defaults to 32 if not provided.
|
|
266
|
+
* @param {string} [data.email] - Optional email associated with the password.
|
|
255
267
|
* @param {string} data.password - The password to be validated.
|
|
256
|
-
* @param {string[]} [data.bannedWords] - The list of banned words that the password must not contain.
|
|
257
|
-
* @returns {Promise<
|
|
268
|
+
* @param {string | string[]} [data.bannedWords] - The list of banned words that the password must not contain.
|
|
269
|
+
* @returns {Promise<Interfaces.PasswordValidationResult>} A promise that resolves to the response from the server.
|
|
258
270
|
* @throws Will throw an error if there is an issue with the password validation process.
|
|
259
271
|
*/
|
|
260
272
|
async isValidPwd(data) {
|
|
261
273
|
return await PublicAPI.isValidPwd(data);
|
|
262
274
|
}
|
|
263
|
-
/**
|
|
264
|
-
* Encrypts a URL using the configured encryption settings.
|
|
265
|
-
*
|
|
266
|
-
* This method requires the URL to be provided in the data object.
|
|
267
|
-
* If the URL is not provided, it will throw an error.
|
|
268
|
-
*
|
|
269
|
-
* @param {Object} data - The data to be sent.
|
|
270
|
-
* @param {string} data.url - The URL to be encrypted.
|
|
271
|
-
* @returns {Promise<Object>} A promise that resolves to the response from the server.
|
|
272
|
-
* @throws Will throw an error if there is an issue with the URL encryption process.
|
|
273
|
-
*/
|
|
274
|
-
async newURLEncrypt(data) {
|
|
275
|
-
return await PublicAPI.newURLEncrypt(data);
|
|
276
|
-
}
|
|
277
275
|
}
|
|
276
|
+
DymoAPI.tokensResponse = null;
|
|
277
|
+
DymoAPI.tokensVerified = false;
|
|
278
278
|
exports.default = DymoAPI;
|
|
@@ -3,10 +3,6 @@ import config, { BASE_URL } from "../config/index.js";
|
|
|
3
3
|
const customError = (code, message) => {
|
|
4
4
|
return Object.assign(new Error(), { code, message: `[${config.lib.name}] ${message}` });
|
|
5
5
|
};
|
|
6
|
-
;
|
|
7
|
-
;
|
|
8
|
-
;
|
|
9
|
-
;
|
|
10
6
|
export const getPrayerTimes = async (data) => {
|
|
11
7
|
const { lat, lon } = data;
|
|
12
8
|
if (lat === undefined || lon === undefined)
|
|
@@ -66,15 +62,3 @@ export const isValidPwd = async (data) => {
|
|
|
66
62
|
throw customError(5000, error.response?.data?.message || error.message);
|
|
67
63
|
}
|
|
68
64
|
};
|
|
69
|
-
export const newURLEncrypt = async (data) => {
|
|
70
|
-
const { url } = data;
|
|
71
|
-
if (url === undefined || (!url.startsWith("https://") && !url.startsWith("http://")))
|
|
72
|
-
throw customError(1500, "You must provide a valid url.");
|
|
73
|
-
try {
|
|
74
|
-
const response = await axios.get(`${BASE_URL}/v1/public/url-encrypt`, { params: data });
|
|
75
|
-
return response.data;
|
|
76
|
-
}
|
|
77
|
-
catch (error) {
|
|
78
|
-
throw customError(5000, error.response?.data?.message || error.message);
|
|
79
|
-
}
|
|
80
|
-
};
|
package/dist/esm/dymo-api.js
CHANGED
|
@@ -35,8 +35,7 @@ class DymoAPI {
|
|
|
35
35
|
this.local = rootApiKey ? local : false; // Only allow setting local if rootApiKey is defined.
|
|
36
36
|
setBaseUrl(this.local);
|
|
37
37
|
this.autoupdate();
|
|
38
|
-
|
|
39
|
-
this.initializeTokens();
|
|
38
|
+
this.initializeTokens(); // Calls the function to obtain tokens when creating the object.
|
|
40
39
|
}
|
|
41
40
|
/**
|
|
42
41
|
* Retrieves and caches authentication tokens.
|
|
@@ -48,17 +47,21 @@ class DymoAPI {
|
|
|
48
47
|
* The method also handles validation of root and API tokens, throwing errors if
|
|
49
48
|
* any of the tokens are invalid. Cached tokens are considered valid for 5 minutes.
|
|
50
49
|
*
|
|
51
|
-
* @returns {Promise<
|
|
50
|
+
* @returns {Promise<TokensResponse|undefined>} A promise that resolves to the tokens response
|
|
52
51
|
* if successful, or undefined if no tokens are available.
|
|
53
52
|
* @throws Will throw an error if token validation fails, or if there is an issue
|
|
54
53
|
* with the token retrieval process.
|
|
55
54
|
*/
|
|
56
|
-
|
|
55
|
+
async getTokens() {
|
|
56
|
+
if (DymoAPI.tokensResponse && DymoAPI.tokensVerified) {
|
|
57
|
+
console.log(`[${config.lib.name}] Using cached tokens response.`);
|
|
58
|
+
return DymoAPI.tokensResponse;
|
|
59
|
+
}
|
|
57
60
|
const tokens = {};
|
|
58
|
-
if (rootApiKey)
|
|
59
|
-
tokens.root = `Bearer ${rootApiKey}`;
|
|
60
|
-
if (apiKey)
|
|
61
|
-
tokens.api = `Bearer ${apiKey}`;
|
|
61
|
+
if (this.rootApiKey)
|
|
62
|
+
tokens.root = `Bearer ${this.rootApiKey}`;
|
|
63
|
+
if (this.apiKey)
|
|
64
|
+
tokens.api = `Bearer ${this.apiKey}`;
|
|
62
65
|
try {
|
|
63
66
|
if (Object.keys(tokens).length === 0)
|
|
64
67
|
return;
|
|
@@ -73,7 +76,8 @@ class DymoAPI {
|
|
|
73
76
|
return DymoAPI.tokensResponse;
|
|
74
77
|
}
|
|
75
78
|
catch (error) {
|
|
76
|
-
|
|
79
|
+
console.error(error.message);
|
|
80
|
+
throw new Error(error.message);
|
|
77
81
|
}
|
|
78
82
|
}
|
|
79
83
|
/**
|
|
@@ -87,13 +91,10 @@ class DymoAPI {
|
|
|
87
91
|
*/
|
|
88
92
|
async initializeTokens() {
|
|
89
93
|
try {
|
|
90
|
-
|
|
91
|
-
await DymoAPI.getTokens(this.rootApiKey, this.apiKey);
|
|
92
|
-
else
|
|
93
|
-
console.log(`[${config.lib.name}] Tokens already verified.`);
|
|
94
|
+
await this.getTokens();
|
|
94
95
|
}
|
|
95
96
|
catch (error) {
|
|
96
|
-
|
|
97
|
+
console.error(`Error initializing tokens: ${error.message}`);
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
100
|
/**
|
|
@@ -110,7 +111,7 @@ class DymoAPI {
|
|
|
110
111
|
await checkForUpdates();
|
|
111
112
|
}
|
|
112
113
|
catch (error) {
|
|
113
|
-
|
|
114
|
+
console.error(`Error checking the latest version in npmjs: ${error.message}`);
|
|
114
115
|
}
|
|
115
116
|
}
|
|
116
117
|
// FUNCTIONS / Private.
|
|
@@ -121,7 +122,14 @@ class DymoAPI {
|
|
|
121
122
|
* If neither is set, it will throw an error.
|
|
122
123
|
*
|
|
123
124
|
* @param {Object} data - The data to be validated.
|
|
124
|
-
* @
|
|
125
|
+
* @param {string} [data.email] - Optional email address to be validated.
|
|
126
|
+
* @param {Interfaces.PhoneData} [data.phone] - Optional phone number data to be validated.
|
|
127
|
+
* @param {string} [data.domain] - Optional domain name to be validated.
|
|
128
|
+
* @param {string|Interfaces.CreditCardData} [data.creditCard] - Optional credit card number or data to be validated.
|
|
129
|
+
* @param {string} [data.ip] - Optional IP address to be validated.
|
|
130
|
+
* @param {string} [data.wallet] - Optional wallet address to be validated.
|
|
131
|
+
* @param {Interfaces.VerifyPlugins[]} [data.plugins] - Optional array of verification plugins to be used.
|
|
132
|
+
* @returns {Promise<Interfaces.DataValidationAnalysis>} A promise that resolves to the response from the server.
|
|
125
133
|
* @throws Will throw an error if there is an issue with the validation process.
|
|
126
134
|
*/
|
|
127
135
|
async isValidData(data) {
|
|
@@ -148,12 +156,12 @@ class DymoAPI {
|
|
|
148
156
|
* @param {string} [data.attachments[].path] - The path or URL of the attached file. Either this or `content` must be provided.
|
|
149
157
|
* @param {Buffer} [data.attachments[].content] - The content of the attached file as a Buffer. Either this or `path` must be provided.
|
|
150
158
|
* @param {string} [data.attachments[].cid] - The CID (Content-ID) of the attached file, used for inline images.
|
|
151
|
-
* @returns {Promise<
|
|
159
|
+
* @returns {Promise<Interfaces.EmailStatus>} A promise that resolves to the response from the server.
|
|
152
160
|
* @throws Will throw an error if there is an issue with the email sending process.
|
|
153
161
|
*/
|
|
154
162
|
async sendEmail(data) {
|
|
155
163
|
if (!this.serverEmailConfig && !this.rootApiKey)
|
|
156
|
-
|
|
164
|
+
console.error("You must configure the email client settings.");
|
|
157
165
|
return await PrivateAPI.sendEmail(this.rootApiKey || this.apiKey, { serverEmailConfig: this.serverEmailConfig, ...data });
|
|
158
166
|
}
|
|
159
167
|
/**
|
|
@@ -162,10 +170,11 @@ class DymoAPI {
|
|
|
162
170
|
* This method requires either the root API key or the API key to be set.
|
|
163
171
|
* If neither is set, it will throw an error.
|
|
164
172
|
*
|
|
165
|
-
* @param {
|
|
173
|
+
* @param {Interfaces.SRNG} data - The data to be sent.
|
|
166
174
|
* @param {number} data.min - The minimum value of the range.
|
|
167
175
|
* @param {number} data.max - The maximum value of the range.
|
|
168
|
-
* @
|
|
176
|
+
* @param {number} [data.quantity] - The number of random values to generate. Defaults to 1 if not provided.
|
|
177
|
+
* @returns {Promise<Interfaces.SRNSummary>} A promise that resolves to the response from the server.
|
|
169
178
|
* @throws Will throw an error if there is an issue with the random number generation process.
|
|
170
179
|
*/
|
|
171
180
|
async getRandom(data) {
|
|
@@ -181,7 +190,7 @@ class DymoAPI {
|
|
|
181
190
|
* @param {Object} data - The data to be sent.
|
|
182
191
|
* @param {number} data.lat - The latitude of the location.
|
|
183
192
|
* @param {number} data.lon - The longitude of the location.
|
|
184
|
-
* @returns {Promise<
|
|
193
|
+
* @returns {Promise<Interfaces.CountryPrayerTimes | { error: string }>} A promise that resolves to the response from the server.
|
|
185
194
|
* @throws Will throw an error if there is an issue with the prayer times retrieval process.
|
|
186
195
|
*/
|
|
187
196
|
async getPrayerTimes(data) {
|
|
@@ -193,7 +202,7 @@ class DymoAPI {
|
|
|
193
202
|
*
|
|
194
203
|
* @param {Object} data - The data to be sent.
|
|
195
204
|
* @param {string} data.input - The input to be satinized.
|
|
196
|
-
* @returns {Promise<
|
|
205
|
+
* @returns {Promise<Interfaces.SatinizedInputAnalysis>} A promise that resolves to the response from the server.
|
|
197
206
|
* @throws Will throw an error if there is an issue with the satinization process.
|
|
198
207
|
*/
|
|
199
208
|
async satinizer(data) {
|
|
@@ -214,27 +223,18 @@ class DymoAPI {
|
|
|
214
223
|
* - The password must not contain any of the given banned words.
|
|
215
224
|
*
|
|
216
225
|
* @param {Object} data - The data to be sent.
|
|
226
|
+
* @param {number} [data.min] - Minimum length of the password. Defaults to 8 if not provided.
|
|
227
|
+
* @param {number} [data.max] - Maximum length of the password. Defaults to 32 if not provided.
|
|
228
|
+
* @param {string} [data.email] - Optional email associated with the password.
|
|
217
229
|
* @param {string} data.password - The password to be validated.
|
|
218
|
-
* @param {string[]} [data.bannedWords] - The list of banned words that the password must not contain.
|
|
219
|
-
* @returns {Promise<
|
|
230
|
+
* @param {string | string[]} [data.bannedWords] - The list of banned words that the password must not contain.
|
|
231
|
+
* @returns {Promise<Interfaces.PasswordValidationResult>} A promise that resolves to the response from the server.
|
|
220
232
|
* @throws Will throw an error if there is an issue with the password validation process.
|
|
221
233
|
*/
|
|
222
234
|
async isValidPwd(data) {
|
|
223
235
|
return await PublicAPI.isValidPwd(data);
|
|
224
236
|
}
|
|
225
|
-
/**
|
|
226
|
-
* Encrypts a URL using the configured encryption settings.
|
|
227
|
-
*
|
|
228
|
-
* This method requires the URL to be provided in the data object.
|
|
229
|
-
* If the URL is not provided, it will throw an error.
|
|
230
|
-
*
|
|
231
|
-
* @param {Object} data - The data to be sent.
|
|
232
|
-
* @param {string} data.url - The URL to be encrypted.
|
|
233
|
-
* @returns {Promise<Object>} A promise that resolves to the response from the server.
|
|
234
|
-
* @throws Will throw an error if there is an issue with the URL encryption process.
|
|
235
|
-
*/
|
|
236
|
-
async newURLEncrypt(data) {
|
|
237
|
-
return await PublicAPI.newURLEncrypt(data);
|
|
238
|
-
}
|
|
239
237
|
}
|
|
238
|
+
DymoAPI.tokensResponse = null;
|
|
239
|
+
DymoAPI.tokensVerified = false;
|
|
240
240
|
export default DymoAPI;
|
|
@@ -1,22 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
interface InputSatinizerData {
|
|
6
|
-
input?: string;
|
|
7
|
-
}
|
|
8
|
-
interface IsValidPwdData {
|
|
9
|
-
email?: string;
|
|
10
|
-
password?: string;
|
|
11
|
-
bannedWords?: string | string[];
|
|
12
|
-
min?: number;
|
|
13
|
-
max?: number;
|
|
14
|
-
}
|
|
15
|
-
interface NewURLEncryptData {
|
|
16
|
-
url?: string;
|
|
17
|
-
}
|
|
18
|
-
export declare const getPrayerTimes: (data: PrayerTimesData) => Promise<any>;
|
|
19
|
-
export declare const satinizer: (data: InputSatinizerData) => Promise<any>;
|
|
20
|
-
export declare const isValidPwd: (data: IsValidPwdData) => Promise<any>;
|
|
21
|
-
export declare const newURLEncrypt: (data: NewURLEncryptData) => Promise<any>;
|
|
22
|
-
export {};
|
|
1
|
+
import * as Interfaces from "../lib/interfaces";
|
|
2
|
+
export declare const getPrayerTimes: (data: Interfaces.PrayerTimesData) => Promise<any>;
|
|
3
|
+
export declare const satinizer: (data: Interfaces.InputSatinizerData) => Promise<any>;
|
|
4
|
+
export declare const isValidPwd: (data: Interfaces.IsValidPwdData) => Promise<any>;
|
package/dist/types/dymo-api.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as Interfaces from "./lib/interfaces";
|
|
1
2
|
interface ServerEmailConfig {
|
|
2
3
|
host: string;
|
|
3
4
|
port: number;
|
|
@@ -15,10 +16,10 @@ interface ServerEmailConfig {
|
|
|
15
16
|
declare class DymoAPI {
|
|
16
17
|
private rootApiKey;
|
|
17
18
|
private apiKey;
|
|
18
|
-
private static tokensResponse;
|
|
19
|
-
private static tokensVerified;
|
|
20
19
|
private serverEmailConfig?;
|
|
21
20
|
private local;
|
|
21
|
+
private static tokensResponse;
|
|
22
|
+
private static tokensVerified;
|
|
22
23
|
/**
|
|
23
24
|
* @param {Object} options - Options to create the DymoAPI instance.
|
|
24
25
|
* @param {string} [options.rootApiKey] - The root API key.
|
|
@@ -53,12 +54,12 @@ declare class DymoAPI {
|
|
|
53
54
|
* The method also handles validation of root and API tokens, throwing errors if
|
|
54
55
|
* any of the tokens are invalid. Cached tokens are considered valid for 5 minutes.
|
|
55
56
|
*
|
|
56
|
-
* @returns {Promise<
|
|
57
|
+
* @returns {Promise<TokensResponse|undefined>} A promise that resolves to the tokens response
|
|
57
58
|
* if successful, or undefined if no tokens are available.
|
|
58
59
|
* @throws Will throw an error if token validation fails, or if there is an issue
|
|
59
60
|
* with the token retrieval process.
|
|
60
61
|
*/
|
|
61
|
-
private
|
|
62
|
+
private getTokens;
|
|
62
63
|
/**
|
|
63
64
|
* Initializes the tokens response by calling getTokens().
|
|
64
65
|
*
|
|
@@ -86,10 +87,17 @@ declare class DymoAPI {
|
|
|
86
87
|
* If neither is set, it will throw an error.
|
|
87
88
|
*
|
|
88
89
|
* @param {Object} data - The data to be validated.
|
|
89
|
-
* @
|
|
90
|
+
* @param {string} [data.email] - Optional email address to be validated.
|
|
91
|
+
* @param {Interfaces.PhoneData} [data.phone] - Optional phone number data to be validated.
|
|
92
|
+
* @param {string} [data.domain] - Optional domain name to be validated.
|
|
93
|
+
* @param {string|Interfaces.CreditCardData} [data.creditCard] - Optional credit card number or data to be validated.
|
|
94
|
+
* @param {string} [data.ip] - Optional IP address to be validated.
|
|
95
|
+
* @param {string} [data.wallet] - Optional wallet address to be validated.
|
|
96
|
+
* @param {Interfaces.VerifyPlugins[]} [data.plugins] - Optional array of verification plugins to be used.
|
|
97
|
+
* @returns {Promise<Interfaces.DataValidationAnalysis>} A promise that resolves to the response from the server.
|
|
90
98
|
* @throws Will throw an error if there is an issue with the validation process.
|
|
91
99
|
*/
|
|
92
|
-
isValidData(data:
|
|
100
|
+
isValidData(data: Interfaces.Validator): Promise<Interfaces.DataValidationAnalysis>;
|
|
93
101
|
/**
|
|
94
102
|
* Sends an email using the configured email client settings.
|
|
95
103
|
*
|
|
@@ -111,23 +119,24 @@ declare class DymoAPI {
|
|
|
111
119
|
* @param {string} [data.attachments[].path] - The path or URL of the attached file. Either this or `content` must be provided.
|
|
112
120
|
* @param {Buffer} [data.attachments[].content] - The content of the attached file as a Buffer. Either this or `path` must be provided.
|
|
113
121
|
* @param {string} [data.attachments[].cid] - The CID (Content-ID) of the attached file, used for inline images.
|
|
114
|
-
* @returns {Promise<
|
|
122
|
+
* @returns {Promise<Interfaces.EmailStatus>} A promise that resolves to the response from the server.
|
|
115
123
|
* @throws Will throw an error if there is an issue with the email sending process.
|
|
116
124
|
*/
|
|
117
|
-
sendEmail(data: any): Promise<
|
|
125
|
+
sendEmail(data: any): Promise<Interfaces.EmailStatus>;
|
|
118
126
|
/**
|
|
119
127
|
* Generates a random number between the provided min and max values.
|
|
120
128
|
*
|
|
121
129
|
* This method requires either the root API key or the API key to be set.
|
|
122
130
|
* If neither is set, it will throw an error.
|
|
123
131
|
*
|
|
124
|
-
* @param {
|
|
132
|
+
* @param {Interfaces.SRNG} data - The data to be sent.
|
|
125
133
|
* @param {number} data.min - The minimum value of the range.
|
|
126
134
|
* @param {number} data.max - The maximum value of the range.
|
|
127
|
-
* @
|
|
135
|
+
* @param {number} [data.quantity] - The number of random values to generate. Defaults to 1 if not provided.
|
|
136
|
+
* @returns {Promise<Interfaces.SRNSummary>} A promise that resolves to the response from the server.
|
|
128
137
|
* @throws Will throw an error if there is an issue with the random number generation process.
|
|
129
138
|
*/
|
|
130
|
-
getRandom(data:
|
|
139
|
+
getRandom(data: Interfaces.SRNG): Promise<Interfaces.SRNSummary>;
|
|
131
140
|
/**
|
|
132
141
|
* Retrieves the prayer times for the given location.
|
|
133
142
|
*
|
|
@@ -137,20 +146,22 @@ declare class DymoAPI {
|
|
|
137
146
|
* @param {Object} data - The data to be sent.
|
|
138
147
|
* @param {number} data.lat - The latitude of the location.
|
|
139
148
|
* @param {number} data.lon - The longitude of the location.
|
|
140
|
-
* @returns {Promise<
|
|
149
|
+
* @returns {Promise<Interfaces.CountryPrayerTimes | { error: string }>} A promise that resolves to the response from the server.
|
|
141
150
|
* @throws Will throw an error if there is an issue with the prayer times retrieval process.
|
|
142
151
|
*/
|
|
143
|
-
getPrayerTimes(data:
|
|
152
|
+
getPrayerTimes(data: Interfaces.PrayerTimesData): Promise<Interfaces.CountryPrayerTimes | {
|
|
153
|
+
error: string;
|
|
154
|
+
}>;
|
|
144
155
|
/**
|
|
145
156
|
* Satinizes the input, replacing any special characters with their HTML
|
|
146
157
|
* entities.
|
|
147
158
|
*
|
|
148
159
|
* @param {Object} data - The data to be sent.
|
|
149
160
|
* @param {string} data.input - The input to be satinized.
|
|
150
|
-
* @returns {Promise<
|
|
161
|
+
* @returns {Promise<Interfaces.SatinizedInputAnalysis>} A promise that resolves to the response from the server.
|
|
151
162
|
* @throws Will throw an error if there is an issue with the satinization process.
|
|
152
163
|
*/
|
|
153
|
-
satinizer(data:
|
|
164
|
+
satinizer(data: Interfaces.InputSatinizerData): Promise<Interfaces.SatinizedInputAnalysis>;
|
|
154
165
|
/**
|
|
155
166
|
* Validates a password based on the given parameters.
|
|
156
167
|
*
|
|
@@ -166,23 +177,14 @@ declare class DymoAPI {
|
|
|
166
177
|
* - The password must not contain any of the given banned words.
|
|
167
178
|
*
|
|
168
179
|
* @param {Object} data - The data to be sent.
|
|
180
|
+
* @param {number} [data.min] - Minimum length of the password. Defaults to 8 if not provided.
|
|
181
|
+
* @param {number} [data.max] - Maximum length of the password. Defaults to 32 if not provided.
|
|
182
|
+
* @param {string} [data.email] - Optional email associated with the password.
|
|
169
183
|
* @param {string} data.password - The password to be validated.
|
|
170
|
-
* @param {string[]} [data.bannedWords] - The list of banned words that the password must not contain.
|
|
171
|
-
* @returns {Promise<
|
|
184
|
+
* @param {string | string[]} [data.bannedWords] - The list of banned words that the password must not contain.
|
|
185
|
+
* @returns {Promise<Interfaces.PasswordValidationResult>} A promise that resolves to the response from the server.
|
|
172
186
|
* @throws Will throw an error if there is an issue with the password validation process.
|
|
173
187
|
*/
|
|
174
|
-
isValidPwd(data:
|
|
175
|
-
/**
|
|
176
|
-
* Encrypts a URL using the configured encryption settings.
|
|
177
|
-
*
|
|
178
|
-
* This method requires the URL to be provided in the data object.
|
|
179
|
-
* If the URL is not provided, it will throw an error.
|
|
180
|
-
*
|
|
181
|
-
* @param {Object} data - The data to be sent.
|
|
182
|
-
* @param {string} data.url - The URL to be encrypted.
|
|
183
|
-
* @returns {Promise<Object>} A promise that resolves to the response from the server.
|
|
184
|
-
* @throws Will throw an error if there is an issue with the URL encryption process.
|
|
185
|
-
*/
|
|
186
|
-
newURLEncrypt(data: any): Promise<any>;
|
|
188
|
+
isValidPwd(data: Interfaces.IsValidPwdData): Promise<Interfaces.PasswordValidationResult>;
|
|
187
189
|
}
|
|
188
190
|
export default DymoAPI;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
interface PhoneData {
|
|
1
|
+
export interface PhoneData {
|
|
2
2
|
iso: any;
|
|
3
3
|
phone: string;
|
|
4
4
|
}
|
|
5
|
-
interface CreditCardData {
|
|
5
|
+
export interface CreditCardData {
|
|
6
6
|
pan: string | number;
|
|
7
7
|
expirationDate?: string;
|
|
8
8
|
cvc?: string | number;
|
|
9
9
|
cvv?: string | number;
|
|
10
10
|
}
|
|
11
|
+
export type VerifyPlugins = "compromiseDetector" | "nsfw" | "reputation" | "torNetwork" | "typosquatting" | "urlShortener";
|
|
11
12
|
export interface Validator {
|
|
12
13
|
email?: string;
|
|
13
14
|
phone?: PhoneData;
|
|
@@ -15,6 +16,7 @@ export interface Validator {
|
|
|
15
16
|
creditCard?: string | CreditCardData;
|
|
16
17
|
ip?: string;
|
|
17
18
|
wallet?: string;
|
|
19
|
+
plugins?: VerifyPlugins[];
|
|
18
20
|
}
|
|
19
21
|
export interface SRNG {
|
|
20
22
|
min: number;
|
|
@@ -37,7 +39,186 @@ export interface SendEmail {
|
|
|
37
39
|
priority?: "high" | "normal" | "low" | undefined;
|
|
38
40
|
composeTailwindClasses?: boolean;
|
|
39
41
|
compileToCssSafe?: boolean;
|
|
42
|
+
onlyVerifiedEmails?: boolean;
|
|
40
43
|
};
|
|
41
44
|
attachments?: Attachment[];
|
|
42
45
|
}
|
|
43
|
-
export {
|
|
46
|
+
export interface PrayerTimesData {
|
|
47
|
+
lat?: number;
|
|
48
|
+
lon?: number;
|
|
49
|
+
}
|
|
50
|
+
export interface InputSatinizerData {
|
|
51
|
+
input?: string;
|
|
52
|
+
}
|
|
53
|
+
export interface IsValidPwdData {
|
|
54
|
+
email?: string;
|
|
55
|
+
password?: string;
|
|
56
|
+
bannedWords?: string | string[];
|
|
57
|
+
min?: number;
|
|
58
|
+
max?: number;
|
|
59
|
+
}
|
|
60
|
+
export interface SRNComponent {
|
|
61
|
+
integer: number;
|
|
62
|
+
float: number;
|
|
63
|
+
}
|
|
64
|
+
export interface SRNSummary {
|
|
65
|
+
values: SRNComponent[];
|
|
66
|
+
executionTime: number;
|
|
67
|
+
}
|
|
68
|
+
export interface CountryPrayerTimes {
|
|
69
|
+
country: string;
|
|
70
|
+
prayerTimesByTimezone: {
|
|
71
|
+
timezone: string;
|
|
72
|
+
prayerTimes: {
|
|
73
|
+
coordinates: string;
|
|
74
|
+
date: string;
|
|
75
|
+
calculationParameters: string;
|
|
76
|
+
fajr: string;
|
|
77
|
+
sunrise: string;
|
|
78
|
+
dhuhr: string;
|
|
79
|
+
asr: string;
|
|
80
|
+
sunset: string;
|
|
81
|
+
maghrib: string;
|
|
82
|
+
isha: string;
|
|
83
|
+
};
|
|
84
|
+
}[];
|
|
85
|
+
}
|
|
86
|
+
export interface SatinizedInputAnalysis {
|
|
87
|
+
input: string;
|
|
88
|
+
formats: {
|
|
89
|
+
ascii: boolean;
|
|
90
|
+
bitcoinAddress: boolean;
|
|
91
|
+
cLikeIdentifier: boolean;
|
|
92
|
+
coordinates: boolean;
|
|
93
|
+
crediCard: boolean;
|
|
94
|
+
date: boolean;
|
|
95
|
+
discordUsername: boolean;
|
|
96
|
+
doi: boolean;
|
|
97
|
+
domain: boolean;
|
|
98
|
+
e164Phone: boolean;
|
|
99
|
+
email: boolean;
|
|
100
|
+
emoji: boolean;
|
|
101
|
+
hanUnification: boolean;
|
|
102
|
+
hashtag: boolean;
|
|
103
|
+
hyphenWordBreak: boolean;
|
|
104
|
+
ipv6: boolean;
|
|
105
|
+
ip: boolean;
|
|
106
|
+
jiraTicket: boolean;
|
|
107
|
+
macAddress: boolean;
|
|
108
|
+
name: boolean;
|
|
109
|
+
number: boolean;
|
|
110
|
+
panFromGstin: boolean;
|
|
111
|
+
password: boolean;
|
|
112
|
+
port: boolean;
|
|
113
|
+
tel: boolean;
|
|
114
|
+
text: boolean;
|
|
115
|
+
semver: boolean;
|
|
116
|
+
ssn: boolean;
|
|
117
|
+
uuid: boolean;
|
|
118
|
+
url: boolean;
|
|
119
|
+
urlSlug: boolean;
|
|
120
|
+
username: boolean;
|
|
121
|
+
};
|
|
122
|
+
includes: {
|
|
123
|
+
spaces: boolean;
|
|
124
|
+
hasSql: boolean;
|
|
125
|
+
hasNoSql: boolean;
|
|
126
|
+
letters: boolean;
|
|
127
|
+
uppercase: boolean;
|
|
128
|
+
lowercase: boolean;
|
|
129
|
+
symbols: boolean;
|
|
130
|
+
digits: boolean;
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
export interface EmailStatus {
|
|
134
|
+
status: boolean;
|
|
135
|
+
error?: string;
|
|
136
|
+
}
|
|
137
|
+
export interface ValidationDetail {
|
|
138
|
+
validation: string;
|
|
139
|
+
message: string;
|
|
140
|
+
word?: string;
|
|
141
|
+
}
|
|
142
|
+
export interface PasswordValidationResult {
|
|
143
|
+
valid: boolean;
|
|
144
|
+
password: string;
|
|
145
|
+
details: ValidationDetail[];
|
|
146
|
+
}
|
|
147
|
+
export interface DataValidationAnalysis {
|
|
148
|
+
email: {
|
|
149
|
+
valid: boolean;
|
|
150
|
+
fraud: boolean;
|
|
151
|
+
proxiedEmail: boolean;
|
|
152
|
+
freeSubdomain: boolean;
|
|
153
|
+
corporate: boolean;
|
|
154
|
+
email: string;
|
|
155
|
+
realUser: string;
|
|
156
|
+
didYouMean: string | null;
|
|
157
|
+
customTLD: boolean;
|
|
158
|
+
domain: string;
|
|
159
|
+
roleAccount: boolean;
|
|
160
|
+
plugins: {};
|
|
161
|
+
};
|
|
162
|
+
phone: {
|
|
163
|
+
valid: boolean;
|
|
164
|
+
fraud: boolean;
|
|
165
|
+
phone: string;
|
|
166
|
+
prefix: string;
|
|
167
|
+
number: string;
|
|
168
|
+
country: string;
|
|
169
|
+
countryCode: string;
|
|
170
|
+
plugins: {};
|
|
171
|
+
};
|
|
172
|
+
domain: {
|
|
173
|
+
valid: boolean;
|
|
174
|
+
fraud: boolean;
|
|
175
|
+
freeSubdomain: boolean;
|
|
176
|
+
customTLD: boolean;
|
|
177
|
+
domain: string;
|
|
178
|
+
plugins: {};
|
|
179
|
+
};
|
|
180
|
+
creditCard: {
|
|
181
|
+
valid: boolean;
|
|
182
|
+
fraud: boolean;
|
|
183
|
+
test: boolean;
|
|
184
|
+
type: string;
|
|
185
|
+
creditCard: string;
|
|
186
|
+
plugins: {};
|
|
187
|
+
};
|
|
188
|
+
ip: {
|
|
189
|
+
valid: boolean;
|
|
190
|
+
type: "IPv4" | "IPv6" | "Invalid";
|
|
191
|
+
class: "A" | "B" | "C" | "D" | "E" | "Unknown" | "None";
|
|
192
|
+
fraud: boolean;
|
|
193
|
+
ip: string;
|
|
194
|
+
continent: string;
|
|
195
|
+
continentCode: string;
|
|
196
|
+
country: string;
|
|
197
|
+
countryCode: string;
|
|
198
|
+
region: string;
|
|
199
|
+
regionName: string;
|
|
200
|
+
city: string;
|
|
201
|
+
district: string;
|
|
202
|
+
zipCode: string;
|
|
203
|
+
lat: number;
|
|
204
|
+
lon: number;
|
|
205
|
+
timezone: string;
|
|
206
|
+
offset: number;
|
|
207
|
+
currency: string;
|
|
208
|
+
isp: string;
|
|
209
|
+
org: string;
|
|
210
|
+
as: string;
|
|
211
|
+
asname: string;
|
|
212
|
+
mobile: boolean;
|
|
213
|
+
proxy: boolean;
|
|
214
|
+
hosting: boolean;
|
|
215
|
+
plugins: {};
|
|
216
|
+
};
|
|
217
|
+
wallet: {
|
|
218
|
+
valid: boolean;
|
|
219
|
+
fraud: boolean;
|
|
220
|
+
wallet: string;
|
|
221
|
+
type: "Bitcoin" | "Bitcoin (Bech32)" | "Ethereum" | "Litecoin" | "Cardano" | "Binance Smart Chain";
|
|
222
|
+
plugins: {};
|
|
223
|
+
};
|
|
224
|
+
}
|