@tomei/sso 0.1.2 → 0.2.1
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/README.md +7 -2
- package/__tests__/unit/components/login-history/login-history.repository.spec.ts +95 -0
- package/__tests__/unit/components/login-user/login-user.spec.ts +223 -0
- package/__tests__/unit/components/login-user/user.repository.spec.ts +81 -0
- package/__tests__/unit/components/password-hash/password-hash.service.spec.ts +33 -0
- package/__tests__/unit/components/system/system.repository.spec.ts +88 -0
- package/__tests__/unit/components/system-access/system-access.repository.spec.ts +78 -0
- package/__tests__/unit/redis-client/redis.service.spec.ts +24 -0
- package/__tests__/unit/session/session.service.spec.ts +27 -0
- package/create-sso-user.sql +1 -0
- package/dist/__tests__/unit/components/login-history/login-history.repository.spec.d.ts +1 -0
- package/dist/__tests__/unit/components/login-history/login-history.repository.spec.js +99 -0
- package/dist/__tests__/unit/components/login-history/login-history.repository.spec.js.map +1 -0
- package/dist/__tests__/unit/components/login-user/login-user.spec.d.ts +1 -0
- package/dist/__tests__/unit/components/login-user/login-user.spec.js +208 -0
- package/dist/__tests__/unit/components/login-user/login-user.spec.js.map +1 -0
- package/dist/__tests__/unit/components/login-user/user.repository.spec.d.ts +1 -0
- package/dist/__tests__/unit/components/login-user/user.repository.spec.js +78 -0
- package/dist/__tests__/unit/components/login-user/user.repository.spec.js.map +1 -0
- package/dist/__tests__/unit/components/password-hash/password-hash.service.spec.d.ts +1 -0
- package/dist/__tests__/unit/components/password-hash/password-hash.service.spec.js +38 -0
- package/dist/__tests__/unit/components/password-hash/password-hash.service.spec.js.map +1 -0
- package/dist/__tests__/unit/components/system/system.repository.spec.d.ts +1 -0
- package/dist/__tests__/unit/components/system/system.repository.spec.js +85 -0
- package/dist/__tests__/unit/components/system/system.repository.spec.js.map +1 -0
- package/dist/__tests__/unit/components/system-access/system-access.repository.spec.d.ts +1 -0
- package/dist/__tests__/unit/components/system-access/system-access.repository.spec.js +75 -0
- package/dist/__tests__/unit/components/system-access/system-access.repository.spec.js.map +1 -0
- package/dist/__tests__/unit/redis-client/redis.service.spec.d.ts +1 -0
- package/dist/__tests__/unit/redis-client/redis.service.spec.js +32 -0
- package/dist/__tests__/unit/redis-client/redis.service.spec.js.map +1 -0
- package/dist/__tests__/unit/session/session.service.spec.d.ts +1 -0
- package/dist/__tests__/unit/session/session.service.spec.js +36 -0
- package/dist/__tests__/unit/session/session.service.spec.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -1
- package/dist/src/components/index.d.ts +7 -0
- package/dist/src/components/index.js +24 -0
- package/dist/src/components/index.js.map +1 -0
- package/dist/src/components/login-history/index.d.ts +1 -0
- package/dist/src/components/login-history/index.js +18 -0
- package/dist/src/components/login-history/index.js.map +1 -0
- package/dist/src/components/login-history/login-history.repository.d.ts +9 -0
- package/dist/src/components/login-history/login-history.repository.js +50 -0
- package/dist/src/components/login-history/login-history.repository.js.map +1 -0
- package/dist/src/components/login-user/index.d.ts +3 -0
- package/dist/src/components/login-user/index.js +20 -0
- package/dist/src/components/login-user/index.js.map +1 -0
- package/dist/src/components/login-user/interfaces/index.d.ts +1 -0
- package/dist/src/components/login-user/interfaces/index.js +18 -0
- package/dist/src/components/login-user/interfaces/index.js.map +1 -0
- package/dist/src/components/login-user/interfaces/user-info.interface.d.ts +9 -0
- package/dist/src/components/login-user/interfaces/user-info.interface.js +3 -0
- package/dist/src/components/login-user/interfaces/user-info.interface.js.map +1 -0
- package/dist/src/components/login-user/login-user.d.ts +41 -0
- package/dist/src/components/login-user/login-user.js +332 -0
- package/dist/src/components/login-user/login-user.js.map +1 -0
- package/dist/src/components/login-user/user.repository.d.ts +9 -0
- package/dist/src/components/login-user/user.repository.js +50 -0
- package/dist/src/components/login-user/user.repository.js.map +1 -0
- package/dist/src/components/password-hash/index.d.ts +2 -0
- package/dist/src/components/password-hash/index.js +19 -0
- package/dist/src/components/password-hash/index.js.map +1 -0
- package/dist/src/components/password-hash/interfaces/index.d.ts +1 -0
- package/dist/src/components/password-hash/interfaces/index.js +18 -0
- package/dist/src/components/password-hash/interfaces/index.js.map +1 -0
- package/dist/src/components/password-hash/interfaces/password-hash-service.interface.d.ts +4 -0
- package/dist/src/components/password-hash/interfaces/password-hash-service.interface.js +3 -0
- package/dist/src/components/password-hash/interfaces/password-hash-service.interface.js.map +1 -0
- package/dist/src/components/password-hash/password-hash.service.d.ts +6 -0
- package/dist/src/components/password-hash/password-hash.service.js +28 -0
- package/dist/src/components/password-hash/password-hash.service.js.map +1 -0
- package/dist/src/components/system/index.d.ts +1 -0
- package/dist/src/components/system/index.js +18 -0
- package/dist/src/components/system/index.js.map +1 -0
- package/dist/src/components/system/system.repository.d.ts +9 -0
- package/dist/src/components/system/system.repository.js +50 -0
- package/dist/src/components/system/system.repository.js.map +1 -0
- package/dist/src/components/system-access/index.d.ts +1 -0
- package/dist/src/components/system-access/index.js +18 -0
- package/dist/src/components/system-access/index.js.map +1 -0
- package/dist/src/components/system-access/system-access.repository.d.ts +9 -0
- package/dist/src/components/system-access/system-access.repository.js +50 -0
- package/dist/src/components/system-access/system-access.repository.js.map +1 -0
- package/dist/src/components/user-group/index.d.ts +1 -0
- package/dist/src/components/user-group/index.js +18 -0
- package/dist/src/components/user-group/index.js.map +1 -0
- package/dist/src/components/user-group/user-group.repository.d.ts +9 -0
- package/dist/src/components/user-group/user-group.repository.js +50 -0
- package/dist/src/components/user-group/user-group.repository.js.map +1 -0
- package/dist/src/components/user-user-group/index.d.ts +1 -0
- package/dist/src/components/user-user-group/index.js +18 -0
- package/dist/src/components/user-user-group/index.js.map +1 -0
- package/dist/src/components/user-user-group/user-user-group.repository.d.ts +9 -0
- package/dist/src/components/user-user-group/user-user-group.repository.js +50 -0
- package/dist/src/components/user-user-group/user-user-group.repository.js.map +1 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.js +24 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/interfaces/index.d.ts +2 -0
- package/dist/src/interfaces/index.js +19 -0
- package/dist/src/interfaces/index.js.map +1 -0
- package/dist/src/interfaces/system-login.interface.d.ts +6 -0
- package/dist/src/interfaces/system-login.interface.js +3 -0
- package/dist/src/interfaces/system-login.interface.js.map +1 -0
- package/dist/src/interfaces/user-session.interface.d.ts +4 -0
- package/dist/src/interfaces/user-session.interface.js +3 -0
- package/dist/src/interfaces/user-session.interface.js.map +1 -0
- package/dist/src/mail/index.d.ts +2 -0
- package/dist/src/mail/index.js +19 -0
- package/dist/src/mail/index.js.map +1 -0
- package/dist/src/mail/interfaces/index.d.ts +2 -0
- package/dist/src/mail/interfaces/index.js +19 -0
- package/dist/src/mail/interfaces/index.js.map +1 -0
- package/dist/src/mail/interfaces/send-mail.interface.d.ts +8 -0
- package/dist/src/mail/interfaces/send-mail.interface.js +3 -0
- package/dist/src/mail/interfaces/send-mail.interface.js.map +1 -0
- package/dist/src/mail/interfaces/send-new-login-alert.interface.d.ts +6 -0
- package/dist/src/mail/interfaces/send-new-login-alert.interface.js +3 -0
- package/dist/src/mail/interfaces/send-new-login-alert.interface.js.map +1 -0
- package/dist/src/mail/mail.d.ts +7 -0
- package/dist/src/mail/mail.js +49 -0
- package/dist/src/mail/mail.js.map +1 -0
- package/dist/src/mail/mail.service.d.ts +7 -0
- package/dist/src/mail/mail.service.js +42 -0
- package/dist/src/mail/mail.service.js.map +1 -0
- package/dist/src/prisma-client/__mocks__/prisma.d.ts +3 -0
- package/dist/src/prisma-client/__mocks__/prisma.js +14 -0
- package/dist/src/prisma-client/__mocks__/prisma.js.map +1 -0
- package/dist/src/prisma-client/client.d.ts +3 -0
- package/dist/src/prisma-client/client.js +6 -0
- package/dist/src/prisma-client/client.js.map +1 -0
- package/dist/src/prisma-client/index.d.ts +1 -0
- package/dist/src/prisma-client/index.js +18 -0
- package/dist/src/prisma-client/index.js.map +1 -0
- package/dist/src/redis-client/__mocks__/jest-initial-setup.d.ts +1 -0
- package/dist/src/redis-client/__mocks__/jest-initial-setup.js +5 -0
- package/dist/src/redis-client/__mocks__/jest-initial-setup.js.map +1 -0
- package/dist/src/redis-client/__mocks__/redis-mock.d.ts +2 -0
- package/dist/src/redis-client/__mocks__/redis-mock.js +23 -0
- package/dist/src/redis-client/__mocks__/redis-mock.js.map +1 -0
- package/dist/src/redis-client/index.d.ts +1 -0
- package/dist/src/redis-client/index.js +18 -0
- package/dist/src/redis-client/index.js.map +1 -0
- package/dist/src/redis-client/redis.service.d.ts +7 -0
- package/dist/src/redis-client/redis.service.js +56 -0
- package/dist/src/redis-client/redis.service.js.map +1 -0
- package/dist/src/session/index.d.ts +2 -0
- package/dist/src/session/index.js +19 -0
- package/dist/src/session/index.js.map +1 -0
- package/dist/src/session/interfaces/index.d.ts +1 -0
- package/dist/src/session/interfaces/index.js +18 -0
- package/dist/src/session/interfaces/index.js.map +1 -0
- package/dist/src/session/interfaces/session-service.interface.d.ts +5 -0
- package/dist/src/session/interfaces/session-service.interface.js +3 -0
- package/dist/src/session/interfaces/session-service.interface.js.map +1 -0
- package/dist/src/session/session.service.d.ts +9 -0
- package/dist/src/session/session.service.js +52 -0
- package/dist/src/session/session.service.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/index.ts +1 -0
- package/jest.config.js +15 -0
- package/package.json +21 -3
- package/prisma/migrations/0_init/migration.sql +41 -42
- package/prisma/migrations/20230528161352_create_user_user_group_and_add_new_column/migration.sql +2 -2
- package/prisma/migrations/20230606091407_create_login_histories_table/migration.sql +17 -0
- package/prisma/schema.prisma +46 -33
- package/sampledotenv +8 -0
- package/src/components/index.ts +7 -0
- package/src/components/login-history/index.ts +1 -0
- package/src/components/login-history/login-history.repository.ts +33 -0
- package/src/components/login-user/index.ts +4 -0
- package/src/components/login-user/interfaces/index.ts +1 -0
- package/src/components/login-user/interfaces/user-info.interface.ts +9 -0
- package/src/components/login-user/login-user.ts +427 -0
- package/src/components/login-user/user.repository.ts +33 -0
- package/src/components/password-hash/index.ts +2 -0
- package/src/components/password-hash/interfaces/index.ts +1 -0
- package/src/components/password-hash/interfaces/password-hash-service.interface.ts +4 -0
- package/src/components/password-hash/password-hash.service.ts +14 -0
- package/src/components/system/index.ts +1 -0
- package/src/components/system/system.repository.ts +33 -0
- package/src/components/system-access/index.ts +1 -0
- package/src/components/system-access/system-access.repository.ts +33 -0
- package/src/components/user-group/index.ts +1 -0
- package/src/components/user-group/user-group.repository.ts +33 -0
- package/src/components/user-user-group/index.ts +1 -0
- package/src/components/user-user-group/user-user-group.repository.ts +33 -0
- package/src/index.ts +7 -0
- package/src/interfaces/index.ts +2 -0
- package/src/interfaces/system-login.interface.ts +6 -0
- package/src/interfaces/user-session.interface.ts +5 -0
- package/src/mail/index.ts +2 -0
- package/src/mail/interfaces/index.ts +2 -0
- package/src/mail/interfaces/send-mail.interface.ts +8 -0
- package/src/mail/interfaces/send-new-login-alert.interface.ts +6 -0
- package/src/mail/mail.service.ts +33 -0
- package/src/mail/mail.ts +40 -0
- package/src/prisma-client/__mocks__/prisma.ts +15 -0
- package/src/prisma-client/client.ts +3 -0
- package/src/prisma-client/index.ts +1 -0
- package/src/redis-client/__mocks__/jest-initial-setup.ts +2 -0
- package/src/redis-client/__mocks__/redis-mock.ts +28 -0
- package/src/redis-client/index.ts +1 -0
- package/src/redis-client/redis.service.ts +48 -0
- package/src/session/index.ts +2 -0
- package/src/session/interfaces/index.ts +1 -0
- package/src/session/interfaces/session-service.interface.ts +6 -0
- package/src/session/session.service.ts +45 -0
- package/tsconfig.build.json +2 -1
- package/tsconfig.json +5 -4
@@ -0,0 +1,332 @@
|
|
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.LoginUser = void 0;
|
13
|
+
const general_1 = require("@tomei/general");
|
14
|
+
const user_repository_1 = require("./user.repository");
|
15
|
+
const system_repository_1 = require("../system/system.repository");
|
16
|
+
const system_access_repository_1 = require("../system-access/system-access.repository");
|
17
|
+
const login_history_repository_1 = require("../login-history/login-history.repository");
|
18
|
+
const mail_service_1 = require("../../mail/mail.service");
|
19
|
+
const user_user_group_repository_1 = require("../user-user-group/user-user-group.repository");
|
20
|
+
const password_hash_service_1 = require("../password-hash/password-hash.service");
|
21
|
+
const session_service_1 = require("../../session/session.service");
|
22
|
+
const user_group_repository_1 = require("../user-group/user-group.repository");
|
23
|
+
class LoginUser extends general_1.ObjectBase {
|
24
|
+
getDetails() {
|
25
|
+
return {
|
26
|
+
FullName: this.FullName,
|
27
|
+
IDNo: this.IDNo,
|
28
|
+
IDType: this.IDType,
|
29
|
+
Email: this.Email,
|
30
|
+
ContactNo: this.ContactNo,
|
31
|
+
};
|
32
|
+
}
|
33
|
+
constructor(sessionService, dbTransaction, userInfo) {
|
34
|
+
super();
|
35
|
+
this.ObjectName = 'User';
|
36
|
+
this.TableName = 'sso_users';
|
37
|
+
this._PasswordHashService = new password_hash_service_1.PasswordHashService();
|
38
|
+
this._MailService = new mail_service_1.MailService();
|
39
|
+
this._SessionService = sessionService;
|
40
|
+
if (dbTransaction) {
|
41
|
+
LoginUser._Repository = new user_repository_1.UserRepository(dbTransaction);
|
42
|
+
LoginUser._SystemRepository = new system_repository_1.SystemRepository(dbTransaction);
|
43
|
+
LoginUser._SystemAccessRepository = new system_access_repository_1.SystemAccessRepository(dbTransaction);
|
44
|
+
LoginUser._LoginHistoryRepository = new login_history_repository_1.LoginHistoryRepository(dbTransaction);
|
45
|
+
LoginUser._UserUserGroupRepository = new user_user_group_repository_1.UserUserGroupRepository(dbTransaction);
|
46
|
+
LoginUser._UserGroupRepository = new user_group_repository_1.UserGroupRepository(dbTransaction);
|
47
|
+
}
|
48
|
+
if (userInfo) {
|
49
|
+
this.ObjectId = userInfo.ObjectId;
|
50
|
+
this.FullName = userInfo.FullName;
|
51
|
+
this.IDNo = userInfo.IDNo;
|
52
|
+
this.Email = userInfo.Email;
|
53
|
+
this.ContactNo = userInfo.ContactNo;
|
54
|
+
this.Password = userInfo.Password;
|
55
|
+
this.staffs = userInfo.staffs;
|
56
|
+
}
|
57
|
+
}
|
58
|
+
static init(userId, dbTransaction = null) {
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
60
|
+
const sessionService = yield session_service_1.SessionService.init();
|
61
|
+
if (userId) {
|
62
|
+
if (dbTransaction) {
|
63
|
+
LoginUser._Repository = new user_repository_1.UserRepository(dbTransaction);
|
64
|
+
}
|
65
|
+
const user = yield LoginUser._Repository.findOne({
|
66
|
+
where: {
|
67
|
+
id: Number(userId),
|
68
|
+
},
|
69
|
+
include: {
|
70
|
+
staffs: true,
|
71
|
+
userSystemPrivileges: {
|
72
|
+
include: {
|
73
|
+
systemPrivilege: true,
|
74
|
+
},
|
75
|
+
},
|
76
|
+
},
|
77
|
+
});
|
78
|
+
if (user) {
|
79
|
+
const userInfo = {
|
80
|
+
ObjectId: user.id,
|
81
|
+
FullName: user.staffs[0].name,
|
82
|
+
IDNo: user.staffs[0].idNo,
|
83
|
+
ContactNo: user.staffs[0].contactNo,
|
84
|
+
Email: user.staffs[0].email,
|
85
|
+
Password: user.password,
|
86
|
+
staffs: user.staffs[0],
|
87
|
+
};
|
88
|
+
return new LoginUser(sessionService, dbTransaction, userInfo);
|
89
|
+
}
|
90
|
+
else {
|
91
|
+
throw new Error('User not found');
|
92
|
+
}
|
93
|
+
}
|
94
|
+
return new LoginUser(sessionService, dbTransaction);
|
95
|
+
});
|
96
|
+
}
|
97
|
+
login(systemCode, email, password, ipAddress) {
|
98
|
+
return __awaiter(this, void 0, void 0, function* () {
|
99
|
+
if (this.Email !== email) {
|
100
|
+
throw new Error('Invalid credentials.');
|
101
|
+
}
|
102
|
+
const isPasswordValid = yield this._PasswordHashService.verify(password, this.Password);
|
103
|
+
if (!isPasswordValid) {
|
104
|
+
throw new Error('Invalid credentials.');
|
105
|
+
}
|
106
|
+
const system = yield LoginUser._SystemRepository.findOne({
|
107
|
+
where: {
|
108
|
+
code: systemCode,
|
109
|
+
},
|
110
|
+
});
|
111
|
+
if (!system) {
|
112
|
+
throw new Error('Invalid system code.');
|
113
|
+
}
|
114
|
+
yield this.checkSystemAccess(this.ObjectId, system.id);
|
115
|
+
yield this.alertNewLogin(this.ObjectId, system.id, ipAddress);
|
116
|
+
const userSession = yield this._SessionService.retrieveUserSession(this.ObjectId);
|
117
|
+
let systemLogin = userSession.systemLogins.find((system) => system.code === systemCode);
|
118
|
+
const { randomUUID } = require('crypto');
|
119
|
+
const sessionId = randomUUID();
|
120
|
+
if (systemLogin) {
|
121
|
+
systemLogin = systemLogin.sessionId = sessionId;
|
122
|
+
userSession.systemLogins.map((system) => system.code === systemCode ? systemLogin : system);
|
123
|
+
}
|
124
|
+
else {
|
125
|
+
const newLogin = {
|
126
|
+
id: system.id.toString(),
|
127
|
+
code: system.code,
|
128
|
+
sessionId: sessionId,
|
129
|
+
privileges: yield this.getPrivileges(system.code),
|
130
|
+
};
|
131
|
+
userSession.systemLogins.push(newLogin);
|
132
|
+
}
|
133
|
+
this._SessionService.setUserSession(this.ObjectId, userSession);
|
134
|
+
yield LoginUser._LoginHistoryRepository.create({
|
135
|
+
data: {
|
136
|
+
userId: this.ObjectId,
|
137
|
+
systemId: system.id,
|
138
|
+
originIp: ipAddress,
|
139
|
+
createdAt: new Date(),
|
140
|
+
},
|
141
|
+
});
|
142
|
+
return sessionId;
|
143
|
+
});
|
144
|
+
}
|
145
|
+
checkSystemAccess(userId, systemId) {
|
146
|
+
return __awaiter(this, void 0, void 0, function* () {
|
147
|
+
const systemAccess = yield LoginUser._SystemAccessRepository.findOne({
|
148
|
+
where: {
|
149
|
+
userId: userId,
|
150
|
+
systemId: systemId,
|
151
|
+
},
|
152
|
+
});
|
153
|
+
if (!systemAccess) {
|
154
|
+
throw new Error("User don't have access to the system.");
|
155
|
+
}
|
156
|
+
});
|
157
|
+
}
|
158
|
+
alertNewLogin(userId, systemId, ipAddress) {
|
159
|
+
return __awaiter(this, void 0, void 0, function* () {
|
160
|
+
const userLogins = yield LoginUser._LoginHistoryRepository.findAll({
|
161
|
+
where: {
|
162
|
+
userId: userId,
|
163
|
+
systemId: systemId,
|
164
|
+
},
|
165
|
+
});
|
166
|
+
const gotPreviousLogins = (userLogins === null || userLogins === void 0 ? void 0 : userLogins.length) !== 0;
|
167
|
+
let ipFound = null;
|
168
|
+
if (gotPreviousLogins) {
|
169
|
+
ipFound = userLogins.find((item) => item.ipAddress === ipAddress);
|
170
|
+
}
|
171
|
+
if (gotPreviousLogins && !ipFound) {
|
172
|
+
yield this._MailService.sendNewLoginAlertEmail({
|
173
|
+
IpAddress: ipAddress,
|
174
|
+
Email: this.Email,
|
175
|
+
Name: this.FullName,
|
176
|
+
LoginDate: new Date(),
|
177
|
+
});
|
178
|
+
}
|
179
|
+
});
|
180
|
+
}
|
181
|
+
getPrivileges(systemCode) {
|
182
|
+
return __awaiter(this, void 0, void 0, function* () {
|
183
|
+
try {
|
184
|
+
const system = yield LoginUser._SystemRepository.findOne({
|
185
|
+
where: {
|
186
|
+
code: systemCode,
|
187
|
+
},
|
188
|
+
});
|
189
|
+
if (!system) {
|
190
|
+
throw new Error('Invalid system code.');
|
191
|
+
}
|
192
|
+
const userUserGroups = yield this.getUserUserGroupFromDB(system.id);
|
193
|
+
const userGroupData = userUserGroups.map((u) => u.userGroup);
|
194
|
+
let privileges = [];
|
195
|
+
for (const userGroup of userGroupData) {
|
196
|
+
const groupSystemPrivileges = userGroup.groupSystemPrivileges.map((g) => g.systemPrivilege.code);
|
197
|
+
const groupRolePrivileges = userGroup.groupRolePrivileges.map((g) => g.systemPrivilege.code);
|
198
|
+
if (userGroup.groupLevel !== 0) {
|
199
|
+
const parentTreePrivileges = yield this.getPrivilegesFromUserGroup(userGroup.parentCode);
|
200
|
+
privileges = [...privileges, ...parentTreePrivileges];
|
201
|
+
}
|
202
|
+
privileges = [
|
203
|
+
...privileges,
|
204
|
+
...groupSystemPrivileges,
|
205
|
+
...groupRolePrivileges,
|
206
|
+
];
|
207
|
+
}
|
208
|
+
const userPrivileges = yield this.getUserPersonalPrivileges(system.id);
|
209
|
+
privileges = [...privileges, ...userPrivileges];
|
210
|
+
privileges = [...new Set(privileges)];
|
211
|
+
return privileges;
|
212
|
+
}
|
213
|
+
catch (error) {
|
214
|
+
throw error;
|
215
|
+
}
|
216
|
+
});
|
217
|
+
}
|
218
|
+
getPrivilegesFromUserGroup(groupCode) {
|
219
|
+
return __awaiter(this, void 0, void 0, function* () {
|
220
|
+
try {
|
221
|
+
const userGroup = yield this.getUserGroupFromDB(groupCode);
|
222
|
+
let privileges = [];
|
223
|
+
privileges = [
|
224
|
+
...privileges,
|
225
|
+
...userGroup.groupSystemPrivileges.map((g) => g.systemPrivilege.code),
|
226
|
+
...userGroup.groupRolePrivileges.map((g) => g.systemPrivilege.code),
|
227
|
+
];
|
228
|
+
const isContinue = userGroup.groupLevel !== 0 &&
|
229
|
+
userGroup.allowInheritFromParentYN === 'Y';
|
230
|
+
if (isContinue) {
|
231
|
+
const recursivePrivileges = yield this.getPrivilegesFromUserGroup(userGroup.parentGroupCode);
|
232
|
+
privileges = privileges.concat(recursivePrivileges);
|
233
|
+
}
|
234
|
+
return privileges;
|
235
|
+
}
|
236
|
+
catch (error) {
|
237
|
+
throw error;
|
238
|
+
}
|
239
|
+
});
|
240
|
+
}
|
241
|
+
getUserGroupFromDB(groupCode) {
|
242
|
+
return __awaiter(this, void 0, void 0, function* () {
|
243
|
+
try {
|
244
|
+
const userGroup = yield LoginUser._UserGroupRepository.findOne({
|
245
|
+
where: {
|
246
|
+
groupCode: groupCode,
|
247
|
+
},
|
248
|
+
include: {
|
249
|
+
groupSystemPrivileges: {
|
250
|
+
include: {
|
251
|
+
systemPrivilege: true,
|
252
|
+
},
|
253
|
+
},
|
254
|
+
groupRolePrivileges: {
|
255
|
+
include: {
|
256
|
+
systemPrivilege: true,
|
257
|
+
},
|
258
|
+
},
|
259
|
+
},
|
260
|
+
});
|
261
|
+
return userGroup;
|
262
|
+
}
|
263
|
+
catch (error) {
|
264
|
+
throw error;
|
265
|
+
}
|
266
|
+
});
|
267
|
+
}
|
268
|
+
getUserUserGroupFromDB(systemCode) {
|
269
|
+
return __awaiter(this, void 0, void 0, function* () {
|
270
|
+
try {
|
271
|
+
return yield LoginUser._UserUserGroupRepository.findAll({
|
272
|
+
where: {
|
273
|
+
userId: this.ObjectId,
|
274
|
+
systemId: systemCode,
|
275
|
+
},
|
276
|
+
include: {
|
277
|
+
userGroup: {
|
278
|
+
include: {
|
279
|
+
groupSystemPrivileges: {
|
280
|
+
include: {
|
281
|
+
systemPrivilege: true,
|
282
|
+
},
|
283
|
+
},
|
284
|
+
groupRolePrivileges: {
|
285
|
+
include: {
|
286
|
+
systemPrivilege: true,
|
287
|
+
},
|
288
|
+
},
|
289
|
+
},
|
290
|
+
},
|
291
|
+
},
|
292
|
+
});
|
293
|
+
}
|
294
|
+
catch (error) {
|
295
|
+
throw error;
|
296
|
+
}
|
297
|
+
});
|
298
|
+
}
|
299
|
+
getUserPersonalPrivileges(systemId) {
|
300
|
+
return __awaiter(this, void 0, void 0, function* () {
|
301
|
+
try {
|
302
|
+
const userRole = yield LoginUser._Repository.findOne({
|
303
|
+
where: {
|
304
|
+
id: this.ObjectId,
|
305
|
+
},
|
306
|
+
include: {
|
307
|
+
userSystemPrivileges: {
|
308
|
+
include: {
|
309
|
+
systemPrivilege: true,
|
310
|
+
},
|
311
|
+
},
|
312
|
+
},
|
313
|
+
});
|
314
|
+
let userSystemPrivileges = userRole.userSystemPrivileges.map((u) => u.systemPrivilege);
|
315
|
+
userSystemPrivileges = userRole.userSystemPrivileges.filter((u) => u.systemPrivilege.systemId === systemId);
|
316
|
+
const userPrivileges = userSystemPrivileges.map((u) => u.code);
|
317
|
+
return userPrivileges;
|
318
|
+
}
|
319
|
+
catch (error) {
|
320
|
+
throw error;
|
321
|
+
}
|
322
|
+
});
|
323
|
+
}
|
324
|
+
}
|
325
|
+
exports.LoginUser = LoginUser;
|
326
|
+
LoginUser._Repository = new user_repository_1.UserRepository();
|
327
|
+
LoginUser._SystemRepository = new system_repository_1.SystemRepository();
|
328
|
+
LoginUser._SystemAccessRepository = new system_access_repository_1.SystemAccessRepository();
|
329
|
+
LoginUser._LoginHistoryRepository = new login_history_repository_1.LoginHistoryRepository();
|
330
|
+
LoginUser._UserUserGroupRepository = new user_user_group_repository_1.UserUserGroupRepository();
|
331
|
+
LoginUser._UserGroupRepository = new user_group_repository_1.UserGroupRepository();
|
332
|
+
//# sourceMappingURL=login-user.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"login-user.js","sourceRoot":"","sources":["../../../../src/components/login-user/login-user.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAA+D;AAI/D,uDAAmD;AACnD,mEAA+D;AAC/D,wFAAmF;AACnF,wFAAmF;AACnF,0DAAsD;AACtD,8FAAwF;AACxF,kFAA6E;AAC7E,mEAA+D;AAC/D,+EAA0E;AAE1E,MAAa,SAAU,SAAQ,oBAAU;IAwBvC,UAAU;QAOR,OAAO;YACL,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC;IACJ,CAAC;IAED,YACE,cAA+B,EAC/B,aAAmB,EACnB,QAAoB;QAEpB,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UserRepository {
|
2
|
+
private _prisma;
|
3
|
+
constructor(client?: any);
|
4
|
+
create(data: any): Promise<any>;
|
5
|
+
findAll(options: any): Promise<any[]>;
|
6
|
+
findOne(options: any): Promise<any>;
|
7
|
+
update(where: any, data: any): Promise<any>;
|
8
|
+
delete(where: any): Promise<any>;
|
9
|
+
}
|
@@ -0,0 +1,50 @@
|
|
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.UserRepository = void 0;
|
13
|
+
const client_1 = require("../../prisma-client/client");
|
14
|
+
class UserRepository {
|
15
|
+
constructor(client) {
|
16
|
+
if (client) {
|
17
|
+
this._prisma = client;
|
18
|
+
}
|
19
|
+
else {
|
20
|
+
this._prisma = client_1.default;
|
21
|
+
}
|
22
|
+
}
|
23
|
+
create(data) {
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
25
|
+
return yield this._prisma.user.create(data);
|
26
|
+
});
|
27
|
+
}
|
28
|
+
findAll(options) {
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
30
|
+
return yield this._prisma.user.findMany(options);
|
31
|
+
});
|
32
|
+
}
|
33
|
+
findOne(options) {
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
35
|
+
return yield this._prisma.user.findFirst(options);
|
36
|
+
});
|
37
|
+
}
|
38
|
+
update(where, data) {
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
40
|
+
return yield this._prisma.user.update(where, data);
|
41
|
+
});
|
42
|
+
}
|
43
|
+
delete(where) {
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
45
|
+
return yield this._prisma.user.delete(where);
|
46
|
+
});
|
47
|
+
}
|
48
|
+
}
|
49
|
+
exports.UserRepository = UserRepository;
|
50
|
+
//# sourceMappingURL=user.repository.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"user.repository.js","sourceRoot":"","sources":["../../../../src/components/login-user/user.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAAgD;AAEhD,MAAa,cAAc;IAGzB,YAAY,MAAY;QACtB,IAAI,MAAM,EAAE;YACV,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;SACvB;aAAM;YACL,IAAI,CAAC,OAAO,GAAG,gBAAM,CAAC;SACvB;IACH,CAAC;IAEY,MAAM,CAAC,IAAS;;YAC3B,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9C,CAAC;KAAA;IAEY,OAAO,CAAC,OAAY;;YAC/B,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACnD,CAAC;KAAA;IAEY,OAAO,CAAC,OAAY;;YAC/B,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACpD,CAAC;KAAA;IAEY,MAAM,CAAC,KAAU,EAAE,IAAS;;YACvC,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACrD,CAAC;KAAA;IAEY,MAAM,CAAC,KAAU;;YAC5B,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC/C,CAAC;KAAA;CACF;AA9BD,wCA8BC"}
|
@@ -0,0 +1,19 @@
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./interfaces"), exports);
|
18
|
+
__exportStar(require("./password-hash.service"), exports);
|
19
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/password-hash/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,0DAAwC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './password-hash-service.interface';
|
@@ -0,0 +1,18 @@
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./password-hash-service.interface"), exports);
|
18
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/password-hash/interfaces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oEAAkD"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"password-hash-service.interface.js","sourceRoot":"","sources":["../../../../../src/components/password-hash/interfaces/password-hash-service.interface.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import { IPasswordHashService } from './interfaces/password-hash-service.interface';
|
2
|
+
export declare class PasswordHashService implements IPasswordHashService {
|
3
|
+
constructor();
|
4
|
+
hashPassword(password: string): Promise<string>;
|
5
|
+
verify(password: string, hash: string): Promise<boolean>;
|
6
|
+
}
|
@@ -0,0 +1,28 @@
|
|
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.PasswordHashService = void 0;
|
13
|
+
const argon2 = require("argon2");
|
14
|
+
class PasswordHashService {
|
15
|
+
constructor() { }
|
16
|
+
hashPassword(password) {
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
18
|
+
return yield argon2.hash(password);
|
19
|
+
});
|
20
|
+
}
|
21
|
+
verify(password, hash) {
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
23
|
+
return yield argon2.verify(hash, password);
|
24
|
+
});
|
25
|
+
}
|
26
|
+
}
|
27
|
+
exports.PasswordHashService = PasswordHashService;
|
28
|
+
//# sourceMappingURL=password-hash.service.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"password-hash.service.js","sourceRoot":"","sources":["../../../../src/components/password-hash/password-hash.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iCAAiC;AAGjC,MAAa,mBAAmB;IAC9B,gBAAe,CAAC;IAEV,YAAY,CAAC,QAAgB;;YACjC,OAAO,MAAM,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACrC,CAAC;KAAA;IAEK,MAAM,CAAC,QAAgB,EAAE,IAAY;;YACzC,OAAO,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC7C,CAAC;KAAA;CACF;AAVD,kDAUC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './system.repository';
|
@@ -0,0 +1,18 @@
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./system.repository"), exports);
|
18
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/system/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
export declare class SystemRepository {
|
2
|
+
private _prisma;
|
3
|
+
constructor(client?: any);
|
4
|
+
create(data: any): Promise<any>;
|
5
|
+
findAll(options: any): Promise<any[]>;
|
6
|
+
findOne(options: any): Promise<any>;
|
7
|
+
update(where: any, data: any): Promise<any>;
|
8
|
+
delete(where: any): Promise<any>;
|
9
|
+
}
|
@@ -0,0 +1,50 @@
|
|
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.SystemRepository = void 0;
|
13
|
+
const client_1 = require("../../prisma-client/client");
|
14
|
+
class SystemRepository {
|
15
|
+
constructor(client) {
|
16
|
+
if (client) {
|
17
|
+
this._prisma = client;
|
18
|
+
}
|
19
|
+
else {
|
20
|
+
this._prisma = client_1.default;
|
21
|
+
}
|
22
|
+
}
|
23
|
+
create(data) {
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
25
|
+
return yield this._prisma.system.create(data);
|
26
|
+
});
|
27
|
+
}
|
28
|
+
findAll(options) {
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
30
|
+
return yield this._prisma.system.findMany(options);
|
31
|
+
});
|
32
|
+
}
|
33
|
+
findOne(options) {
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
35
|
+
return yield this._prisma.system.findFirst(options);
|
36
|
+
});
|
37
|
+
}
|
38
|
+
update(where, data) {
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
40
|
+
return yield this._prisma.system.update(where, data);
|
41
|
+
});
|
42
|
+
}
|
43
|
+
delete(where) {
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
45
|
+
return yield this._prisma.system.delete(where);
|
46
|
+
});
|
47
|
+
}
|
48
|
+
}
|
49
|
+
exports.SystemRepository = SystemRepository;
|
50
|
+
//# sourceMappingURL=system.repository.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"system.repository.js","sourceRoot":"","sources":["../../../../src/components/system/system.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAAgD;AAEhD,MAAa,gBAAgB;IAG3B,YAAY,MAAY;QACtB,IAAI,MAAM,EAAE;YACV,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;SACvB;aAAM;YACL,IAAI,CAAC,OAAO,GAAG,gBAAM,CAAC;SACvB;IACH,CAAC;IAEY,MAAM,CAAC,IAAS;;YAC3B,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAChD,CAAC;KAAA;IAEY,OAAO,CAAC,OAAY;;YAC/B,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACrD,CAAC;KAAA;IAEY,OAAO,CAAC,OAAY;;YAC/B,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACtD,CAAC;KAAA;IAEY,MAAM,CAAC,KAAU,EAAE,IAAS;;YACvC,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACvD,CAAC;KAAA;IAEY,MAAM,CAAC,KAAU;;YAC5B,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACjD,CAAC;KAAA;CACF;AA9BD,4CA8BC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './system-access.repository';
|
@@ -0,0 +1,18 @@
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./system-access.repository"), exports);
|
18
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/system-access/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6DAA2C"}
|