dymo-api 1.0.41 → 1.0.43
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/dymo-api.js +2 -0
- package/dist/esm/branches/private.js +43 -11
- package/dist/esm/branches/public.js +44 -11
- package/dist/esm/config/index.js +8 -4
- package/dist/esm/dymo-api.js +42 -12
- package/dist/esm/lib/interfaces.js +2 -1
- package/dist/esm/services/autoupdate.js +11 -5
- package/package.json +5 -4
package/dist/cjs/dymo-api.js
CHANGED
|
@@ -1,10 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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");
|
|
4
33
|
const customError = (code, message) => {
|
|
5
|
-
return Object.assign(new Error(), { code, message: `[${
|
|
34
|
+
return Object.assign(new Error(), { code, message: `[${config_1.default.lib.name}] ${message}` });
|
|
6
35
|
};
|
|
7
|
-
|
|
36
|
+
const isValidData = async (token, data) => {
|
|
8
37
|
if (token === null)
|
|
9
38
|
throw customError(3000, "Invalid private token.");
|
|
10
39
|
let i = false;
|
|
@@ -17,14 +46,15 @@ export const isValidData = async (token, data) => {
|
|
|
17
46
|
if (!i)
|
|
18
47
|
throw customError(1500, "You must provide at least one parameter.");
|
|
19
48
|
try {
|
|
20
|
-
const response = await
|
|
49
|
+
const response = await axios_1.default.post(`${config_1.BASE_URL}/v1/private/secure/verify`, data, { headers: { "Authorization": token } });
|
|
21
50
|
return response.data;
|
|
22
51
|
}
|
|
23
52
|
catch (error) {
|
|
24
53
|
throw customError(5000, error.response?.data?.message || error.message);
|
|
25
54
|
}
|
|
26
55
|
};
|
|
27
|
-
|
|
56
|
+
exports.isValidData = isValidData;
|
|
57
|
+
const sendEmail = async (token, data) => {
|
|
28
58
|
if (token === null)
|
|
29
59
|
throw customError(3000, "Invalid private token.");
|
|
30
60
|
if (!data.from)
|
|
@@ -40,7 +70,7 @@ export const sendEmail = async (token, data) => {
|
|
|
40
70
|
try {
|
|
41
71
|
if (data.react) {
|
|
42
72
|
//@ts-ignore
|
|
43
|
-
data.html = await render(data.react);
|
|
73
|
+
data.html = await (0, render_1.render)(data.react);
|
|
44
74
|
delete data.react;
|
|
45
75
|
}
|
|
46
76
|
}
|
|
@@ -48,14 +78,15 @@ export const sendEmail = async (token, data) => {
|
|
|
48
78
|
throw customError(1500, `An error occurred while rendering your React component. Details: ${error}`);
|
|
49
79
|
}
|
|
50
80
|
try {
|
|
51
|
-
const response = await
|
|
81
|
+
const response = await axios_1.default.post(`${config_1.BASE_URL}/v1/private/sender/sendEmail`, data, { headers: { "Authorization": token } });
|
|
52
82
|
return response.data;
|
|
53
83
|
}
|
|
54
84
|
catch (error) {
|
|
55
85
|
throw customError(5000, error.response?.data?.message || error.message);
|
|
56
86
|
}
|
|
57
87
|
};
|
|
58
|
-
|
|
88
|
+
exports.sendEmail = sendEmail;
|
|
89
|
+
const getRandom = async (token, data) => {
|
|
59
90
|
if (token === null)
|
|
60
91
|
throw customError(3000, "Invalid private token.");
|
|
61
92
|
if (!data.min || !data.max)
|
|
@@ -67,10 +98,11 @@ export const getRandom = async (token, data) => {
|
|
|
67
98
|
if (data.max < -1000000000 || data.max > 1000000000)
|
|
68
99
|
throw customError(1500, "'max' must be an integer in the interval [-1000000000}, 1000000000].");
|
|
69
100
|
try {
|
|
70
|
-
const response = await
|
|
101
|
+
const response = await axios_1.default.post(`${config_1.BASE_URL}/v1/private/srng`, data, { headers: { "Authorization": token } });
|
|
71
102
|
return response.data;
|
|
72
103
|
}
|
|
73
104
|
catch (error) {
|
|
74
105
|
throw customError(5000, error.response?.data?.message || error.message);
|
|
75
106
|
}
|
|
76
107
|
};
|
|
108
|
+
exports.getRandom = getRandom;
|
|
@@ -1,37 +1,68 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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"));
|
|
3
32
|
const customError = (code, message) => {
|
|
4
|
-
return Object.assign(new Error(), { code, message: `[${
|
|
33
|
+
return Object.assign(new Error(), { code, message: `[${config_1.default.lib.name}] ${message}` });
|
|
5
34
|
};
|
|
6
35
|
;
|
|
7
36
|
;
|
|
8
37
|
;
|
|
9
38
|
;
|
|
10
|
-
|
|
39
|
+
const getPrayerTimes = async (data) => {
|
|
11
40
|
const { lat, lon } = data;
|
|
12
41
|
if (lat === undefined || lon === undefined)
|
|
13
42
|
throw customError(1000, "You must provide a latitude and longitude.");
|
|
14
43
|
try {
|
|
15
|
-
const response = await
|
|
44
|
+
const response = await axios_1.default.get(`${config_1.BASE_URL}/v1/public/islam/prayertimes`, { params: data });
|
|
16
45
|
return response.data;
|
|
17
46
|
}
|
|
18
47
|
catch (error) {
|
|
19
48
|
throw customError(5000, error.response?.data?.message || error.message);
|
|
20
49
|
}
|
|
21
50
|
};
|
|
22
|
-
|
|
51
|
+
exports.getPrayerTimes = getPrayerTimes;
|
|
52
|
+
const satinizer = async (data) => {
|
|
23
53
|
const { input } = data;
|
|
24
54
|
if (input === undefined)
|
|
25
55
|
throw customError(1000, "You must specify at least the input.");
|
|
26
56
|
try {
|
|
27
|
-
const response = await
|
|
57
|
+
const response = await axios_1.default.get(`${config_1.BASE_URL}/v1/public/inputSatinizer`, { params: { input: encodeURIComponent(input) } });
|
|
28
58
|
return response.data;
|
|
29
59
|
}
|
|
30
60
|
catch (error) {
|
|
31
61
|
throw customError(5000, error.response?.data?.message || error.message);
|
|
32
62
|
}
|
|
33
63
|
};
|
|
34
|
-
|
|
64
|
+
exports.satinizer = satinizer;
|
|
65
|
+
const isValidPwd = async (data) => {
|
|
35
66
|
let { email, password, bannedWords, min, max } = data;
|
|
36
67
|
if (password === undefined)
|
|
37
68
|
throw customError(1000, "You must specify at least the password.");
|
|
@@ -59,22 +90,24 @@ export const isValidPwd = async (data) => {
|
|
|
59
90
|
if (max !== undefined)
|
|
60
91
|
params.max = max;
|
|
61
92
|
try {
|
|
62
|
-
const response = await
|
|
93
|
+
const response = await axios_1.default.get(`${config_1.BASE_URL}/v1/public/validPwd`, { params });
|
|
63
94
|
return response.data;
|
|
64
95
|
}
|
|
65
96
|
catch (error) {
|
|
66
97
|
throw customError(5000, error.response?.data?.message || error.message);
|
|
67
98
|
}
|
|
68
99
|
};
|
|
69
|
-
|
|
100
|
+
exports.isValidPwd = isValidPwd;
|
|
101
|
+
const newURLEncrypt = async (data) => {
|
|
70
102
|
const { url } = data;
|
|
71
103
|
if (url === undefined || (!url.startsWith("https://") && !url.startsWith("http://")))
|
|
72
104
|
throw customError(1500, "You must provide a valid url.");
|
|
73
105
|
try {
|
|
74
|
-
const response = await
|
|
106
|
+
const response = await axios_1.default.get(`${config_1.BASE_URL}/v1/public/url-encrypt`, { params: data });
|
|
75
107
|
return response.data;
|
|
76
108
|
}
|
|
77
109
|
catch (error) {
|
|
78
110
|
throw customError(5000, error.response?.data?.message || error.message);
|
|
79
111
|
}
|
|
80
112
|
};
|
|
113
|
+
exports.newURLEncrypt = newURLEncrypt;
|
package/dist/esm/config/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BASE_URL = exports.setBaseUrl = void 0;
|
|
1
4
|
const config = {
|
|
2
5
|
lib: {
|
|
3
6
|
name: "Dymo API",
|
|
@@ -7,9 +10,10 @@ const config = {
|
|
|
7
10
|
baseUrl: "https://api.tpeoficial.com"
|
|
8
11
|
}
|
|
9
12
|
};
|
|
10
|
-
|
|
13
|
+
exports.default = config;
|
|
11
14
|
let BASE_URL = config.env.baseUrl;
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
exports.BASE_URL = BASE_URL;
|
|
16
|
+
const setBaseUrl = (isLocal) => {
|
|
17
|
+
exports.BASE_URL = BASE_URL = isLocal ? "http://localhost:3050" : config.env.baseUrl;
|
|
14
18
|
};
|
|
15
|
-
|
|
19
|
+
exports.setBaseUrl = setBaseUrl;
|
package/dist/esm/dymo-api.js
CHANGED
|
@@ -1,10 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
+
const axios_1 = __importDefault(require("axios"));
|
|
30
|
+
const PublicAPI = __importStar(require("./branches/public"));
|
|
31
|
+
const PrivateAPI = __importStar(require("./branches/private"));
|
|
32
|
+
const config_1 = __importStar(require("./config"));
|
|
33
|
+
const autoupdate_1 = require("./services/autoupdate");
|
|
6
34
|
const customError = (code, message) => {
|
|
7
|
-
return Object.assign(new Error(), { code, message: `[${
|
|
35
|
+
return Object.assign(new Error(), { code, message: `[${config_1.default.lib.name}] ${message}` });
|
|
8
36
|
};
|
|
9
37
|
;
|
|
10
38
|
;
|
|
@@ -35,7 +63,7 @@ class DymoAPI {
|
|
|
35
63
|
this.lastFetchTime = null;
|
|
36
64
|
this.serverEmailConfig = serverEmailConfig;
|
|
37
65
|
this.local = rootApiKey ? local : false; // Only allow setting local if rootApiKey is defined.
|
|
38
|
-
setBaseUrl(this.local);
|
|
66
|
+
(0, config_1.setBaseUrl)(this.local);
|
|
39
67
|
this.autoupdate();
|
|
40
68
|
this.initializeTokens(); // Calls the function to obtain tokens when creating the object.
|
|
41
69
|
}
|
|
@@ -57,7 +85,7 @@ class DymoAPI {
|
|
|
57
85
|
async getTokens() {
|
|
58
86
|
const currentTime = new Date();
|
|
59
87
|
if (this.tokensResponse && this.lastFetchTime && (currentTime.getTime() - this.lastFetchTime.getTime()) < 5 * 60 * 1000) {
|
|
60
|
-
console.log(`[${
|
|
88
|
+
console.log(`[${config_1.default.lib.name}] Using cached tokens response.`);
|
|
61
89
|
return this.tokensResponse;
|
|
62
90
|
}
|
|
63
91
|
;
|
|
@@ -69,14 +97,14 @@ class DymoAPI {
|
|
|
69
97
|
try {
|
|
70
98
|
if (Object.keys(tokens).length === 0)
|
|
71
99
|
return;
|
|
72
|
-
const response = await
|
|
100
|
+
const response = await axios_1.default.post(`${config_1.BASE_URL}/v1/dvr/tokens`, { tokens });
|
|
73
101
|
if (tokens.root && response.data.root === false)
|
|
74
102
|
throw customError(3000, "Invalid root token.");
|
|
75
103
|
if (tokens.api && response.data.api === false)
|
|
76
104
|
throw customError(3000, "Invalid API token.");
|
|
77
105
|
this.tokensResponse = response.data;
|
|
78
106
|
this.lastFetchTime = currentTime;
|
|
79
|
-
console.log(`[${
|
|
107
|
+
console.log(`[${config_1.default.lib.name}] Tokens initialized successfully.`);
|
|
80
108
|
return this.tokensResponse;
|
|
81
109
|
}
|
|
82
110
|
catch (error) {
|
|
@@ -111,7 +139,7 @@ class DymoAPI {
|
|
|
111
139
|
*/
|
|
112
140
|
async autoupdate() {
|
|
113
141
|
try {
|
|
114
|
-
await checkForUpdates();
|
|
142
|
+
await (0, autoupdate_1.checkForUpdates)();
|
|
115
143
|
}
|
|
116
144
|
catch (error) {
|
|
117
145
|
throw customError(5000, `Error checking the latest version in npmjs: ${error.message}`);
|
|
@@ -232,4 +260,6 @@ class DymoAPI {
|
|
|
232
260
|
return await PublicAPI.newURLEncrypt(data);
|
|
233
261
|
}
|
|
234
262
|
}
|
|
235
|
-
|
|
263
|
+
exports.default = DymoAPI;
|
|
264
|
+
//@ts-ignore
|
|
265
|
+
module.exports = DymoAPI;
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.checkForUpdates = checkForUpdates;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
2
8
|
//@ts-ignore
|
|
3
|
-
|
|
4
|
-
const localVersion = execSync("npm list dymo-api --depth=0").toString().match(new RegExp("dymo-api@(\\d+\\.\\d+\\.\\d+)"))?.[1] || "0.0.0";
|
|
5
|
-
|
|
9
|
+
const child_process_1 = require("child_process");
|
|
10
|
+
const localVersion = (0, child_process_1.execSync)("npm list dymo-api --depth=0").toString().match(new RegExp("dymo-api@(\\d+\\.\\d+\\.\\d+)"))?.[1] || "0.0.0";
|
|
11
|
+
async function checkForUpdates() {
|
|
6
12
|
try {
|
|
7
|
-
const response = await
|
|
13
|
+
const response = await axios_1.default.get("https://registry.npmjs.org/dymo-api/latest");
|
|
8
14
|
const latestVersion = response.data.version;
|
|
9
15
|
if (localVersion !== latestVersion)
|
|
10
16
|
console.log(`[Dymo API] A new version of dymo-api is available: ${latestVersion}. You are using ${localVersion}. Consider updating.`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dymo-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.43",
|
|
4
4
|
"description": "Flow system for Dymo API.",
|
|
5
5
|
"main": "dist/cjs/dymo-api.js",
|
|
6
6
|
"module": "dist/esm/dymo-api.js",
|
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@react-email/render": "1.0.1",
|
|
42
42
|
"@types/react": "^18.3.5",
|
|
43
|
-
"axios": "^1.6.8"
|
|
43
|
+
"axios": "^1.6.8",
|
|
44
|
+
"rimraf": "^6.0.1"
|
|
44
45
|
},
|
|
45
46
|
"contributors": [
|
|
46
47
|
"TPEOficial (https://github.com/TPEOficial)",
|
|
@@ -48,8 +49,8 @@
|
|
|
48
49
|
],
|
|
49
50
|
"devDependencies": {
|
|
50
51
|
"@types/axios": "^0.9.36",
|
|
51
|
-
"@types/node": "^22.0
|
|
52
|
+
"@types/node": "^22.9.0",
|
|
52
53
|
"ts-node": "^10.9.2",
|
|
53
54
|
"typescript": "^5.5.4"
|
|
54
55
|
}
|
|
55
|
-
}
|
|
56
|
+
}
|