serverpreconfigured 2.2.13 → 2.2.15
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/package.json +6 -4
- package/spc_envfile.json +4 -1
- package/src/database/database.ts +2 -2
- package/src/logs/logs.ts +127 -0
- package/dist/auth/auth.d.ts +0 -3
- package/dist/auth/auth.js +0 -22
- package/dist/auth/config.d.ts +0 -1
- package/dist/auth/config.js +0 -4
- package/dist/database/database.d.ts +0 -2
- package/dist/database/database.js +0 -11
- package/dist/database/models/User.d.ts +0 -9
- package/dist/database/models/User.js +0 -19
- package/dist/database/models/WSAuth.d.ts +0 -6
- package/dist/database/models/WSAuth.js +0 -19
- package/dist/expressServer.d.ts +0 -20
- package/dist/expressServer.js +0 -52
- package/dist/middlewares/auth.d.ts +0 -6
- package/dist/middlewares/auth.js +0 -35
- package/dist/middlewares/post.d.ts +0 -1
- package/dist/middlewares/post.js +0 -6
- package/dist/middlewares/wsauth.d.ts +0 -1
- package/dist/middlewares/wsauth.js +0 -56
- package/dist/modules/initcors.d.ts +0 -1
- package/dist/modules/initcors.js +0 -13
- package/dist/modules/postreader.d.ts +0 -1
- package/dist/modules/postreader.js +0 -12
- package/dist/modules/sessions.d.ts +0 -1
- package/dist/modules/sessions.js +0 -20
- package/dist/routes/auth.d.ts +0 -2
- package/dist/routes/auth.js +0 -56
- package/dist/routes/userauth.d.ts +0 -2
- package/dist/routes/userauth.js +0 -68
- package/dist/routes/userresgister.d.ts +0 -2
- package/dist/routes/userresgister.js +0 -42
- package/dist/routes/users.d.ts +0 -2
- package/dist/routes/users.js +0 -90
- package/dist/routes/wsauth.d.ts +0 -1
- package/dist/routes/wsauth.js +0 -33
- package/dist/server.d.ts +0 -15
- package/dist/server.js +0 -42
- package/dist/sessions/secureget.d.ts +0 -1
- package/dist/sessions/secureget.js +0 -7
- package/dist/sessions/secureset.d.ts +0 -2
- package/dist/sessions/secureset.js +0 -11
- package/dist/settings/database/database.d.ts +0 -11
- package/dist/settings/database/database.js +0 -15
- package/dist/settings/env.d.ts +0 -15
- package/dist/settings/env.js +0 -30
- package/dist/users/password.d.ts +0 -3
- package/dist/users/password.js +0 -41
- package/dist/users/types.d.ts +0 -6
- package/dist/users/types.js +0 -3
- package/dist/users/users.d.ts +0 -12
- package/dist/users/users.js +0 -143
- package/dist/utils/debug/debug.d.ts +0 -1
- package/dist/utils/debug/debug.js +0 -15
- package/dist/utils/response.d.ts +0 -8
- package/dist/utils/response.js +0 -27
- package/dist/utils/string/random.d.ts +0 -1
- package/dist/utils/string/random.js +0 -14
- package/dist/utils/validators/email.d.ts +0 -1
- package/dist/utils/validators/email.js +0 -18
- package/dist/wsauth/types.d.ts +0 -0
- package/dist/wsauth/types.js +0 -1
- package/dist/wsauth/wsauth.d.ts +0 -5
- package/dist/wsauth/wsauth.js +0 -111
package/dist/utils/response.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { LogSeverity } from "../logs/logs";
|
|
2
|
-
export declare function JSONResponse(data: any, error?: any): string;
|
|
3
|
-
export interface SendIErrorOptions {
|
|
4
|
-
severity?: LogSeverity;
|
|
5
|
-
penTestSuspcion?: boolean;
|
|
6
|
-
}
|
|
7
|
-
export declare function sendIError(req: any, res: any, error?: any, options?: SendIErrorOptions): any;
|
|
8
|
-
export declare function WSResponse(isOK: boolean, message?: string, errorMessage?: string, data?: any): string;
|
package/dist/utils/response.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WSResponse = exports.sendIError = exports.JSONResponse = void 0;
|
|
4
|
-
const logs_1 = require("../logs/logs");
|
|
5
|
-
function JSONResponse(data, error) {
|
|
6
|
-
return JSON.stringify({
|
|
7
|
-
data,
|
|
8
|
-
hasError: Boolean(error),
|
|
9
|
-
error,
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
exports.JSONResponse = JSONResponse;
|
|
13
|
-
;
|
|
14
|
-
function sendIError(req, res, error, options) {
|
|
15
|
-
(0, logs_1.saveInternalErrorLog)(req, error, options);
|
|
16
|
-
return res.status(500).send(JSONResponse("", "I-E"));
|
|
17
|
-
}
|
|
18
|
-
exports.sendIError = sendIError;
|
|
19
|
-
function WSResponse(isOK, message = '', errorMessage = "", data = {}) {
|
|
20
|
-
return JSON.stringify({
|
|
21
|
-
is_ok: isOK,
|
|
22
|
-
message: message,
|
|
23
|
-
error_message: errorMessage,
|
|
24
|
-
data: data
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
exports.WSResponse = WSResponse;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function randomString(length: number): string;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.randomString = void 0;
|
|
4
|
-
function randomString(length) {
|
|
5
|
-
var result = '';
|
|
6
|
-
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
7
|
-
var charactersLength = characters.length;
|
|
8
|
-
for (var i = 0; i < length; i++) {
|
|
9
|
-
result += characters.charAt(Math.floor(Math.random() *
|
|
10
|
-
charactersLength));
|
|
11
|
-
}
|
|
12
|
-
return result;
|
|
13
|
-
}
|
|
14
|
-
exports.randomString = randomString;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function checkEmail(email: string): boolean;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkEmail = void 0;
|
|
4
|
-
function checkEmail(email) {
|
|
5
|
-
const atIndex = email.indexOf("@");
|
|
6
|
-
if (atIndex < 1)
|
|
7
|
-
return false;
|
|
8
|
-
const after = email.slice(atIndex + 1);
|
|
9
|
-
if (after.length < 3)
|
|
10
|
-
return false;
|
|
11
|
-
if (after.indexOf('@') >= 0)
|
|
12
|
-
return false;
|
|
13
|
-
const periodIndex = after.indexOf('.');
|
|
14
|
-
if (periodIndex < 1 || periodIndex >= after.length - 1)
|
|
15
|
-
return false;
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
exports.checkEmail = checkEmail;
|
package/dist/wsauth/types.d.ts
DELETED
|
File without changes
|
package/dist/wsauth/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
package/dist/wsauth/wsauth.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare function getWSAuthDataByUserId(userId: number): Promise<any>;
|
|
2
|
-
export declare function setWSAuthDataNewToken(userId: number, expiration_hours?: number): Promise<any>;
|
|
3
|
-
export declare function checkWSAuthToken(userId: number, token: string): Promise<boolean>;
|
|
4
|
-
export declare function authenticateWS(userId: number, token: string, connection_token: string): Promise<boolean>;
|
|
5
|
-
export declare function checkConnectionAuth(userId: number, connection_token: string): Promise<boolean>;
|
package/dist/wsauth/wsauth.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.checkConnectionAuth = exports.authenticateWS = exports.checkWSAuthToken = exports.setWSAuthDataNewToken = exports.getWSAuthDataByUserId = void 0;
|
|
13
|
-
const server_1 = require("../server");
|
|
14
|
-
const random_1 = require("./../utils/string/random");
|
|
15
|
-
function getWSAuthDataByUserId(userId) {
|
|
16
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
-
try {
|
|
18
|
-
let u = yield server_1.WebSocketAuth.findOne({ where: { user_id: userId.toString() } });
|
|
19
|
-
return u;
|
|
20
|
-
}
|
|
21
|
-
catch (e) {
|
|
22
|
-
throw e;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
exports.getWSAuthDataByUserId = getWSAuthDataByUserId;
|
|
27
|
-
function setWSAuthDataNewToken(userId, expiration_hours = 72) {
|
|
28
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
try {
|
|
30
|
-
let ws = yield getWSAuthDataByUserId(userId);
|
|
31
|
-
let token = (0, random_1.randomString)(50);
|
|
32
|
-
let expiration = new Date();
|
|
33
|
-
expiration.setTime(expiration.getTime() + expiration_hours * 60 * 60 * 1000);
|
|
34
|
-
if (!Boolean(ws)) {
|
|
35
|
-
return yield server_1.WebSocketAuth.create({ user_id: userId.toString(),
|
|
36
|
-
token: token,
|
|
37
|
-
expiration: expiration,
|
|
38
|
-
is_active: true,
|
|
39
|
-
auth_connection_token: "",
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
ws.token = token;
|
|
44
|
-
ws.expiration = expiration;
|
|
45
|
-
ws.is_active = true;
|
|
46
|
-
ws.auth_connection_token = "";
|
|
47
|
-
return yield ws.save();
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
catch (e) {
|
|
51
|
-
throw e;
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
exports.setWSAuthDataNewToken = setWSAuthDataNewToken;
|
|
56
|
-
function checkWSAuthToken(userId, token) {
|
|
57
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
-
try {
|
|
59
|
-
let ws = yield getWSAuthDataByUserId(userId);
|
|
60
|
-
if (!Boolean(ws))
|
|
61
|
-
return false;
|
|
62
|
-
if (!ws.dataValues.is_active)
|
|
63
|
-
return false;
|
|
64
|
-
if (ws.dataValues.token != token)
|
|
65
|
-
return false;
|
|
66
|
-
if (Date.now() > ws.dataValues.expiration.getTime())
|
|
67
|
-
return false;
|
|
68
|
-
return true;
|
|
69
|
-
}
|
|
70
|
-
catch (e) {
|
|
71
|
-
throw e;
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
exports.checkWSAuthToken = checkWSAuthToken;
|
|
76
|
-
function authenticateWS(userId, token, connection_token) {
|
|
77
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
-
try {
|
|
79
|
-
if (!(yield checkWSAuthToken(userId, token)))
|
|
80
|
-
return false;
|
|
81
|
-
let ws = yield getWSAuthDataByUserId(userId);
|
|
82
|
-
ws.auth_connection_token = connection_token;
|
|
83
|
-
yield ws.save();
|
|
84
|
-
return true;
|
|
85
|
-
}
|
|
86
|
-
catch (e) {
|
|
87
|
-
throw e;
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
exports.authenticateWS = authenticateWS;
|
|
92
|
-
function checkConnectionAuth(userId, connection_token) {
|
|
93
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
-
try {
|
|
95
|
-
let ws = yield getWSAuthDataByUserId(userId);
|
|
96
|
-
if (!Boolean(ws))
|
|
97
|
-
return false;
|
|
98
|
-
if (!ws.dataValues.is_active)
|
|
99
|
-
return false;
|
|
100
|
-
if (Date.now() > ws.dataValues.expiration.getTime())
|
|
101
|
-
return false;
|
|
102
|
-
if (ws.dataValues.auth_connection_token !== connection_token)
|
|
103
|
-
return false;
|
|
104
|
-
return true;
|
|
105
|
-
}
|
|
106
|
-
catch (e) {
|
|
107
|
-
throw e;
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
exports.checkConnectionAuth = checkConnectionAuth;
|