dymo-api 1.0.22 → 1.0.24
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/branches/private.js +105 -0
- package/dist/branches/public.js +113 -0
- package/dist/config/index.js +19 -0
- package/dist/dymo-api.js +117 -0
- package/dist/lib/interfaces.js +5 -0
- package/dist/types/branches/private.d.ts +4 -0
- package/dist/types/branches/public.d.ts +22 -0
- package/dist/types/config/index.d.ts +13 -0
- package/dist/types/dymo-api.d.ts +34 -0
- package/{src/lib/interfaces.ts → dist/types/lib/interfaces.d.ts} +37 -29
- package/package.json +10 -3
- package/.github/workflows/publish.yml +0 -31
- package/index.d.ts +0 -44
- package/index.ts +0 -3
- package/src/branches/private.ts +0 -62
- package/src/branches/public.ts +0 -93
- package/src/config/index.ts +0 -19
- package/src/dymo-api.ts +0 -118
- package/test/preview.js +0 -16
- package/tsconfig.json +0 -15
|
@@ -0,0 +1,105 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.getRandom = exports.sendEmail = exports.isValidData = void 0;
|
|
30
|
+
const axios_1 = __importDefault(require("axios"));
|
|
31
|
+
const config_1 = __importStar(require("../config"));
|
|
32
|
+
const render_1 = require("@react-email/render");
|
|
33
|
+
const customError = (code, message) => {
|
|
34
|
+
return Object.assign(new Error(), { code, message: `[${config_1.default.lib.name}] ${message}` });
|
|
35
|
+
};
|
|
36
|
+
const isValidData = async (token, data) => {
|
|
37
|
+
if (token === null)
|
|
38
|
+
throw customError(3000, "Invalid private token.");
|
|
39
|
+
let i = false;
|
|
40
|
+
for (const key in data) {
|
|
41
|
+
if (data.hasOwnProperty(key) && (key === "email" || key === "phone" || key === "domain" || key === "creditCard" || key === "ip")) {
|
|
42
|
+
i = true;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (!i)
|
|
47
|
+
throw customError(1500, "You must provide at least one parameter.");
|
|
48
|
+
try {
|
|
49
|
+
const response = await axios_1.default.post(`${config_1.BASE_URL}/v1/private/secure/verify`, data, { headers: { "Authorization": token } });
|
|
50
|
+
return response.data;
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
throw customError(5000, error.message);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
exports.isValidData = isValidData;
|
|
57
|
+
const sendEmail = async (token, data) => {
|
|
58
|
+
if (token === null)
|
|
59
|
+
throw customError(3000, "Invalid private token.");
|
|
60
|
+
if (!data.from)
|
|
61
|
+
throw customError(1500, "You must provide an email address from which the following will be sent.");
|
|
62
|
+
if (!data.to)
|
|
63
|
+
throw customError(1500, "You must provide an email to be sent to.");
|
|
64
|
+
if (!data.subject)
|
|
65
|
+
throw customError(1500, "You must provide a subject for the email to be sent.");
|
|
66
|
+
if (!data.html && !data.react)
|
|
67
|
+
throw customError(1500, "You must provide HTML or a React component.");
|
|
68
|
+
if (data.html && data.react)
|
|
69
|
+
throw customError(1500, "You must provide only HTML or a React component, not both.");
|
|
70
|
+
try {
|
|
71
|
+
data.html = await (0, render_1.renderAsync)(data.react);
|
|
72
|
+
delete data.react;
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
throw customError(1500, "An error occurred while rendering your React component.");
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
const response = await axios_1.default.post(`${config_1.BASE_URL}/v1/private/sender/sendEmail`, data, { headers: { "Authorization": token } });
|
|
79
|
+
return response.data;
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
throw customError(5000, error.message);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
exports.sendEmail = sendEmail;
|
|
86
|
+
const getRandom = async (token, data) => {
|
|
87
|
+
if (token === null)
|
|
88
|
+
throw customError(3000, "Invalid private token.");
|
|
89
|
+
if (!data.min || !data.max)
|
|
90
|
+
throw customError(1500, "Both 'min' and 'max' parameters must be defined.");
|
|
91
|
+
if (data.min >= data.max)
|
|
92
|
+
throw customError(1500, "'min' must be less than 'max'.");
|
|
93
|
+
if (data.min < -1000000000 || data.min > 1000000000)
|
|
94
|
+
throw customError(1500, "'min' must be an integer in the interval [-1000000000}, 1000000000].");
|
|
95
|
+
if (data.max < -1000000000 || data.max > 1000000000)
|
|
96
|
+
throw customError(1500, "'max' must be an integer in the interval [-1000000000}, 1000000000].");
|
|
97
|
+
try {
|
|
98
|
+
const response = await axios_1.default.post(`${config_1.BASE_URL}/v1/private/srng`, data, { headers: { "Authorization": token } });
|
|
99
|
+
return response.data;
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
throw customError(5000, error.message);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
exports.getRandom = getRandom;
|
|
@@ -0,0 +1,113 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.newURLEncrypt = exports.isValidPwd = exports.satinizer = exports.getPrayerTimes = void 0;
|
|
30
|
+
const axios_1 = __importDefault(require("axios"));
|
|
31
|
+
const config_1 = __importStar(require("../config"));
|
|
32
|
+
const customError = (code, message) => {
|
|
33
|
+
return Object.assign(new Error(), { code, message: `[${config_1.default.lib.name}] ${message}` });
|
|
34
|
+
};
|
|
35
|
+
;
|
|
36
|
+
;
|
|
37
|
+
;
|
|
38
|
+
;
|
|
39
|
+
const getPrayerTimes = async (data) => {
|
|
40
|
+
const { lat, lon } = data;
|
|
41
|
+
if (lat === undefined || lon === undefined)
|
|
42
|
+
throw customError(1000, "You must provide a latitude and longitude.");
|
|
43
|
+
try {
|
|
44
|
+
const response = await axios_1.default.get(`${config_1.BASE_URL}/v1/public/islam/prayertimes`, { params: data });
|
|
45
|
+
return response.data;
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
throw customError(5000, error.message);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
exports.getPrayerTimes = getPrayerTimes;
|
|
52
|
+
const satinizer = async (data) => {
|
|
53
|
+
const { input } = data;
|
|
54
|
+
if (input === undefined)
|
|
55
|
+
throw customError(1000, "You must specify at least the input.");
|
|
56
|
+
try {
|
|
57
|
+
const response = await axios_1.default.get(`${config_1.BASE_URL}/v1/public/inputSatinizer`, { params: { input: encodeURIComponent(input) } });
|
|
58
|
+
return response.data;
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
throw customError(5000, error.message);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
exports.satinizer = satinizer;
|
|
65
|
+
const isValidPwd = async (data) => {
|
|
66
|
+
let { email, password, bannedWords, min, max } = data;
|
|
67
|
+
if (password === undefined)
|
|
68
|
+
throw customError(1000, "You must specify at least the password.");
|
|
69
|
+
const params = { password: encodeURIComponent(password) };
|
|
70
|
+
if (email) {
|
|
71
|
+
if (!/^[a-zA-Z0-9._\-+]+@?[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/.test(email))
|
|
72
|
+
throw customError(1500, "If you provide an email address it must be valid.");
|
|
73
|
+
params.email = encodeURIComponent(email);
|
|
74
|
+
}
|
|
75
|
+
if (bannedWords) {
|
|
76
|
+
if (typeof bannedWords === "string")
|
|
77
|
+
bannedWords = bannedWords.slice(1, -1).trim().split(",").map(item => item.trim());
|
|
78
|
+
if (!Array.isArray(bannedWords) || bannedWords.length > 10)
|
|
79
|
+
throw customError(1500, "If you provide a list of banned words; the list may not exceed 10 words and must be of array type.");
|
|
80
|
+
if (!bannedWords.every(word => typeof word === "string") || new Set(bannedWords).size !== bannedWords.length)
|
|
81
|
+
throw customError(1500, "If you provide a list of banned words; all elements must be non-repeated strings.");
|
|
82
|
+
params.bannedWords = bannedWords;
|
|
83
|
+
}
|
|
84
|
+
if (min !== undefined && (!Number.isInteger(min) || min < 8 || min > 32))
|
|
85
|
+
throw customError(1500, "If you provide a minimum it must be valid.");
|
|
86
|
+
if (max !== undefined && (!Number.isInteger(max) || max < 32 || max > 100))
|
|
87
|
+
throw customError(1500, "If you provide a maximum it must be valid.");
|
|
88
|
+
if (min !== undefined)
|
|
89
|
+
params.min = min;
|
|
90
|
+
if (max !== undefined)
|
|
91
|
+
params.max = max;
|
|
92
|
+
try {
|
|
93
|
+
const response = await axios_1.default.get(`${config_1.BASE_URL}/v1/public/validPwd`, { params });
|
|
94
|
+
return response.data;
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
throw customError(5000, error.message);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
exports.isValidPwd = isValidPwd;
|
|
101
|
+
const newURLEncrypt = async (data) => {
|
|
102
|
+
const { url } = data;
|
|
103
|
+
if (url === undefined || (!url.startsWith("https://") && !url.startsWith("http://")))
|
|
104
|
+
throw customError(1500, "You must provide a valid url.");
|
|
105
|
+
try {
|
|
106
|
+
const response = await axios_1.default.get(`${config_1.BASE_URL}/v1/public/url-encrypt`, { params: data });
|
|
107
|
+
return response.data;
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
throw customError(5000, error.message);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
exports.newURLEncrypt = newURLEncrypt;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BASE_URL = exports.setBaseUrl = void 0;
|
|
4
|
+
const config = {
|
|
5
|
+
lib: {
|
|
6
|
+
name: "Dymo API",
|
|
7
|
+
dir: "dymo-api"
|
|
8
|
+
},
|
|
9
|
+
env: {
|
|
10
|
+
baseUrl: "https://api.tpeoficial.com"
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
exports.default = config;
|
|
14
|
+
let BASE_URL = config.env.baseUrl;
|
|
15
|
+
exports.BASE_URL = BASE_URL;
|
|
16
|
+
const setBaseUrl = (isLocal) => {
|
|
17
|
+
exports.BASE_URL = BASE_URL = isLocal ? "http://localhost:3050" : config.env.baseUrl;
|
|
18
|
+
};
|
|
19
|
+
exports.setBaseUrl = setBaseUrl;
|
package/dist/dymo-api.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.DymoAPI = void 0;
|
|
30
|
+
const axios_1 = __importDefault(require("axios"));
|
|
31
|
+
const PublicAPI = __importStar(require("./branches/public"));
|
|
32
|
+
const PrivateAPI = __importStar(require("./branches/private"));
|
|
33
|
+
const config_1 = __importStar(require("./config"));
|
|
34
|
+
const customError = (code, message) => {
|
|
35
|
+
return Object.assign(new Error(), { code, message: `[${config_1.default.lib.name}] ${message}` });
|
|
36
|
+
};
|
|
37
|
+
;
|
|
38
|
+
;
|
|
39
|
+
;
|
|
40
|
+
class DymoAPI {
|
|
41
|
+
constructor({ rootApiKey = null, apiKey = null, local = false, serverEmailConfig = undefined }) {
|
|
42
|
+
this.rootApiKey = rootApiKey;
|
|
43
|
+
this.apiKey = apiKey;
|
|
44
|
+
this.tokensResponse = null;
|
|
45
|
+
this.lastFetchTime = null;
|
|
46
|
+
this.serverEmailConfig = serverEmailConfig;
|
|
47
|
+
this.local = rootApiKey ? local : false; // Only allow setting local if rootApiKey is defined.
|
|
48
|
+
(0, config_1.setBaseUrl)(this.local);
|
|
49
|
+
this.initializeTokens(); // Calls the function to obtain tokens when creating the object.
|
|
50
|
+
}
|
|
51
|
+
getBaseUrl() {
|
|
52
|
+
return this.local ? "http://localhost:3050" : "https://api.tpeoficial.com";
|
|
53
|
+
}
|
|
54
|
+
async getTokens() {
|
|
55
|
+
const currentTime = new Date();
|
|
56
|
+
if (this.tokensResponse && this.lastFetchTime && (currentTime.getTime() - this.lastFetchTime.getTime()) < 5 * 60 * 1000) {
|
|
57
|
+
console.log(`[${config_1.default.lib.name}] Using cached tokens response.`);
|
|
58
|
+
return this.tokensResponse;
|
|
59
|
+
}
|
|
60
|
+
;
|
|
61
|
+
const tokens = {};
|
|
62
|
+
if (this.rootApiKey)
|
|
63
|
+
tokens.root = `Bearer ${this.rootApiKey}`;
|
|
64
|
+
if (this.apiKey)
|
|
65
|
+
tokens.api = `Bearer ${this.apiKey}`;
|
|
66
|
+
try {
|
|
67
|
+
if (Object.keys(tokens).length === 0)
|
|
68
|
+
return;
|
|
69
|
+
const response = await axios_1.default.post(`${config_1.BASE_URL}/v1/dvr/tokens`, { tokens });
|
|
70
|
+
if (tokens.root && response.data.data.root === false)
|
|
71
|
+
throw customError(3000, "Invalid root token.");
|
|
72
|
+
if (tokens.api && response.data.data.api === false)
|
|
73
|
+
throw customError(3000, "Invalid API token.");
|
|
74
|
+
this.tokensResponse = response.data.data;
|
|
75
|
+
this.lastFetchTime = currentTime;
|
|
76
|
+
console.log(`[${config_1.default.lib.name}] Tokens initialized successfully.`);
|
|
77
|
+
return this.tokensResponse;
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
throw customError(5000, error.message);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
async initializeTokens() {
|
|
84
|
+
try {
|
|
85
|
+
await this.getTokens();
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
throw customError(5000, `Error initializing tokens: ${error.message}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// FUNCTIONS / Private.
|
|
92
|
+
async isValidData(data) {
|
|
93
|
+
return await PrivateAPI.isValidData(this.apiKey, data);
|
|
94
|
+
}
|
|
95
|
+
async sendEmail(data) {
|
|
96
|
+
if (this.serverEmailConfig)
|
|
97
|
+
throw customError(5000, `You must configure the email client settings.`);
|
|
98
|
+
return await PrivateAPI.sendEmail(this.apiKey, { serverEmailConfig: this.serverEmailConfig, ...data });
|
|
99
|
+
}
|
|
100
|
+
async getRandom(data) {
|
|
101
|
+
return await PrivateAPI.getRandom(this.apiKey, data);
|
|
102
|
+
}
|
|
103
|
+
// FUNCTIONS / Public.
|
|
104
|
+
async getPrayerTimes(data) {
|
|
105
|
+
return await PublicAPI.getPrayerTimes(data);
|
|
106
|
+
}
|
|
107
|
+
async satinizer(data) {
|
|
108
|
+
return await PublicAPI.satinizer(data);
|
|
109
|
+
}
|
|
110
|
+
async isValidPwd(data) {
|
|
111
|
+
return await PublicAPI.isValidPwd(data);
|
|
112
|
+
}
|
|
113
|
+
async newURLEncrypt(data) {
|
|
114
|
+
return await PublicAPI.newURLEncrypt(data);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.DymoAPI = DymoAPI;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as Interfaces from "../lib/interfaces";
|
|
2
|
+
export declare const isValidData: (token: string | null, data: Interfaces.Validator) => Promise<any>;
|
|
3
|
+
export declare const sendEmail: (token: string | null, data: Interfaces.SendEmail) => Promise<any>;
|
|
4
|
+
export declare const getRandom: (token: string | null, data: Interfaces.SRNG) => Promise<any>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
interface PrayerTimesData {
|
|
2
|
+
lat?: number;
|
|
3
|
+
lon?: number;
|
|
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 {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
interface ServerEmailConfig {
|
|
2
|
+
host: string;
|
|
3
|
+
port: number;
|
|
4
|
+
secure: boolean;
|
|
5
|
+
auth: {
|
|
6
|
+
user: string;
|
|
7
|
+
pass: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
declare class DymoAPI {
|
|
11
|
+
private rootApiKey;
|
|
12
|
+
private apiKey;
|
|
13
|
+
private tokensResponse;
|
|
14
|
+
private lastFetchTime;
|
|
15
|
+
private serverEmailConfig?;
|
|
16
|
+
private local;
|
|
17
|
+
constructor({ rootApiKey, apiKey, local, serverEmailConfig }: {
|
|
18
|
+
rootApiKey?: string | null;
|
|
19
|
+
apiKey?: string | null;
|
|
20
|
+
local?: boolean;
|
|
21
|
+
serverEmailConfig?: ServerEmailConfig;
|
|
22
|
+
});
|
|
23
|
+
private getBaseUrl;
|
|
24
|
+
private getTokens;
|
|
25
|
+
private initializeTokens;
|
|
26
|
+
isValidData(data: any): Promise<any>;
|
|
27
|
+
sendEmail(data: any): Promise<any>;
|
|
28
|
+
getRandom(data: any): Promise<any>;
|
|
29
|
+
getPrayerTimes(data: any): Promise<any>;
|
|
30
|
+
satinizer(data: any): Promise<any>;
|
|
31
|
+
isValidPwd(data: any): Promise<any>;
|
|
32
|
+
newURLEncrypt(data: any): Promise<any>;
|
|
33
|
+
}
|
|
34
|
+
export { DymoAPI };
|
|
@@ -1,29 +1,37 @@
|
|
|
1
|
-
import type * as React from "react";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
interface PhoneData {
|
|
3
|
+
iso: any;
|
|
4
|
+
phone: string;
|
|
5
|
+
}
|
|
6
|
+
interface CreditCardData {
|
|
7
|
+
pan: string | number;
|
|
8
|
+
expirationDate?: string;
|
|
9
|
+
cvc?: string | number;
|
|
10
|
+
cvv?: string | number;
|
|
11
|
+
}
|
|
12
|
+
export interface Validator {
|
|
13
|
+
email?: string;
|
|
14
|
+
phone?: PhoneData;
|
|
15
|
+
domain?: string;
|
|
16
|
+
creditCard?: string | CreditCardData;
|
|
17
|
+
ip?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface SRNG {
|
|
20
|
+
min: number;
|
|
21
|
+
max: number;
|
|
22
|
+
quantity?: number;
|
|
23
|
+
}
|
|
24
|
+
export type SendEmail = {
|
|
25
|
+
from: string;
|
|
26
|
+
to: string;
|
|
27
|
+
subject: string;
|
|
28
|
+
html: string;
|
|
29
|
+
react?: never;
|
|
30
|
+
} | {
|
|
31
|
+
from: string;
|
|
32
|
+
to: string;
|
|
33
|
+
subject: string;
|
|
34
|
+
html?: never;
|
|
35
|
+
react: React.ReactNode;
|
|
36
|
+
};
|
|
37
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dymo-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.24",
|
|
4
4
|
"description": "Flow system for Dymo API.",
|
|
5
|
-
"main": "dist/
|
|
5
|
+
"main": "dist/dymo-api.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist/**/*",
|
|
8
|
+
"README.md",
|
|
9
|
+
"LICENSE"
|
|
10
|
+
],
|
|
11
|
+
"types": "dist/dymo-api.d.ts",
|
|
6
12
|
"type": "module",
|
|
7
13
|
"scripts": {
|
|
8
14
|
"build": "tsc",
|
|
9
15
|
"start": "ts-node src/dymo-api.ts",
|
|
16
|
+
"prepublishOnly": "npm run build",
|
|
10
17
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
11
18
|
},
|
|
12
19
|
"repository": {
|
|
@@ -39,4 +46,4 @@
|
|
|
39
46
|
"ts-node": "^10.9.2",
|
|
40
47
|
"typescript": "^5.5.4"
|
|
41
48
|
}
|
|
42
|
-
}
|
|
49
|
+
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
name: Publish Package
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
release:
|
|
5
|
-
types: [published]
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
publish:
|
|
9
|
-
name: publish
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
environment: publish
|
|
12
|
-
|
|
13
|
-
steps:
|
|
14
|
-
- name: Checkout code
|
|
15
|
-
uses: actions/checkout@v3
|
|
16
|
-
|
|
17
|
-
- name: Set up Node.js
|
|
18
|
-
uses: actions/setup-node@v3
|
|
19
|
-
with:
|
|
20
|
-
node-version: "18"
|
|
21
|
-
|
|
22
|
-
- name: Install dependencies
|
|
23
|
-
run: npm install
|
|
24
|
-
|
|
25
|
-
- name: Build
|
|
26
|
-
run: npm run build
|
|
27
|
-
|
|
28
|
-
- name: Publish to npm
|
|
29
|
-
run: npm publish
|
|
30
|
-
env:
|
|
31
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/index.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export interface ConfigurationOptions {
|
|
2
|
-
rootApiKey?: string;
|
|
3
|
-
apiKey?: string;
|
|
4
|
-
local?: boolean;
|
|
5
|
-
serverEmailConfig?: {
|
|
6
|
-
host: string;
|
|
7
|
-
port: number;
|
|
8
|
-
secure: boolean;
|
|
9
|
-
auth: {
|
|
10
|
-
user: string;
|
|
11
|
-
pass: string;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
declare module "dymo-api" {
|
|
17
|
-
class DymoAPI {
|
|
18
|
-
private rootApiKey: string | null;
|
|
19
|
-
private apiKey: string | null;
|
|
20
|
-
private tokensResponse: { root: boolean; api: boolean; } | null;
|
|
21
|
-
private lastFetchTime: Date | null;
|
|
22
|
-
private serverEmailConfig?: {
|
|
23
|
-
host: string;
|
|
24
|
-
port: number;
|
|
25
|
-
secure: boolean;
|
|
26
|
-
auth: {
|
|
27
|
-
user: string;
|
|
28
|
-
pass: string;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
private local: boolean;
|
|
32
|
-
constructor(configuration?: ConfigurationOptions);
|
|
33
|
-
initializeTokens(): Promise<void>;
|
|
34
|
-
isValidData(data: any): Promise<any>;
|
|
35
|
-
getRandom(data: any): Promise<any>;
|
|
36
|
-
getPrayerTimes(data: any): Promise<any>;
|
|
37
|
-
inputSatinizer(data: any): Promise<any>;
|
|
38
|
-
isValidPwd(data: any): Promise<any>;
|
|
39
|
-
newURLEncrypt(data: any): Promise<any>;
|
|
40
|
-
sendEmail(data: any): Promise<any>;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export { DymoAPI };
|
|
44
|
-
}
|
package/index.ts
DELETED
package/src/branches/private.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
|
-
import config, { BASE_URL } from "../config";
|
|
3
|
-
import * as Interfaces from "../lib/interfaces";
|
|
4
|
-
import { renderAsync } from "@react-email/render";
|
|
5
|
-
|
|
6
|
-
const customError = (code: number, message: string): Error => {
|
|
7
|
-
return Object.assign(new Error(), { code, message: `[${config.lib.name}] ${message}` });
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const isValidData = async (token: string | null, data: Interfaces.Validator): Promise<any> => {
|
|
11
|
-
if (token === null) throw customError(3000, "Invalid private token.");
|
|
12
|
-
let i = false;
|
|
13
|
-
for (const key in data) {
|
|
14
|
-
if (data.hasOwnProperty(key) && (key === "email" || key === "phone" || key === "domain" || key === "creditCard" || key === "ip")) {
|
|
15
|
-
i = true;
|
|
16
|
-
break;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
if (!i) throw customError(1500, "You must provide at least one parameter.");
|
|
20
|
-
try {
|
|
21
|
-
const response = await axios.post(`${BASE_URL}/v1/private/secure/verify`, data, { headers: { "Authorization": token } });
|
|
22
|
-
return response.data;
|
|
23
|
-
} catch (error: any) {
|
|
24
|
-
throw customError(5000, error.message);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const sendEmail = async (token: string | null, data: Interfaces.SendEmail): Promise<any> => {
|
|
29
|
-
if (token === null) throw customError(3000, "Invalid private token.");
|
|
30
|
-
|
|
31
|
-
if (!data.from) throw customError(1500, "You must provide an email address from which the following will be sent.");
|
|
32
|
-
if (!data.to) throw customError(1500, "You must provide an email to be sent to.");
|
|
33
|
-
if (!data.subject) throw customError(1500, "You must provide a subject for the email to be sent.");
|
|
34
|
-
if (!data.html && !data.react) throw customError(1500, "You must provide HTML or a React component.");
|
|
35
|
-
if (data.html && data.react) throw customError(1500, "You must provide only HTML or a React component, not both.");
|
|
36
|
-
try {
|
|
37
|
-
data.html = await renderAsync(data.react as React.ReactElement);
|
|
38
|
-
delete data.react;
|
|
39
|
-
} catch (error) {
|
|
40
|
-
throw customError(1500, "An error occurred while rendering your React component.");
|
|
41
|
-
}
|
|
42
|
-
try {
|
|
43
|
-
const response = await axios.post(`${BASE_URL}/v1/private/sender/sendEmail`, data, { headers: { "Authorization": token } });
|
|
44
|
-
return response.data;
|
|
45
|
-
} catch (error: any) {
|
|
46
|
-
throw customError(5000, error.message);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export const getRandom = async (token: string | null, data: Interfaces.SRNG): Promise<any> => {
|
|
51
|
-
if (token === null) throw customError(3000, "Invalid private token.");
|
|
52
|
-
if (!data.min || !data.max) throw customError(1500, "Both 'min' and 'max' parameters must be defined.");
|
|
53
|
-
if (data.min >= data.max) throw customError(1500, "'min' must be less than 'max'.");
|
|
54
|
-
if (data.min < -1000000000 || data.min > 1000000000) throw customError(1500, "'min' must be an integer in the interval [-1000000000}, 1000000000].");
|
|
55
|
-
if (data.max < -1000000000 || data.max > 1000000000) throw customError(1500, "'max' must be an integer in the interval [-1000000000}, 1000000000].");
|
|
56
|
-
try {
|
|
57
|
-
const response = await axios.post(`${BASE_URL}/v1/private/srng`, data, { headers: { "Authorization": token } });
|
|
58
|
-
return response.data;
|
|
59
|
-
} catch (error: any) {
|
|
60
|
-
throw customError(5000, error.message);
|
|
61
|
-
}
|
|
62
|
-
};
|
package/src/branches/public.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
|
-
import config, { BASE_URL } from "../config";
|
|
3
|
-
|
|
4
|
-
const customError = (code: number, message: string): Error => {
|
|
5
|
-
return Object.assign(new Error(), { code, message: `[${config.lib.name}] ${message}` });
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
interface PrayerTimesData {
|
|
9
|
-
lat?: number;
|
|
10
|
-
lon?: number;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
interface InputSatinizerData {
|
|
14
|
-
input?: string;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
interface IsValidPwdData {
|
|
18
|
-
email?: string;
|
|
19
|
-
password?: string;
|
|
20
|
-
bannedWords?: string | string[];
|
|
21
|
-
min?: number;
|
|
22
|
-
max?: number;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
interface NewURLEncryptData {
|
|
26
|
-
url?: string;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export const getPrayerTimes = async (data: PrayerTimesData): Promise<any> => {
|
|
30
|
-
const { lat, lon } = data;
|
|
31
|
-
if (lat === undefined || lon === undefined) throw customError(1000, "You must provide a latitude and longitude.");
|
|
32
|
-
try {
|
|
33
|
-
const response = await axios.get(`${BASE_URL}/v1/public/islam/prayertimes`, { params: data });
|
|
34
|
-
return response.data;
|
|
35
|
-
} catch (error: any) {
|
|
36
|
-
throw customError(5000, error.message);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export const satinizer = async (data: InputSatinizerData): Promise<any> => {
|
|
41
|
-
const { input } = data;
|
|
42
|
-
if (input === undefined) throw customError(1000, "You must specify at least the input.");
|
|
43
|
-
try {
|
|
44
|
-
const response = await axios.get(`${BASE_URL}/v1/public/inputSatinizer`, { params: { input: encodeURIComponent(input) } });
|
|
45
|
-
return response.data;
|
|
46
|
-
} catch (error: any) {
|
|
47
|
-
throw customError(5000, error.message);
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export const isValidPwd = async (data: IsValidPwdData): Promise<any> => {
|
|
52
|
-
let { email, password, bannedWords, min, max } = data;
|
|
53
|
-
if (password === undefined) throw customError(1000, "You must specify at least the password.");
|
|
54
|
-
const params: { [key: string]: any } = { password: encodeURIComponent(password) };
|
|
55
|
-
|
|
56
|
-
if (email) {
|
|
57
|
-
if (!/^[a-zA-Z0-9._\-+]+@?[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/.test(email)) throw customError(1500, "If you provide an email address it must be valid.");
|
|
58
|
-
params.email = encodeURIComponent(email);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (bannedWords) {
|
|
62
|
-
if (typeof bannedWords === "string") bannedWords = bannedWords.slice(1, -1).trim().split(",").map(item => item.trim());
|
|
63
|
-
|
|
64
|
-
if (!Array.isArray(bannedWords) || bannedWords.length > 10)
|
|
65
|
-
throw customError(1500, "If you provide a list of banned words; the list may not exceed 10 words and must be of array type.");
|
|
66
|
-
if (!bannedWords.every(word => typeof word === "string") || new Set(bannedWords).size !== bannedWords.length)
|
|
67
|
-
throw customError(1500, "If you provide a list of banned words; all elements must be non-repeated strings.");
|
|
68
|
-
params.bannedWords = bannedWords;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (min !== undefined && (!Number.isInteger(min) || min < 8 || min > 32)) throw customError(1500, "If you provide a minimum it must be valid.");
|
|
72
|
-
if (max !== undefined && (!Number.isInteger(max) || max < 32 || max > 100)) throw customError(1500, "If you provide a maximum it must be valid.");
|
|
73
|
-
if (min !== undefined) params.min = min;
|
|
74
|
-
if (max !== undefined) params.max = max;
|
|
75
|
-
|
|
76
|
-
try {
|
|
77
|
-
const response = await axios.get(`${BASE_URL}/v1/public/validPwd`, { params });
|
|
78
|
-
return response.data;
|
|
79
|
-
} catch (error: any) {
|
|
80
|
-
throw customError(5000, error.message);
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export const newURLEncrypt = async (data: NewURLEncryptData): Promise<any> => {
|
|
85
|
-
const { url } = data;
|
|
86
|
-
if (url === undefined || (!url.startsWith("https://") && !url.startsWith("http://"))) throw customError(1500, "You must provide a valid url.");
|
|
87
|
-
try {
|
|
88
|
-
const response = await axios.get(`${BASE_URL}/v1/public/url-encrypt`, { params: data });
|
|
89
|
-
return response.data;
|
|
90
|
-
} catch (error: any) {
|
|
91
|
-
throw customError(5000, error.message);
|
|
92
|
-
}
|
|
93
|
-
};
|
package/src/config/index.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const config = {
|
|
2
|
-
lib: {
|
|
3
|
-
name: "Dymo API",
|
|
4
|
-
dir: "dymo-api"
|
|
5
|
-
},
|
|
6
|
-
env: {
|
|
7
|
-
baseUrl: "https://api.tpeoficial.com"
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export default config;
|
|
12
|
-
|
|
13
|
-
let BASE_URL: string = config.env.baseUrl;
|
|
14
|
-
|
|
15
|
-
export const setBaseUrl = (isLocal: boolean): void => {
|
|
16
|
-
BASE_URL = isLocal ? "http://localhost:3050" : config.env.baseUrl;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export { BASE_URL };
|
package/src/dymo-api.ts
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
|
-
import * as PublicAPI from "./branches/public";
|
|
3
|
-
import * as PrivateAPI from "./branches/private";
|
|
4
|
-
import config, { BASE_URL, setBaseUrl } from "./config";
|
|
5
|
-
|
|
6
|
-
const customError = (code: number, message: string): Error => {
|
|
7
|
-
return Object.assign(new Error(), { code, message: `[${config.lib.name}] ${message}` });
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
interface TokensResponse {
|
|
11
|
-
root: boolean;
|
|
12
|
-
api: boolean;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
interface Tokens {
|
|
16
|
-
root?: string;
|
|
17
|
-
api?: string;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
interface ServerEmailConfig {
|
|
21
|
-
host: string;
|
|
22
|
-
port: number;
|
|
23
|
-
secure: boolean;
|
|
24
|
-
auth: {
|
|
25
|
-
user: string;
|
|
26
|
-
pass: string;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
class DymoAPI {
|
|
31
|
-
private rootApiKey: string | null;
|
|
32
|
-
private apiKey: string | null;
|
|
33
|
-
private tokensResponse: TokensResponse | null;
|
|
34
|
-
private lastFetchTime: Date | null;
|
|
35
|
-
private serverEmailConfig?: ServerEmailConfig;
|
|
36
|
-
private local: boolean;
|
|
37
|
-
|
|
38
|
-
constructor({ rootApiKey = null, apiKey = null, local = false, serverEmailConfig = undefined }: { rootApiKey?: string | null; apiKey?: string | null; local?: boolean; serverEmailConfig?: ServerEmailConfig; }) {
|
|
39
|
-
this.rootApiKey = rootApiKey;
|
|
40
|
-
this.apiKey = apiKey;
|
|
41
|
-
this.tokensResponse = null;
|
|
42
|
-
this.lastFetchTime = null;
|
|
43
|
-
this.serverEmailConfig = serverEmailConfig;
|
|
44
|
-
this.local = rootApiKey ? local : false; // Only allow setting local if rootApiKey is defined.
|
|
45
|
-
setBaseUrl(this.local);
|
|
46
|
-
this.initializeTokens(); // Calls the function to obtain tokens when creating the object.
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
private getBaseUrl(): string {
|
|
50
|
-
return this.local ? "http://localhost:3050" : "https://api.tpeoficial.com";
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
private async getTokens(): Promise<TokensResponse | undefined> {
|
|
54
|
-
const currentTime = new Date();
|
|
55
|
-
if (this.tokensResponse && this.lastFetchTime && (currentTime.getTime() - this.lastFetchTime.getTime()) < 5 * 60 * 1000) {
|
|
56
|
-
console.log(`[${config.lib.name}] Using cached tokens response.`);
|
|
57
|
-
return this.tokensResponse;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const tokens: Tokens = {};
|
|
61
|
-
if (this.rootApiKey) tokens.root = `Bearer ${this.rootApiKey}`;
|
|
62
|
-
if (this.apiKey) tokens.api = `Bearer ${this.apiKey}`;
|
|
63
|
-
|
|
64
|
-
try {
|
|
65
|
-
if (Object.keys(tokens).length === 0) return;
|
|
66
|
-
const response = await axios.post<{ data: TokensResponse }>(`${BASE_URL}/v1/dvr/tokens`, { tokens });
|
|
67
|
-
if (tokens.root && response.data.data.root === false) throw customError(3000, "Invalid root token.");
|
|
68
|
-
if (tokens.api && response.data.data.api === false) throw customError(3000, "Invalid API token.");
|
|
69
|
-
this.tokensResponse = response.data.data;
|
|
70
|
-
this.lastFetchTime = currentTime;
|
|
71
|
-
console.log(`[${config.lib.name}] Tokens initialized successfully.`);
|
|
72
|
-
return this.tokensResponse;
|
|
73
|
-
} catch (error: any) {
|
|
74
|
-
throw customError(5000, error.message);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
private async initializeTokens() {
|
|
79
|
-
try {
|
|
80
|
-
await this.getTokens();
|
|
81
|
-
} catch (error: any) {
|
|
82
|
-
throw customError(5000, `Error initializing tokens: ${error.message}`);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// FUNCTIONS / Private.
|
|
87
|
-
async isValidData(data: any): Promise<any> {
|
|
88
|
-
return await PrivateAPI.isValidData(this.apiKey, data);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
async sendEmail(data: any): Promise<any> {
|
|
92
|
-
if (this.serverEmailConfig) throw customError(5000, `You must configure the email client settings.`);
|
|
93
|
-
return await PrivateAPI.sendEmail(this.apiKey, { serverEmailConfig: this.serverEmailConfig, ...data });
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
async getRandom(data: any): Promise<any> {
|
|
97
|
-
return await PrivateAPI.getRandom(this.apiKey, data);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// FUNCTIONS / Public.
|
|
101
|
-
async getPrayerTimes(data: any): Promise<any> {
|
|
102
|
-
return await PublicAPI.getPrayerTimes(data);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
async satinizer(data: any): Promise<any> {
|
|
106
|
-
return await PublicAPI.satinizer(data);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
async isValidPwd(data: any): Promise<any> {
|
|
110
|
-
return await PublicAPI.isValidPwd(data);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
async newURLEncrypt(data: any): Promise<any> {
|
|
114
|
-
return await PublicAPI.newURLEncrypt(data);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export { DymoAPI };
|
package/test/preview.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { DymoAPI } from "../index.js";
|
|
3
|
-
|
|
4
|
-
// Creating the client for use.
|
|
5
|
-
const dymo = new DymoAPI({
|
|
6
|
-
/*rootApiKey: "ROOT_TOKEN_HERE",
|
|
7
|
-
apiKey: "PRIVATE_TOKEN_HERE",*/
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
/*
|
|
11
|
-
console.log(await dymo.isValidData({ email: "test@test.com", tel: "+34617509462", domain: "test.com", creditCard: "5110929780543845", ip: "52.94.236.248" })); // Private authorization required.
|
|
12
|
-
console.log(await dymo.getPrayerTimes({ lat: "37.3755847689721", lon: "-4.457957889422379" })); // No authorization required.
|
|
13
|
-
console.log(await dymo.inputSatinizer({ input: "21/08/2024" })); // No authorization required.
|
|
14
|
-
console.log(await dymo.isValidPwd({ email: "username@test.com", password: "ThisIsATest" })); // No authorization required.
|
|
15
|
-
console.log(await dymo.newURLEncrypt({ url: "https://www.tpeoficial.com/" })); // No authorization required.
|
|
16
|
-
*/
|
package/tsconfig.json
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"module": "CommonJS",
|
|
5
|
-
"strict": true,
|
|
6
|
-
"esModuleInterop": true,
|
|
7
|
-
"skipLibCheck": true,
|
|
8
|
-
"forceConsistentCasingInFileNames": true,
|
|
9
|
-
"outDir": "./dist",
|
|
10
|
-
"rootDir": "./src"
|
|
11
|
-
},
|
|
12
|
-
"include": [
|
|
13
|
-
"src/**/*"
|
|
14
|
-
]
|
|
15
|
-
}
|