mdkcontroller 1.0.2 → 1.0.4
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/demoApp.js +8 -0
- package/dk_modules/EncryptC/DKEncryptCMD.deps.json +23 -0
- package/dk_modules/EncryptC/DKEncryptCMD.dll +0 -0
- package/dk_modules/EncryptC/DKEncryptCMD.exe +0 -0
- package/dk_modules/EncryptC/DKEncryptCMD.runtimeconfig.json +9 -0
- package/dk_modules/authorization.js +28 -2
- package/package.json +9 -4
- package/app.js +0 -3
package/demoApp.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import svInstance from "./main.js";
|
|
2
|
+
|
|
3
|
+
const _sv = await svInstance("khanhnbd");
|
|
4
|
+
const enc = await _sv.authen.encrypt("khanhnbd");
|
|
5
|
+
const dec = await _sv.authen.decrypt(enc);
|
|
6
|
+
console.log("khanhnbd => " + enc);
|
|
7
|
+
console.log("khanhnbd will => " + dec);
|
|
8
|
+
_sv.startListen(8905);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"runtimeTarget": {
|
|
3
|
+
"name": ".NETCoreApp,Version=v7.0",
|
|
4
|
+
"signature": ""
|
|
5
|
+
},
|
|
6
|
+
"compilationOptions": {},
|
|
7
|
+
"targets": {
|
|
8
|
+
".NETCoreApp,Version=v7.0": {
|
|
9
|
+
"DKEncryptCMD/1.0.0": {
|
|
10
|
+
"runtime": {
|
|
11
|
+
"DKEncryptCMD.dll": {}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"libraries": {
|
|
17
|
+
"DKEncryptCMD/1.0.0": {
|
|
18
|
+
"type": "project",
|
|
19
|
+
"serviceable": false,
|
|
20
|
+
"sha512": ""
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
Binary file
|
|
Binary file
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import child_process from "child_process";
|
|
2
|
+
|
|
1
3
|
export default function (db) {
|
|
2
4
|
const tbLoginToken = db.data.loginTokens;
|
|
3
5
|
const tbUser = db.data.users;
|
|
@@ -31,17 +33,41 @@ export default function (db) {
|
|
|
31
33
|
const resultValidate = validateBase(req, res);
|
|
32
34
|
switch (resultValidate) {
|
|
33
35
|
case 0:
|
|
34
|
-
return res.status(401).json({
|
|
36
|
+
return res.status(401).json({message: 'Token không được cung cấp'});
|
|
35
37
|
case 1:
|
|
36
38
|
|
|
37
39
|
next();
|
|
38
40
|
break;
|
|
39
41
|
case -1:
|
|
40
|
-
return res.status(401).json({
|
|
42
|
+
return res.status(401).json({message: 'Token không hợp lệ'});
|
|
41
43
|
}
|
|
42
44
|
},
|
|
43
45
|
validateBool: (req, res) => {
|
|
44
46
|
return validateBase(req, res);
|
|
47
|
+
},
|
|
48
|
+
encrypt: async function (data = "", pw = "mdkpaswoEcrHidDefat") {
|
|
49
|
+
const cmd = data + " " + pw;
|
|
50
|
+
return new Promise((resolve, reject) => {
|
|
51
|
+
child_process.exec(`dk_modules\\EncryptC\\DKEncryptCMD e ${cmd}`, (error, stdout, stderr) => {
|
|
52
|
+
if (error) {
|
|
53
|
+
reject(error);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
resolve(stdout.trimEnd());
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
decrypt: function (data = "", pw = "mdkpaswoEcrHidDefat") {
|
|
61
|
+
const cmd = data + " " + pw;
|
|
62
|
+
return new Promise((resolve, reject) => {
|
|
63
|
+
child_process.exec(`dk_modules\\EncryptC\\DKEncryptCMD d ${cmd}`, (error, stdout, stderr) => {
|
|
64
|
+
if (error) {
|
|
65
|
+
reject(error);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
resolve(stdout);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
45
71
|
}
|
|
46
72
|
}
|
|
47
73
|
};
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
|
+
"child_process": "^1.0.2",
|
|
3
4
|
"cookie-parser": "^1.4.6",
|
|
4
5
|
"express": "^4.18.2",
|
|
5
6
|
"fluent-ffmpeg": "^2.1.2",
|
|
@@ -9,14 +10,18 @@
|
|
|
9
10
|
"socket.io": "^4.7.2"
|
|
10
11
|
},
|
|
11
12
|
"name": "mdkcontroller",
|
|
12
|
-
"version": "1.0.
|
|
13
|
+
"version": "1.0.4",
|
|
13
14
|
"keywords": [],
|
|
14
|
-
"author": "",
|
|
15
|
+
"author": "KHANHNBD <khanh272421@gmail.com>",
|
|
15
16
|
"license": "ISC",
|
|
16
|
-
"description": "",
|
|
17
|
+
"description": "Quick setup authentication and express",
|
|
17
18
|
"type": "module",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": "./main.js"
|
|
21
|
+
},
|
|
22
|
+
"types": "./main.js",
|
|
18
23
|
"files": [
|
|
19
|
-
"
|
|
24
|
+
"demoApp.js",
|
|
20
25
|
"main.js",
|
|
21
26
|
"Cores/",
|
|
22
27
|
"dk_modules/"
|
package/app.js
DELETED