@scefira/dfw 0.2.9 → 1.0.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/DFWUtils.d.ts +3 -0
- package/lib/DFWUtils.d.ts.map +1 -1
- package/lib/DFWUtils.js +34 -2
- package/lib/DFWUtils.js.map +1 -1
- package/lib/controller/DFWController.d.ts +17 -0
- package/lib/controller/DFWController.d.ts.map +1 -0
- package/lib/{manager/DatabaseManager.js → controller/DFWController.js} +28 -8
- package/lib/controller/DFWController.js.map +1 -0
- package/lib/controller/DFWSecurityController.d.ts +29 -0
- package/lib/controller/DFWSecurityController.d.ts.map +1 -0
- package/lib/controller/DFWSecurityController.js +107 -0
- package/lib/controller/DFWSecurityController.js.map +1 -0
- package/lib/controller/DFWSessionController.d.ts +8 -0
- package/lib/controller/DFWSessionController.d.ts.map +1 -0
- package/lib/controller/DFWSessionController.js +45 -0
- package/lib/controller/DFWSessionController.js.map +1 -0
- package/lib/controller/DFWUserController.d.ts +22 -0
- package/lib/controller/DFWUserController.d.ts.map +1 -0
- package/lib/controller/DFWUserController.js +69 -0
- package/lib/controller/DFWUserController.js.map +1 -0
- package/lib/index.d.ts +35 -6
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +110 -13
- package/lib/index.js.map +1 -1
- package/lib/lib/APIManager.d.ts +10 -0
- package/lib/lib/APIManager.d.ts.map +1 -0
- package/lib/lib/APIManager.js +130 -0
- package/lib/lib/APIManager.js.map +1 -0
- package/lib/lib/DFWSessionStore.d.ts +11 -0
- package/lib/lib/DFWSessionStore.d.ts.map +1 -0
- package/lib/lib/DFWSessionStore.js +60 -0
- package/lib/lib/DFWSessionStore.js.map +1 -0
- package/lib/lib/SessionManager.d.ts +6 -0
- package/lib/lib/SessionManager.d.ts.map +1 -0
- package/lib/lib/SessionManager.js +9 -0
- package/lib/lib/SessionManager.js.map +1 -0
- package/lib/lib/strategies/DFWPassportStrategy.d.ts +4 -0
- package/lib/lib/strategies/DFWPassportStrategy.d.ts.map +1 -0
- package/lib/lib/strategies/DFWPassportStrategy.js +33 -0
- package/lib/lib/strategies/DFWPassportStrategy.js.map +1 -0
- package/lib/listeners/DELETEListener.d.ts +4 -0
- package/lib/listeners/DELETEListener.d.ts.map +1 -0
- package/lib/listeners/DELETEListener.js +10 -0
- package/lib/listeners/DELETEListener.js.map +1 -0
- package/lib/listeners/GETListener.d.ts +4 -0
- package/lib/listeners/GETListener.d.ts.map +1 -0
- package/lib/listeners/GETListener.js +10 -0
- package/lib/listeners/GETListener.js.map +1 -0
- package/lib/listeners/PATCHListener.d.ts +4 -0
- package/lib/listeners/PATCHListener.d.ts.map +1 -0
- package/lib/listeners/PATCHListener.js +10 -0
- package/lib/listeners/PATCHListener.js.map +1 -0
- package/lib/listeners/POSTListener.d.ts +4 -0
- package/lib/listeners/POSTListener.d.ts.map +1 -0
- package/lib/listeners/POSTListener.js +10 -0
- package/lib/listeners/POSTListener.js.map +1 -0
- package/lib/listeners/PUTListener.d.ts +4 -0
- package/lib/listeners/PUTListener.d.ts.map +1 -0
- package/lib/listeners/PUTListener.js +10 -0
- package/lib/listeners/PUTListener.js.map +1 -0
- package/lib/listeners/RawListener.d.ts +5 -0
- package/lib/listeners/RawListener.d.ts.map +1 -0
- package/lib/listeners/RawListener.js +13 -0
- package/lib/listeners/RawListener.js.map +1 -0
- package/lib/listeners/auth/DFWAuthListener.d.ts +4 -0
- package/lib/listeners/auth/DFWAuthListener.d.ts.map +1 -0
- package/lib/listeners/auth/DFWAuthListener.js +31 -0
- package/lib/listeners/auth/DFWAuthListener.js.map +1 -0
- package/lib/test.js +86 -63
- package/lib/test.js.map +1 -1
- package/lib/types/APIListener.d.ts +51 -0
- package/lib/types/APIListener.d.ts.map +1 -0
- package/lib/types/{DFWRequestScheme.js → APIListener.js} +1 -1
- package/lib/types/APIListener.js.map +1 -0
- package/lib/types/DFWConfig.d.ts +23 -30
- package/lib/types/DFWConfig.d.ts.map +1 -1
- package/lib/types/DFWRequest.d.ts +26 -0
- package/lib/types/DFWRequest.d.ts.map +1 -0
- package/lib/types/{DFWBoot.js → DFWRequest.js} +1 -1
- package/lib/types/DFWRequest.js.map +1 -0
- package/package.json +19 -11
- package/prisma/schema/dfw.prisma +91 -0
- package/prisma/schema/schema.prisma +9 -0
- package/lib/DFWInstance.d.ts +0 -21
- package/lib/DFWInstance.d.ts.map +0 -1
- package/lib/DFWInstance.js +0 -56
- package/lib/DFWInstance.js.map +0 -1
- package/lib/manager/APIManager.d.ts +0 -48
- package/lib/manager/APIManager.d.ts.map +0 -1
- package/lib/manager/APIManager.js +0 -211
- package/lib/manager/APIManager.js.map +0 -1
- package/lib/manager/DFWModule.d.ts +0 -14
- package/lib/manager/DFWModule.d.ts.map +0 -1
- package/lib/manager/DFWModule.js +0 -20
- package/lib/manager/DFWModule.js.map +0 -1
- package/lib/manager/DatabaseManager.d.ts +0 -9
- package/lib/manager/DatabaseManager.d.ts.map +0 -1
- package/lib/manager/DatabaseManager.js.map +0 -1
- package/lib/manager/FileManager.d.ts +0 -149
- package/lib/manager/FileManager.d.ts.map +0 -1
- package/lib/manager/FileManager.js +0 -279
- package/lib/manager/FileManager.js.map +0 -1
- package/lib/manager/SecurityManager.d.ts +0 -51
- package/lib/manager/SecurityManager.d.ts.map +0 -1
- package/lib/manager/SecurityManager.js +0 -201
- package/lib/manager/SecurityManager.js.map +0 -1
- package/lib/manager/SessionManager.d.ts +0 -41
- package/lib/manager/SessionManager.d.ts.map +0 -1
- package/lib/manager/SessionManager.js +0 -199
- package/lib/manager/SessionManager.js.map +0 -1
- package/lib/manager/UserManager.d.ts +0 -43
- package/lib/manager/UserManager.d.ts.map +0 -1
- package/lib/manager/UserManager.js +0 -63
- package/lib/manager/UserManager.js.map +0 -1
- package/lib/types/APIListenerConfig.d.ts +0 -53
- package/lib/types/APIListenerConfig.d.ts.map +0 -1
- package/lib/types/APIListenerConfig.js +0 -3
- package/lib/types/APIListenerConfig.js.map +0 -1
- package/lib/types/DFWBoot.d.ts +0 -19
- package/lib/types/DFWBoot.d.ts.map +0 -1
- package/lib/types/DFWBoot.js.map +0 -1
- package/lib/types/DFWRequestScheme.d.ts +0 -40
- package/lib/types/DFWRequestScheme.d.ts.map +0 -1
- package/lib/types/DFWRequestScheme.js.map +0 -1
- package/prisma/schema.prisma +0 -98
|
@@ -1,199 +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
|
-
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 DFWModule_1 = __importDefault(require("./DFWModule"));
|
|
16
|
-
const luxon_1 = require("luxon");
|
|
17
|
-
const DFWUtils_1 = __importDefault(require("../DFWUtils"));
|
|
18
|
-
const SecurityManager_1 = __importDefault(require("./SecurityManager"));
|
|
19
|
-
const DEFAULT_SESSION_EXPIRE_DAYS = 7;
|
|
20
|
-
class SessionManager extends DFWModule_1.default {
|
|
21
|
-
constructor(DFW) {
|
|
22
|
-
var _a, _b, _c, _d;
|
|
23
|
-
super(DFW);
|
|
24
|
-
this.stkFieldName = "stk";
|
|
25
|
-
this.sidFieldName = "sid";
|
|
26
|
-
this.middleware = (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
req.dfw.session = {
|
|
28
|
-
isLogged: false,
|
|
29
|
-
user: undefined,
|
|
30
|
-
record: undefined,
|
|
31
|
-
};
|
|
32
|
-
req.dfw.SessionManager = this;
|
|
33
|
-
if (req.dfw.__meta.config.noSession)
|
|
34
|
-
return;
|
|
35
|
-
if (!req.cookies || !req.cookies[this.sidFieldName] || !req.cookies[this.stkFieldName]) {
|
|
36
|
-
req.dfw.session = yield this.regenerateSessionAsync(req);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
let session = yield this.db.dfw_session.findFirst({
|
|
40
|
-
where: { id: Number(req.cookies[this.sidFieldName]), token: req.cookies[this.stkFieldName], expire: { gte: new Date() } },
|
|
41
|
-
include: {
|
|
42
|
-
user: {
|
|
43
|
-
include: {
|
|
44
|
-
credentials: {
|
|
45
|
-
select: {
|
|
46
|
-
id: true,
|
|
47
|
-
name: true,
|
|
48
|
-
access: {
|
|
49
|
-
select: {
|
|
50
|
-
id: true,
|
|
51
|
-
name: true
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
});
|
|
60
|
-
req.dfw.session = session ? { record: session, user: session.user, isLogged: session.user ? true : false } : yield this.regenerateSessionAsync(req);
|
|
61
|
-
}
|
|
62
|
-
this.setSessionCookies(req, res);
|
|
63
|
-
res.on("finish", () => __awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
var _e, _f;
|
|
65
|
-
if (!req.dfw.__meta.config.noSession) {
|
|
66
|
-
if (req.dfw.session.record.ip !== req.ip || req.dfw.session.record.agent !== ((_e = req.headers['user-agent']) !== null && _e !== void 0 ? _e : "")) {
|
|
67
|
-
yield req.dfw.db.dfw_session.update({
|
|
68
|
-
data: {
|
|
69
|
-
ip: req.ip,
|
|
70
|
-
agent: (_f = req.headers['user-agent']) !== null && _f !== void 0 ? _f : "",
|
|
71
|
-
},
|
|
72
|
-
where: {
|
|
73
|
-
id: Number(req.dfw.session.record.id)
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}));
|
|
79
|
-
});
|
|
80
|
-
this.sessionExpirationDays = DFW.config.session && DFW.config.session.daysToExpire ? DFW.config.session.daysToExpire : DEFAULT_SESSION_EXPIRE_DAYS;
|
|
81
|
-
this.sidFieldName = (_b = (_a = DFW.config.session) === null || _a === void 0 ? void 0 : _a.sid) !== null && _b !== void 0 ? _b : this.sidFieldName;
|
|
82
|
-
this.stkFieldName = (_d = (_c = DFW.config.session) === null || _c === void 0 ? void 0 : _c.stk) !== null && _d !== void 0 ? _d : this.stkFieldName;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
*
|
|
86
|
-
* @param req
|
|
87
|
-
* @param res
|
|
88
|
-
*/
|
|
89
|
-
regenerateSessionAsync(req) {
|
|
90
|
-
var _a;
|
|
91
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
-
let token = DFWUtils_1.default.uuid();
|
|
93
|
-
let session = yield this.db.dfw_session.create({
|
|
94
|
-
data: {
|
|
95
|
-
token,
|
|
96
|
-
agent: (_a = req.headers['user-agent']) !== null && _a !== void 0 ? _a : "",
|
|
97
|
-
ip: req.ip,
|
|
98
|
-
expire: luxon_1.DateTime.now().plus({ days: this.sessionExpirationDays }).toJSDate()
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
return { isLogged: false, record: session, user: undefined };
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
*
|
|
106
|
-
* @param user
|
|
107
|
-
* @param password
|
|
108
|
-
* @param persist undefined => onli browser session time | number => number in days that sessiopn keeps opened
|
|
109
|
-
*/
|
|
110
|
-
loginAsync(req, user, password) {
|
|
111
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
-
if (!user || !password)
|
|
113
|
-
return false;
|
|
114
|
-
// Retrive user with credentials
|
|
115
|
-
let userObj = yield req.dfw.UserManager.getUserAsync(user);
|
|
116
|
-
if (userObj) {
|
|
117
|
-
if (yield SecurityManager_1.default.verifyPassword(userObj.encodedKey, password)) {
|
|
118
|
-
let sessionUpdated = yield this.db.dfw_session.update({
|
|
119
|
-
include: {
|
|
120
|
-
user: {
|
|
121
|
-
include: {
|
|
122
|
-
credentials: {
|
|
123
|
-
select: {
|
|
124
|
-
id: true,
|
|
125
|
-
name: true,
|
|
126
|
-
access: {
|
|
127
|
-
select: {
|
|
128
|
-
id: true,
|
|
129
|
-
name: true
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
},
|
|
137
|
-
where: { id: Number(req.dfw.session.record.id) },
|
|
138
|
-
data: {
|
|
139
|
-
idUser: Number(userObj.id),
|
|
140
|
-
expire: luxon_1.DateTime.now().plus({ days: this.sessionExpirationDays }).toJSDate()
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
req.dfw.session = { isLogged: true, record: sessionUpdated, user: userObj };
|
|
144
|
-
return true;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
yield DFWUtils_1.default.sleepAsync(2500); // if login attempt fail ocurs a time gap for security to reduce guess oportunities
|
|
148
|
-
return false;
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
*
|
|
153
|
-
* @param req
|
|
154
|
-
* @param res
|
|
155
|
-
*/
|
|
156
|
-
logoutAsync(req) {
|
|
157
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
158
|
-
let sessionUpdated = yield req.dfw.db.dfw_session.update({
|
|
159
|
-
where: { id: Number(req.dfw.session.record.id) },
|
|
160
|
-
data: {
|
|
161
|
-
idUser: null,
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
req.dfw.session = { isLogged: false, record: sessionUpdated };
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* set (or reset) cookies if needed
|
|
169
|
-
* @param req
|
|
170
|
-
* @param res
|
|
171
|
-
*/
|
|
172
|
-
setSessionCookies(req, res) {
|
|
173
|
-
var _a;
|
|
174
|
-
let cookieOptions = this.instance.config.session ? (_a = this.instance.config.session.cookieOptions) !== null && _a !== void 0 ? _a : {} : {};
|
|
175
|
-
let diffCookies = req.cookies[this.sidFieldName] != req.dfw.session.record.id || req.cookies[this.stkFieldName] != req.dfw.session.record.token;
|
|
176
|
-
if (!diffCookies)
|
|
177
|
-
return; // no diference in cookies prevent reset cookies
|
|
178
|
-
res.cookie(this.sidFieldName, req.dfw.session.record.id, cookieOptions);
|
|
179
|
-
res.cookie(this.stkFieldName, req.dfw.session.record.token, cookieOptions);
|
|
180
|
-
req.cookies[this.sidFieldName] = req.dfw.session.record.id;
|
|
181
|
-
req.cookies[this.stkFieldName] = req.dfw.session.record.token;
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Destroy all sessions that expires 1 day ago
|
|
185
|
-
*/
|
|
186
|
-
sweepExpiredSessionsAsync() {
|
|
187
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
188
|
-
yield this.db.dfw_session.deleteMany({
|
|
189
|
-
where: {
|
|
190
|
-
expire: {
|
|
191
|
-
lt: luxon_1.DateTime.now().minus({ days: 1 }).toJSDate()
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
exports.default = SessionManager;
|
|
199
|
-
//# sourceMappingURL=SessionManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SessionManager.js","sourceRoot":"","sources":["../../src/manager/SessionManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAGA,4DAAoC;AACpC,iCAAiC;AACjC,2DAAmC;AACnC,wEAAgD;AAGhD,MAAM,2BAA2B,GAAG,CAAC,CAAC;AAEtC,MAAqB,cAAe,SAAQ,mB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C,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3D,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;IAClE,CAAC;IAED;;OAEG;IACU,yBAAyB;;YAClC,MAAM,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,UAAU,CAAC;gBACjC,KAAK,EAAE;oBACH,MAAM,EAAE;wBACJ,EAAE,EAAE,gBAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;qBACnD;iBACJ;aACJ,CAAC,CAAC;QACP,CAAC;KAAA;CACJ;AAzLD,iCAyLC"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Response } from "express";
|
|
2
|
-
import DFWModule from "./DFWModule";
|
|
3
|
-
import { DFWRequest } from "../types/DFWRequestScheme";
|
|
4
|
-
import DFWInstance from "../DFWInstance";
|
|
5
|
-
import { dfw_credential, dfw_user } from "@prisma/client";
|
|
6
|
-
export default class UserManager extends DFWModule {
|
|
7
|
-
constructor(DFW: DFWInstance);
|
|
8
|
-
middleware: ({ dfw }: DFWRequest, res: Response) => Promise<void>;
|
|
9
|
-
createUserAsync(email: string, nick: string, password?: string): Promise<import("@prisma/client/runtime/library").GetResult<{
|
|
10
|
-
id: number;
|
|
11
|
-
nick: string;
|
|
12
|
-
email: string;
|
|
13
|
-
status: number | null;
|
|
14
|
-
encodedKey: string | null;
|
|
15
|
-
createdAt: Date;
|
|
16
|
-
updatedAt: Date;
|
|
17
|
-
}, unknown> & {}>;
|
|
18
|
-
getUserAsync(reference: string): Promise<(import("@prisma/client/runtime/library").GetResult<{
|
|
19
|
-
id: number;
|
|
20
|
-
nick: string;
|
|
21
|
-
email: string;
|
|
22
|
-
status: number | null;
|
|
23
|
-
encodedKey: string | null;
|
|
24
|
-
createdAt: Date;
|
|
25
|
-
updatedAt: Date;
|
|
26
|
-
}, unknown> & {}) | null>;
|
|
27
|
-
createCredentiaASync(name: string, description?: string): Promise<import("@prisma/client/runtime/library").GetResult<{
|
|
28
|
-
id: number;
|
|
29
|
-
name: string;
|
|
30
|
-
description: string | null;
|
|
31
|
-
createdAt: Date;
|
|
32
|
-
updatedAt: Date;
|
|
33
|
-
}, unknown> & {}>;
|
|
34
|
-
createAccessAsync(name: string, description?: string): Promise<import("@prisma/client/runtime/library").GetResult<{
|
|
35
|
-
id: number;
|
|
36
|
-
name: string;
|
|
37
|
-
description: string | null;
|
|
38
|
-
createdAt: Date;
|
|
39
|
-
updatedAt: Date;
|
|
40
|
-
}, unknown> & {}>;
|
|
41
|
-
assignCredentialAsync(user: number | dfw_user, credential: dfw_credential | number | string | any[]): Promise<dfw_credential[]>;
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=UserManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UserManager.d.ts","sourceRoot":"","sources":["../../src/manager/UserManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGnC,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,WAAW,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1D,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,SAAS;gBAElC,GAAG,EAAE,WAAW;IAIrB,UAAU,YAAmB,UAAU,OAAO,QAAQ,mBAE5D;IAEY,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;;;;;;;;;IAU9D,YAAY,CAAC,SAAS,EAAE,MAAM;;;;;;;;;IAQ9B,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM;;;;;;;IAIvD,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM;;;;;;;IAIpD,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,EAAE,UAAU,EAAE,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,GAAG,EAAE,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;CAI/I"}
|
|
@@ -1,63 +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
|
-
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 SecurityManager_1 = __importDefault(require("./SecurityManager"));
|
|
16
|
-
const DFWUtils_1 = __importDefault(require("../DFWUtils"));
|
|
17
|
-
const DFWModule_1 = __importDefault(require("./DFWModule"));
|
|
18
|
-
class UserManager extends DFWModule_1.default {
|
|
19
|
-
constructor(DFW) {
|
|
20
|
-
super(DFW);
|
|
21
|
-
this.middleware = ({ dfw }, res) => __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
dfw.UserManager = this;
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
createUserAsync(email, nick, password) {
|
|
26
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
return this.db.dfw_user.create({
|
|
28
|
-
data: {
|
|
29
|
-
nick,
|
|
30
|
-
email,
|
|
31
|
-
encodedKey: password ? yield SecurityManager_1.default.encryptPassword(password) : undefined
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
getUserAsync(reference) {
|
|
37
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
if (DFWUtils_1.default.isEmail(reference)) {
|
|
39
|
-
return yield this.db.dfw_user.findFirst({ where: { email: reference } });
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
return yield this.db.dfw_user.findFirst({ where: { nick: reference } });
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
createCredentiaASync(name, description) {
|
|
47
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
return this.db.dfw_credential.create({ data: { name, description } });
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
createAccessAsync(name, description) {
|
|
52
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
return this.db.dfw_access.create({ data: { name, description } });
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
assignCredentialAsync(user, credential) {
|
|
57
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
-
return this.instance.SecurityManager.use(this.db).addCredentialToAsync(user, credential);
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
exports.default = UserManager;
|
|
63
|
-
//# sourceMappingURL=UserManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UserManager.js","sourceRoot":"","sources":["../../src/manager/UserManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,wEAAgD;AAChD,2DAAmC;AACnC,4DAAoC;AAKpC,MAAqB,WAAY,SAAQ,mBAAS;IAE9C,YAAY,G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E,CAAC,CAAC;QACtE,CAAC;KAAA;IAEY,qBAAqB,CAAC,IAAuB,EAAE,UAAoD;;YAC5G,OAAO,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,oBAAoB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAC7F,CAAC;KAAA;CAEJ;AAxCD,8BAwCC"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { RequestHandler } from "express";
|
|
2
|
-
import fileUpload from "express-fileupload";
|
|
3
|
-
import { APIMethods } from "../manager/APIManager";
|
|
4
|
-
import { DFWRequest } from "./DFWRequestScheme";
|
|
5
|
-
export type APIListenerConfig = {
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
method?: APIMethods;
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
*/
|
|
13
|
-
middleware?: RequestHandler | RequestHandler[];
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
security?: ListenerSecurityConfig;
|
|
18
|
-
/**
|
|
19
|
-
* By default DFW-Express parses the request body
|
|
20
|
-
* if parseBody is false Disables the body parse
|
|
21
|
-
*
|
|
22
|
-
*/
|
|
23
|
-
parseBody?: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* allow/disallow to upload files
|
|
26
|
-
* @default false
|
|
27
|
-
*/
|
|
28
|
-
upload?: true | fileUpload.Options;
|
|
29
|
-
/**
|
|
30
|
-
* Disable the autosend system, allows you to specify what send to the clien and when
|
|
31
|
-
*/
|
|
32
|
-
autoSend?: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* if false the session system will be disabled for this api endpoint
|
|
35
|
-
* @default true
|
|
36
|
-
*/
|
|
37
|
-
noSession?: boolean;
|
|
38
|
-
/**
|
|
39
|
-
* Callback function after the server responses to the client (after the connection was closed)
|
|
40
|
-
*/
|
|
41
|
-
callback?: (req: DFWRequest, objResponse: any) => Promise<void>;
|
|
42
|
-
};
|
|
43
|
-
export interface ListenerSecurityConfig {
|
|
44
|
-
session?: boolean;
|
|
45
|
-
validation?: {
|
|
46
|
-
body?: string[];
|
|
47
|
-
query?: string[];
|
|
48
|
-
};
|
|
49
|
-
bindings?: [number, any][];
|
|
50
|
-
credentials?: number[] | string[];
|
|
51
|
-
access?: number[] | string[];
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=APIListenerConfig.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"APIListenerConfig.d.ts","sourceRoot":"","sources":["../../src/types/APIListenerConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,UAAU,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,MAAM,MAAM,iBAAiB,GAAG;IAC5B;;OAEG;IACF,MAAM,CAAC,EAAC,UAAU,CAAC;IAEnB;;OAEG;IACH,UAAU,CAAC,EAAC,cAAc,GAAC,cAAc,EAAE,CAAC;IAE5C;;OAEG;IACH,QAAQ,CAAC,EAAC,sBAAsB,CAAC;IAEjC;;;;OAIG;IACH,SAAS,CAAC,EAAC,OAAO,CAAC;IAEnB;;;OAGG;IACH,MAAM,CAAC,EAAC,IAAI,GAAC,UAAU,CAAC,OAAO,CAAC;IAEhC;;OAEG;IACH,QAAQ,CAAC,EAAC,OAAO,CAAC;IAElB;;;OAGG;IACF,SAAS,CAAC,EAAC,OAAO,CAAC;IAEpB;;OAEG;IACH,QAAQ,CAAC,EAAC,CAAC,GAAG,EAAC,UAAU,EAAC,WAAW,EAAC,GAAG,KAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC7D,CAAA;AAGD,MAAM,WAAW,sBAAsB;IACnC,OAAO,CAAC,EAAC,OAAO,CAAC;IACjB,UAAU,CAAC,EAAC;QACR,IAAI,CAAC,EAAC,MAAM,EAAE,CAAC;QACf,KAAK,CAAC,EAAC,MAAM,EAAE,CAAC;KACnB,CAAA;IACD,QAAQ,CAAC,EAAC,CAAC,MAAM,EAAC,GAAG,CAAC,EAAE,CAAC;IACzB,WAAW,CAAC,EAAC,MAAM,EAAE,GAAC,MAAM,EAAE,CAAC;IAC/B,MAAM,CAAC,EAAC,MAAM,EAAE,GAAC,MAAM,EAAE,CAAC;CAC7B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"APIListenerConfig.js","sourceRoot":"","sources":["../../src/types/APIListenerConfig.ts"],"names":[],"mappings":""}
|
package/lib/types/DFWBoot.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export type DFWBoot = {
|
|
2
|
-
session: {
|
|
3
|
-
user?: {
|
|
4
|
-
id: number;
|
|
5
|
-
nick?: string;
|
|
6
|
-
email?: string;
|
|
7
|
-
credentials: {
|
|
8
|
-
id: number;
|
|
9
|
-
name: string;
|
|
10
|
-
access: {
|
|
11
|
-
id: number;
|
|
12
|
-
name: string;
|
|
13
|
-
}[];
|
|
14
|
-
}[];
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
export default DFWBoot;
|
|
19
|
-
//# sourceMappingURL=DFWBoot.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DFWBoot.d.ts","sourceRoot":"","sources":["../../src/types/DFWBoot.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG;IAClB,OAAO,EAAE;QACL,IAAI,CAAC,EAAE;YACH,EAAE,EAAE,MAAM,CAAC;YACX,IAAI,CAAC,EAAE,MAAM,CAAC;YACd,KAAK,CAAC,EAAE,MAAM,CAAC;YACf,WAAW,EAAE;gBACT,EAAE,EAAE,MAAM,CAAC;gBACX,IAAI,EAAE,MAAM,CAAC;gBACb,MAAM,EAAE;oBACJ,EAAE,EAAE,MAAM,CAAC;oBACX,IAAI,EAAE,MAAM,CAAC;iBAChB,EAAE,CAAA;aACN,EAAE,CAAC;SACP,CAAA;KACJ,CAAA;CACJ,CAAA;AAED,eAAe,OAAO,CAAC"}
|
package/lib/types/DFWBoot.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DFWBoot.js","sourceRoot":"","sources":["../../src/types/DFWBoot.ts"],"names":[],"mappings":""}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import DFWInstance from "../DFWInstance";
|
|
2
|
-
import { Request, Response } from "express";
|
|
3
|
-
import SecurityManager from "../manager/SecurityManager";
|
|
4
|
-
import UserManager from "../manager/UserManager";
|
|
5
|
-
import SessionManager from "../manager/SessionManager";
|
|
6
|
-
import FileManager from "../manager/FileManager";
|
|
7
|
-
import DFWBoot from "./DFWBoot";
|
|
8
|
-
import { dfw_session, dfw_user, PrismaClient } from "@prisma/client";
|
|
9
|
-
import { APIListenerConfig } from "./APIListenerConfig";
|
|
10
|
-
export type DFWRequest = {
|
|
11
|
-
dfw: DFWRequestScheme;
|
|
12
|
-
} & Request;
|
|
13
|
-
export type DFWRequestScheme = {
|
|
14
|
-
__meta: {
|
|
15
|
-
config: APIListenerConfig;
|
|
16
|
-
};
|
|
17
|
-
req: DFWRequest;
|
|
18
|
-
res: Response;
|
|
19
|
-
instance: DFWInstance;
|
|
20
|
-
session: {
|
|
21
|
-
isLogged: boolean;
|
|
22
|
-
user?: dfw_user;
|
|
23
|
-
record: dfw_session & {
|
|
24
|
-
user?: dfw_user | null;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
db: PrismaClient;
|
|
28
|
-
boot: () => Promise<DFWBoot>;
|
|
29
|
-
/**
|
|
30
|
-
* Callback called in background after finish the api response
|
|
31
|
-
* @param cb callback function or promise
|
|
32
|
-
* @returns
|
|
33
|
-
*/
|
|
34
|
-
addCallback: (cb: () => void | Promise<void>) => void;
|
|
35
|
-
SecurityManager: SecurityManager;
|
|
36
|
-
SessionManager: SessionManager;
|
|
37
|
-
FileManager: FileManager;
|
|
38
|
-
UserManager: UserManager;
|
|
39
|
-
};
|
|
40
|
-
//# sourceMappingURL=DFWRequestScheme.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DFWRequestScheme.d.ts","sourceRoot":"","sources":["../../src/types/DFWRequestScheme.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,eAAe,MAAM,4BAA4B,CAAC;AACzD,OAAO,WAAW,MAAM,wBAAwB,CAAC;AACjD,OAAO,cAAc,MAAM,2BAA2B,CAAC;AACvD,OAAO,WAAW,MAAM,wBAAwB,CAAC;AACjD,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,MAAM,UAAU,GAAG;IACrB,GAAG,EAAE,gBAAgB,CAAC;CACzB,GAAG,OAAO,CAAA;AAEX,MAAM,MAAM,gBAAgB,GAAG;IAC3B,MAAM,EAAE;QACJ,MAAM,EAAE,iBAAiB,CAAA;KAC5B,CAAC;IACF,GAAG,EAAE,UAAU,CAAA;IACf,GAAG,EAAE,QAAQ,CAAA;IACb,QAAQ,EAAE,WAAW,CAAA;IACrB,OAAO,EAAE;QACL,QAAQ,EAAE,OAAO,CAAA;QACjB,IAAI,CAAC,EAAE,QAAQ,CAAA;QACf,MAAM,EAAE,WAAW,GAAG;YAAE,IAAI,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAA;SAAE,CAAA;KACnD,CAAC;IAEF,EAAE,EAAE,YAAY,CAAC;IAEjB,IAAI,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;IAE5B;;;;OAIG;IACH,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,CAAA;IAGrD,eAAe,EAAE,eAAe,CAAA;IAChC,cAAc,EAAE,cAAc,CAAA;IAC9B,WAAW,EAAE,WAAW,CAAA;IACxB,WAAW,EAAE,WAAW,CAAA;CAC3B,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DFWRequestScheme.js","sourceRoot":"","sources":["../../src/types/DFWRequestScheme.ts"],"names":[],"mappings":""}
|
package/prisma/schema.prisma
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
generator client {
|
|
2
|
-
provider = "prisma-client-js"
|
|
3
|
-
previewFeatures = ["interactiveTransactions"]
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
datasource db {
|
|
7
|
-
provider = "mysql"
|
|
8
|
-
url = env("DATABASE_URL")
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
model dfw_access {
|
|
12
|
-
id Int @id @default(autoincrement()) @db.UnsignedInt
|
|
13
|
-
name String @unique @db.VarChar(255)
|
|
14
|
-
description String? @db.VarChar(255)
|
|
15
|
-
|
|
16
|
-
createdAt DateTime @default(now())
|
|
17
|
-
updatedAt DateTime @updatedAt
|
|
18
|
-
|
|
19
|
-
credentials dfw_credential[]
|
|
20
|
-
|
|
21
|
-
@@index([name])
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
model dfw_credential {
|
|
25
|
-
id Int @id @default(autoincrement()) @db.UnsignedInt
|
|
26
|
-
name String @unique @db.VarChar(255)
|
|
27
|
-
description String? @db.VarChar(255)
|
|
28
|
-
|
|
29
|
-
createdAt DateTime @default(now())
|
|
30
|
-
updatedAt DateTime @updatedAt
|
|
31
|
-
|
|
32
|
-
users dfw_user[]
|
|
33
|
-
access dfw_access[]
|
|
34
|
-
|
|
35
|
-
@@index([name])
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
model dfw_file {
|
|
39
|
-
id Int @id @default(autoincrement()) @db.UnsignedInt
|
|
40
|
-
path String @db.VarChar(255)
|
|
41
|
-
description String? @db.VarChar(255)
|
|
42
|
-
idUser Int? @db.UnsignedInt
|
|
43
|
-
variant String? @db.VarChar(255)
|
|
44
|
-
size Int? @db.UnsignedInt
|
|
45
|
-
checksum String? @db.VarChar(255)
|
|
46
|
-
slug String? @db.VarChar(255)
|
|
47
|
-
mimetype String? @db.VarChar(255)
|
|
48
|
-
virtual Boolean @default(false)
|
|
49
|
-
expire DateTime? @db.Date
|
|
50
|
-
idParent Int? @db.UnsignedInt
|
|
51
|
-
|
|
52
|
-
createdAt DateTime @default(now())
|
|
53
|
-
updatedAt DateTime @updatedAt
|
|
54
|
-
|
|
55
|
-
user dfw_user? @relation(fields: [idUser], references: [id])
|
|
56
|
-
parent dfw_file? @relation("parent", fields: [idParent], references: [id])
|
|
57
|
-
children dfw_file[] @relation("parent")
|
|
58
|
-
|
|
59
|
-
@@index([expire])
|
|
60
|
-
@@index([id])
|
|
61
|
-
@@index([slug])
|
|
62
|
-
@@index([idParent])
|
|
63
|
-
@@index([idUser])
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
model dfw_session {
|
|
67
|
-
id Int @id @default(autoincrement()) @db.UnsignedInt
|
|
68
|
-
token String @db.Char(36)
|
|
69
|
-
agent String? @db.VarChar(255)
|
|
70
|
-
ip String? @db.VarChar(255)
|
|
71
|
-
expire DateTime? @db.Date
|
|
72
|
-
idUser Int? @db.UnsignedInt
|
|
73
|
-
|
|
74
|
-
createdAt DateTime @default(now())
|
|
75
|
-
updatedAt DateTime @updatedAt
|
|
76
|
-
|
|
77
|
-
user dfw_user? @relation(fields: [idUser], references: [id])
|
|
78
|
-
|
|
79
|
-
@@index([idUser])
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
model dfw_user {
|
|
83
|
-
id Int @id @default(autoincrement()) @db.UnsignedInt
|
|
84
|
-
nick String @unique @db.VarChar(255)
|
|
85
|
-
email String @unique @db.VarChar(255)
|
|
86
|
-
status Int? @db.TinyInt
|
|
87
|
-
encodedKey String? @db.VarChar(255)
|
|
88
|
-
|
|
89
|
-
createdAt DateTime @default(now())
|
|
90
|
-
updatedAt DateTime @updatedAt
|
|
91
|
-
|
|
92
|
-
sessions dfw_session[]
|
|
93
|
-
credentials dfw_credential[]
|
|
94
|
-
files dfw_file[]
|
|
95
|
-
|
|
96
|
-
@@index([email])
|
|
97
|
-
@@index([nick])
|
|
98
|
-
}
|