@scefira/dfw 0.1.15 → 0.2.0
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/lib/DFWInstance.d.ts +20 -20
- package/lib/DFWInstance.js +55 -55
- package/lib/DFWUtils.d.ts +27 -27
- package/lib/DFWUtils.js +63 -63
- package/lib/DFWUtils.js.map +1 -1
- package/lib/index.d.ts +10 -10
- package/lib/index.js +25 -25
- package/lib/manager/APIManager.d.ts +47 -47
- package/lib/manager/APIManager.d.ts.map +1 -1
- package/lib/manager/APIManager.js +207 -233
- package/lib/manager/APIManager.js.map +1 -1
- package/lib/manager/DFWModule.d.ts +13 -13
- package/lib/manager/DFWModule.js +19 -19
- package/lib/manager/DatabaseManager.d.ts +8 -8
- package/lib/manager/DatabaseManager.js +24 -24
- package/lib/manager/FileManager.d.ts +130 -130
- package/lib/manager/FileManager.js +254 -254
- package/lib/manager/SecurityManager.d.ts +50 -50
- package/lib/manager/SecurityManager.d.ts.map +1 -1
- package/lib/manager/SecurityManager.js +187 -191
- package/lib/manager/SecurityManager.js.map +1 -1
- package/lib/manager/SessionManager.d.ts +40 -40
- package/lib/manager/SessionManager.d.ts.map +1 -1
- package/lib/manager/SessionManager.js +194 -173
- package/lib/manager/SessionManager.js.map +1 -1
- package/lib/manager/UserManager.d.ts +42 -42
- package/lib/manager/UserManager.js +62 -62
- package/lib/test.d.ts +1 -1
- package/lib/test.js +70 -70
- package/lib/test.js.map +1 -1
- package/lib/types/APIListenerConfig.d.ts +52 -52
- package/lib/types/APIListenerConfig.js +2 -2
- package/lib/types/DFWBoot.d.ts +18 -18
- package/lib/types/DFWBoot.d.ts.map +1 -1
- package/lib/types/DFWBoot.js +2 -2
- package/lib/types/DFWConfig.d.ts +54 -54
- package/lib/types/DFWConfig.js +2 -2
- package/lib/types/DFWRequestScheme.d.ts +33 -37
- package/lib/types/DFWRequestScheme.d.ts.map +1 -1
- package/lib/types/DFWRequestScheme.js +2 -2
- package/package.json +4 -3
- package/prisma/schema.prisma +5 -27
|
@@ -1,192 +1,188 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const node_php_password_1 = __importDefault(require("node-php-password"));
|
|
16
|
-
const DFWModule_1 = __importDefault(require("./DFWModule"));
|
|
17
|
-
class SecurityManager extends DFWModule_1.default {
|
|
18
|
-
constructor() {
|
|
19
|
-
super(...arguments);
|
|
20
|
-
this.middleware = (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
req.dfw.SecurityManager = this;
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Genera un array de security bindings a partir de un obejto ListenerSecurityConfig
|
|
26
|
-
* @param securityObject
|
|
27
|
-
*/
|
|
28
|
-
static jsonToBindings(securityObject) {
|
|
29
|
-
let bindings = [];
|
|
30
|
-
if (securityObject.session !== undefined) {
|
|
31
|
-
bindings.push([SecurityManager.RULE_LOGGED_SESSION, securityObject.session ? true : false]);
|
|
32
|
-
}
|
|
33
|
-
if (securityObject.credentials) {
|
|
34
|
-
bindings.push([SecurityManager.RULE_CREDENTIAL, securityObject.credentials]);
|
|
35
|
-
}
|
|
36
|
-
if (securityObject.access) {
|
|
37
|
-
bindings.push([SecurityManager.RULE_ACCESS, securityObject.access]);
|
|
38
|
-
}
|
|
39
|
-
if (securityObject.validation) {
|
|
40
|
-
if (securityObject.validation.body) {
|
|
41
|
-
bindings.push([SecurityManager.RULE_BODY_PARAMS_SETTED, securityObject.validation.body]);
|
|
42
|
-
}
|
|
43
|
-
if (securityObject.validation.query) {
|
|
44
|
-
bindings.push([SecurityManager.RULE_QUERY_PARAMS_SETTED, securityObject.validation.query]);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
if (securityObject.bindings) {
|
|
48
|
-
for (let binding of securityObject.bindings) {
|
|
49
|
-
bindings.push(binding);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return bindings;
|
|
53
|
-
}
|
|
54
|
-
;
|
|
55
|
-
static verifyPassword(encoded, test) {
|
|
56
|
-
return node_php_password_1.default.verify(test, encoded);
|
|
57
|
-
}
|
|
58
|
-
static encryptPassword(password) {
|
|
59
|
-
return node_php_password_1.default.hash(password);
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Check all security bindings from a request
|
|
63
|
-
* @param req
|
|
64
|
-
* @param bindings
|
|
65
|
-
*/
|
|
66
|
-
checkBindingArrayAsync(req, bindings) {
|
|
67
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
for (let i = 0; i < bindings.length; i++) {
|
|
69
|
-
let binding = bindings[i];
|
|
70
|
-
if ((yield this.checkBindingAsync(req, binding[0], binding[1])) === false) {
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return true;
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
*
|
|
79
|
-
* @param req
|
|
80
|
-
* @param type
|
|
81
|
-
* @param value
|
|
82
|
-
*/
|
|
83
|
-
checkBindingAsync(req, type, value) {
|
|
84
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
switch (type) {
|
|
86
|
-
case SecurityManager.RULE_LOGGED_SESSION: {
|
|
87
|
-
return req.dfw.session.isLogged === value; // checks session state
|
|
88
|
-
}
|
|
89
|
-
case SecurityManager.RULE_CREDENTIAL: {
|
|
90
|
-
return yield this.checkUserCredentialsAsync(req.dfw.session.user, value); // checks credentials array
|
|
91
|
-
}
|
|
92
|
-
case SecurityManager.RULE_ACCESS: {
|
|
93
|
-
return yield this.checkUserAccessAsync(req.dfw.session.user, value); // checks access array
|
|
94
|
-
}
|
|
95
|
-
case SecurityManager.RULE_BODY_PARAMS_SETTED: {
|
|
96
|
-
return this.checkBodyParams(req, value); // Check params array on body
|
|
97
|
-
}
|
|
98
|
-
case SecurityManager.RULE_QUERY_PARAMS_SETTED: {
|
|
99
|
-
return this.checkQueryParams(req, value); // Check params array on body
|
|
100
|
-
}
|
|
101
|
-
default: {
|
|
102
|
-
return false; // UNKNOWN RULE always return false
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
createCredentialAsync(name) {
|
|
108
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
-
return this.db.dfw_credential.create({ data: { name, } });
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
checkUserCredentialsAsync(user, credential) {
|
|
113
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
-
if (!user)
|
|
115
|
-
return false;
|
|
116
|
-
return false;
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
checkUserAccessAsync(user, access) {
|
|
120
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
-
if (!user)
|
|
122
|
-
return false;
|
|
123
|
-
return false;
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
addCredentialToAsync(user, credential) {
|
|
127
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
-
const idUser = typeof user === "object" ? user.id : user;
|
|
129
|
-
if (Array.isArray(credential)) {
|
|
130
|
-
let result = yield Promise.all(credential.map((credentialObj) => this.addCredentialToAsync(user, credentialObj)));
|
|
131
|
-
return result.flat(1);
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
let idCredential;
|
|
135
|
-
if (typeof credential == "number") {
|
|
136
|
-
idCredential = credential;
|
|
137
|
-
}
|
|
138
|
-
else if (typeof credential == "string") {
|
|
139
|
-
let credentialObj = (yield this.db.dfw_credential.findFirst({ where: { name: credential } }));
|
|
140
|
-
if (credentialObj) {
|
|
141
|
-
idCredential = credentialObj.id;
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
return [];
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
idCredential = credential.id;
|
|
149
|
-
}
|
|
150
|
-
let newCredential = yield this.db.dfw_credential.update({
|
|
151
|
-
data: {
|
|
152
|
-
users: {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
let keys = req.
|
|
172
|
-
return keys.length >= params.length && params.every(v => keys.includes(v));
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
SecurityManager.
|
|
181
|
-
SecurityManager.
|
|
182
|
-
SecurityManager.
|
|
183
|
-
SecurityManager.
|
|
184
|
-
SecurityManager.
|
|
185
|
-
SecurityManager.
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
[SecurityManager.RULE_CREDENTIAL]: "access denied (you dond have the credentials to this)",
|
|
189
|
-
[SecurityManager.RULE_BODY_PARAMS_SETTED]: "missing post arguments setted",
|
|
190
|
-
[SecurityManager.RULE_QUERY_PARAMS_SETTED]: "missing query arguments setted",
|
|
191
|
-
};
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const node_php_password_1 = __importDefault(require("node-php-password"));
|
|
16
|
+
const DFWModule_1 = __importDefault(require("./DFWModule"));
|
|
17
|
+
class SecurityManager extends DFWModule_1.default {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
this.middleware = (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
req.dfw.SecurityManager = this;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Genera un array de security bindings a partir de un obejto ListenerSecurityConfig
|
|
26
|
+
* @param securityObject
|
|
27
|
+
*/
|
|
28
|
+
static jsonToBindings(securityObject) {
|
|
29
|
+
let bindings = [];
|
|
30
|
+
if (securityObject.session !== undefined) {
|
|
31
|
+
bindings.push([SecurityManager.RULE_LOGGED_SESSION, securityObject.session ? true : false]);
|
|
32
|
+
}
|
|
33
|
+
if (securityObject.credentials) {
|
|
34
|
+
bindings.push([SecurityManager.RULE_CREDENTIAL, securityObject.credentials]);
|
|
35
|
+
}
|
|
36
|
+
if (securityObject.access) {
|
|
37
|
+
bindings.push([SecurityManager.RULE_ACCESS, securityObject.access]);
|
|
38
|
+
}
|
|
39
|
+
if (securityObject.validation) {
|
|
40
|
+
if (securityObject.validation.body) {
|
|
41
|
+
bindings.push([SecurityManager.RULE_BODY_PARAMS_SETTED, securityObject.validation.body]);
|
|
42
|
+
}
|
|
43
|
+
if (securityObject.validation.query) {
|
|
44
|
+
bindings.push([SecurityManager.RULE_QUERY_PARAMS_SETTED, securityObject.validation.query]);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (securityObject.bindings) {
|
|
48
|
+
for (let binding of securityObject.bindings) {
|
|
49
|
+
bindings.push(binding);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return bindings;
|
|
53
|
+
}
|
|
54
|
+
;
|
|
55
|
+
static verifyPassword(encoded, test) {
|
|
56
|
+
return node_php_password_1.default.verify(test, encoded);
|
|
57
|
+
}
|
|
58
|
+
static encryptPassword(password) {
|
|
59
|
+
return node_php_password_1.default.hash(password);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Check all security bindings from a request
|
|
63
|
+
* @param req
|
|
64
|
+
* @param bindings
|
|
65
|
+
*/
|
|
66
|
+
checkBindingArrayAsync(req, bindings) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
for (let i = 0; i < bindings.length; i++) {
|
|
69
|
+
let binding = bindings[i];
|
|
70
|
+
if ((yield this.checkBindingAsync(req, binding[0], binding[1])) === false) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return true;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
*
|
|
79
|
+
* @param req
|
|
80
|
+
* @param type
|
|
81
|
+
* @param value
|
|
82
|
+
*/
|
|
83
|
+
checkBindingAsync(req, type, value) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
switch (type) {
|
|
86
|
+
case SecurityManager.RULE_LOGGED_SESSION: {
|
|
87
|
+
return req.dfw.session.isLogged === value; // checks session state
|
|
88
|
+
}
|
|
89
|
+
case SecurityManager.RULE_CREDENTIAL: {
|
|
90
|
+
return yield this.checkUserCredentialsAsync(req.dfw.session.user, value); // checks credentials array
|
|
91
|
+
}
|
|
92
|
+
case SecurityManager.RULE_ACCESS: {
|
|
93
|
+
return yield this.checkUserAccessAsync(req.dfw.session.user, value); // checks access array
|
|
94
|
+
}
|
|
95
|
+
case SecurityManager.RULE_BODY_PARAMS_SETTED: {
|
|
96
|
+
return this.checkBodyParams(req, value); // Check params array on body
|
|
97
|
+
}
|
|
98
|
+
case SecurityManager.RULE_QUERY_PARAMS_SETTED: {
|
|
99
|
+
return this.checkQueryParams(req, value); // Check params array on body
|
|
100
|
+
}
|
|
101
|
+
default: {
|
|
102
|
+
return false; // UNKNOWN RULE always return false
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
createCredentialAsync(name) {
|
|
108
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
return this.db.dfw_credential.create({ data: { name, } });
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
checkUserCredentialsAsync(user, credential) {
|
|
113
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
if (!user)
|
|
115
|
+
return false;
|
|
116
|
+
return false;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
checkUserAccessAsync(user, access) {
|
|
120
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
+
if (!user)
|
|
122
|
+
return false;
|
|
123
|
+
return false;
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
addCredentialToAsync(user, credential) {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
const idUser = typeof user === "object" ? user.id : user;
|
|
129
|
+
if (Array.isArray(credential)) {
|
|
130
|
+
let result = yield Promise.all(credential.map((credentialObj) => this.addCredentialToAsync(user, credentialObj)));
|
|
131
|
+
return result.flat(1);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
let idCredential;
|
|
135
|
+
if (typeof credential == "number") {
|
|
136
|
+
idCredential = credential;
|
|
137
|
+
}
|
|
138
|
+
else if (typeof credential == "string") {
|
|
139
|
+
let credentialObj = (yield this.db.dfw_credential.findFirst({ where: { name: credential } }));
|
|
140
|
+
if (credentialObj) {
|
|
141
|
+
idCredential = credentialObj.id;
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
return [];
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
idCredential = credential.id;
|
|
149
|
+
}
|
|
150
|
+
let newCredential = yield this.db.dfw_credential.update({
|
|
151
|
+
data: {
|
|
152
|
+
users: {
|
|
153
|
+
connect: {
|
|
154
|
+
id: idUser
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
where: {
|
|
159
|
+
id: idCredential
|
|
160
|
+
}
|
|
161
|
+
}).catch((e) => []);
|
|
162
|
+
return Array.isArray(newCredential) ? newCredential : [newCredential];
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
checkBodyParams(req, params) {
|
|
167
|
+
let keys = req.body ? Object.keys(req.body) : [];
|
|
168
|
+
return keys.length >= params.length && params.every(v => keys.includes(v));
|
|
169
|
+
}
|
|
170
|
+
checkQueryParams(req, params) {
|
|
171
|
+
let keys = req.query ? Object.keys(req.query) : [];
|
|
172
|
+
return keys.length >= params.length && params.every(v => keys.includes(v));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
SecurityManager.RULE_LOGGED_SESSION = 0;
|
|
176
|
+
SecurityManager.RULE_ACCESS = 1;
|
|
177
|
+
SecurityManager.RULE_CREDENTIAL = 2;
|
|
178
|
+
SecurityManager.RULE_BODY_PARAMS_SETTED = 3;
|
|
179
|
+
SecurityManager.RULE_QUERY_PARAMS_SETTED = 4;
|
|
180
|
+
SecurityManager.RULE_LABELS = {
|
|
181
|
+
[SecurityManager.RULE_LOGGED_SESSION]: "access denied (you need to be logged)",
|
|
182
|
+
[SecurityManager.RULE_ACCESS]: "access denied (you dond have the access to this)",
|
|
183
|
+
[SecurityManager.RULE_CREDENTIAL]: "access denied (you dond have the credentials to this)",
|
|
184
|
+
[SecurityManager.RULE_BODY_PARAMS_SETTED]: "missing post arguments setted",
|
|
185
|
+
[SecurityManager.RULE_QUERY_PARAMS_SETTED]: "missing query arguments setted",
|
|
186
|
+
};
|
|
187
|
+
exports.default = SecurityManager;
|
|
192
188
|
//# sourceMappingURL=SecurityManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SecurityManager.js","sourceRoot":"","sources":["../../src/manager/SecurityManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,0EAAyC;AAGzC,4DAAoC;AAQpC,MAAqB,eAAgB,SAAQ,mBAAS;IAAtD;;QAgBW,eAAU,GAAG,CAAO,GAAe,EAAE,GAAa,EAAE,EAAE;YACzD,GAAG,CAAC,GAAG,CAAC,eAAe,GAAG,IAAI,CAAC;QACnC,CAAC,CAAA,CAAA;
|
|
1
|
+
{"version":3,"file":"SecurityManager.js","sourceRoot":"","sources":["../../src/manager/SecurityManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,0EAAyC;AAGzC,4DAAoC;AAQpC,MAAqB,eAAgB,SAAQ,mBAAS;IAAtD;;QAgBW,eAAU,GAAG,CAAO,GAAe,EAAE,GAAa,EAAE,EAAE;YACzD,GAAG,CAAC,GAAG,CAAC,eAAe,GAAG,IAAI,CAAC;QACnC,CAAC,CAAA,CAAA;IA2JL,CAAC;IAzJG;;;OAGG;IACI,MAAM,CAAC,cAAc,CAAC,cAAsC;QAC/D,IAAI,QAAQ,GAAoB,EAAE,CAAC;QAEnC,IAAI,cAAc,CAAC,OAAO,KAAK,SAAS,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AM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACnD,OAAO,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/E,CAAC;;AAzKe,mCAAmB,GAAG,CAAC,AAAJ,CAAK;AACxB,2BAAW,GAAG,CAAC,AAAJ,CAAK;AAChB,+BAAe,GAAG,CAAC,AAAJ,CAAK;AACpB,uCAAuB,GAAG,CAAC,AAAJ,CAAK;AAC5B,wCAAwB,GAAG,CAAC,AAAJ,CAAK;AAE7B,2BAAW,GAAG;IAC1B,CAAC,eAAe,CAAC,mBAAmB,CAAC,EAAE,uCAAuC;IAC9E,CAAC,eAAe,CAAC,WAAW,CAAC,EAAE,kDAAkD;IACjF,CAAC,eAAe,CAAC,eAAe,CAAC,EAAE,uDAAuD;IAC1F,CAAC,eAAe,CAAC,uBAAuB,CAAC,EAAE,+BAA+B;IAC1E,CAAC,eAAe,CAAC,wBAAwB,CAAC,EAAE,gCAAgC;CAC/E,AAN0B,CAM1B;kBAdgB,eAAe"}
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { Response } from "express";
|
|
2
|
-
import DFWInstance from "../DFWInstance";
|
|
3
|
-
import { DFWRequest } from "../types/DFWRequestScheme";
|
|
4
|
-
import DFWModule from "./DFWModule";
|
|
5
|
-
export default class SessionManager extends DFWModule {
|
|
6
|
-
readonly sessionExpirationDays: number;
|
|
7
|
-
readonly stkFieldName: string;
|
|
8
|
-
readonly sidFieldName: string;
|
|
9
|
-
constructor(DFW: DFWInstance);
|
|
10
|
-
middleware: (req: DFWRequest, res: Response) => Promise<void>;
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* @param req
|
|
14
|
-
* @param res
|
|
15
|
-
*/
|
|
16
|
-
private regenerateSessionAsync;
|
|
17
|
-
/**
|
|
18
|
-
*
|
|
19
|
-
* @param user
|
|
20
|
-
* @param password
|
|
21
|
-
* @param persist undefined => onli browser session time | number => number in days that sessiopn keeps opened
|
|
22
|
-
*/
|
|
23
|
-
loginAsync(req: DFWRequest, user: string, password: string): Promise<boolean>;
|
|
24
|
-
/**
|
|
25
|
-
*
|
|
26
|
-
* @param req
|
|
27
|
-
* @param res
|
|
28
|
-
*/
|
|
29
|
-
logoutAsync(req: DFWRequest): Promise<void>;
|
|
30
|
-
/**
|
|
31
|
-
* set (or reset) cookies if needed
|
|
32
|
-
* @param req
|
|
33
|
-
* @param res
|
|
34
|
-
*/
|
|
35
|
-
setSessionCookies(req: DFWRequest, res: Response): void;
|
|
36
|
-
/**
|
|
37
|
-
* Destroy all sessions that expires 1 day ago
|
|
38
|
-
*/
|
|
39
|
-
sweepExpiredSessionsAsync(): Promise<void>;
|
|
40
|
-
}
|
|
1
|
+
import { Response } from "express";
|
|
2
|
+
import DFWInstance from "../DFWInstance";
|
|
3
|
+
import { DFWRequest } from "../types/DFWRequestScheme";
|
|
4
|
+
import DFWModule from "./DFWModule";
|
|
5
|
+
export default class SessionManager extends DFWModule {
|
|
6
|
+
readonly sessionExpirationDays: number;
|
|
7
|
+
readonly stkFieldName: string;
|
|
8
|
+
readonly sidFieldName: string;
|
|
9
|
+
constructor(DFW: DFWInstance);
|
|
10
|
+
middleware: (req: DFWRequest, res: Response) => Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @param req
|
|
14
|
+
* @param res
|
|
15
|
+
*/
|
|
16
|
+
private regenerateSessionAsync;
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param user
|
|
20
|
+
* @param password
|
|
21
|
+
* @param persist undefined => onli browser session time | number => number in days that sessiopn keeps opened
|
|
22
|
+
*/
|
|
23
|
+
loginAsync(req: DFWRequest, user: string, password: string): Promise<boolean>;
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @param req
|
|
27
|
+
* @param res
|
|
28
|
+
*/
|
|
29
|
+
logoutAsync(req: DFWRequest): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* set (or reset) cookies if needed
|
|
32
|
+
* @param req
|
|
33
|
+
* @param res
|
|
34
|
+
*/
|
|
35
|
+
setSessionCookies(req: DFWRequest, res: Response): void;
|
|
36
|
+
/**
|
|
37
|
+
* Destroy all sessions that expires 1 day ago
|
|
38
|
+
*/
|
|
39
|
+
sweepExpiredSessionsAsync(): Promise<void>;
|
|
40
|
+
}
|
|
41
41
|
//# sourceMappingURL=SessionManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionManager.d.ts","sourceRoot":"","sources":["../../src/manager/SessionManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,WAAW,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,SAAS,MAAM,aAAa,CAAC;AAQpC,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,SAAS;IAEjD,SAAgB,qBAAqB,EAAE,MAAM,CAAC;IAC9C,SAAgB,YAAY,EAAE,MAAM,CAAS;IAC7C,SAAgB,YAAY,EAAE,MAAM,CAAS;gBAEjC,GAAG,EAAE,WAAW;IAKrB,UAAU,QAAe,UAAU,OAAO,QAAQ,
|
|
1
|
+
{"version":3,"file":"SessionManager.d.ts","sourceRoot":"","sources":["../../src/manager/SessionManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,WAAW,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,SAAS,MAAM,aAAa,CAAC;AAQpC,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,SAAS;IAEjD,SAAgB,qBAAq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