@smartsoft001/auth-shell-app-services 2.147.0 → 2.149.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/package.json +9 -2
- package/src/index.d.ts +1 -1
- package/src/index.js +5 -0
- package/src/index.js.map +1 -0
- package/src/lib/services/auth/auth.service.js +65 -0
- package/src/lib/services/auth/auth.service.js.map +1 -0
- package/src/lib/services/index.js +8 -0
- package/src/lib/services/index.js.map +1 -0
- package/test-setup.js +2 -0
- package/test-setup.js.map +1 -0
- package/index.js +0 -318
package/package.json
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smartsoft001/auth-shell-app-services",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.149.0",
|
|
4
|
+
"type": "commonjs",
|
|
5
|
+
"main": "./src/index.js",
|
|
6
|
+
"typings": "./src/index.d.ts",
|
|
4
7
|
"publishConfig": {
|
|
5
8
|
"access": "public"
|
|
6
9
|
},
|
|
@@ -15,5 +18,9 @@
|
|
|
15
18
|
"nestjs"
|
|
16
19
|
],
|
|
17
20
|
"author": "Emil Juchnikowski",
|
|
18
|
-
"license": "MIT"
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"@smartsoft001/auth-domain": "2.149.0"
|
|
24
|
+
},
|
|
25
|
+
"types": "./src/index.d.ts"
|
|
19
26
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './lib/services
|
|
1
|
+
export * from './lib/services';
|
package/src/index.js
ADDED
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/auth/shell/app-services/src/index.ts"],"names":[],"mappings":";;;AAAA,yDAA+B"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var AuthService_1;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.AuthService = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const common_1 = require("@nestjs/common");
|
|
7
|
+
const core_1 = require("@nestjs/core");
|
|
8
|
+
const auth_domain_1 = require("@smartsoft001/auth-domain");
|
|
9
|
+
let AuthService = AuthService_1 = class AuthService {
|
|
10
|
+
factory;
|
|
11
|
+
moduleRef;
|
|
12
|
+
constructor(factory, moduleRef) {
|
|
13
|
+
this.factory = factory;
|
|
14
|
+
this.moduleRef = moduleRef;
|
|
15
|
+
}
|
|
16
|
+
create(req, httpReq) {
|
|
17
|
+
return this.factory.create({
|
|
18
|
+
httpReq: httpReq,
|
|
19
|
+
request: req,
|
|
20
|
+
payloadProvider: this.getPayloadProvider(),
|
|
21
|
+
validationProvider: this.getValidationProvider(),
|
|
22
|
+
userProvider: this.getUserProvider(),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
getPayloadProvider() {
|
|
26
|
+
try {
|
|
27
|
+
return this.moduleRef.get(auth_domain_1.AUTH_TOKEN_PAYLOAD_PROVIDER, {
|
|
28
|
+
strict: false,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
common_1.Logger.debug(e.message, AuthService_1.name);
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
getValidationProvider() {
|
|
37
|
+
try {
|
|
38
|
+
return this.moduleRef.get(auth_domain_1.AUTH_TOKEN_VALIDATION_PROVIDER, {
|
|
39
|
+
strict: false,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
common_1.Logger.debug(e.message, AuthService_1.name);
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
getUserProvider() {
|
|
48
|
+
try {
|
|
49
|
+
return this.moduleRef.get(auth_domain_1.AUTH_TOKEN_USER_PROVIDER, {
|
|
50
|
+
strict: false,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
common_1.Logger.debug(e.message, AuthService_1.name);
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
exports.AuthService = AuthService;
|
|
60
|
+
exports.AuthService = AuthService = AuthService_1 = tslib_1.__decorate([
|
|
61
|
+
(0, common_1.Injectable)(),
|
|
62
|
+
tslib_1.__metadata("design:paramtypes", [auth_domain_1.TokenFactory,
|
|
63
|
+
core_1.ModuleRef])
|
|
64
|
+
], AuthService);
|
|
65
|
+
//# sourceMappingURL=auth.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../../../../../../../../../packages/auth/shell/app-services/src/lib/services/auth/auth.service.ts"],"names":[],"mappings":";;;;;AAAA,2CAAoD;AACpD,uCAAyC;AAGzC,2DAUmC;AAG5B,IAAM,WAAW,mBAAjB,MAAM,WAAW;IAEZ;IACA;IAFV,YACU,OAAqB,EACrB,SAAoB;QADpB,YAAO,GAAP,OAAO,CAAc;QACrB,cAAS,GAAT,SAAS,CAAW;IAC3B,CAAC;IAEJ,MAAM,CAAC,GAAsB,EAAE,OAAiB;QAC9C,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;YACzB,OAAO,EAAE,OAAO;YAChB,OAAO,EAAE,GAAG;YACZ,eAAe,EAAE,IAAI,CAAC,kBAAkB,EAAE;YAC1C,kBAAkB,EAAE,IAAI,CAAC,qBAAqB,EAAE;YAChD,YAAY,EAAE,IAAI,CAAC,eAAe,EAAE;SACrC,CAAwB,CAAC;IAC5B,CAAC;IAEO,kBAAkB;QACxB,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,yCAA2B,EAAE;gBACrD,MAAM,EAAE,KAAK;aACd,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,eAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,aAAW,CAAC,IAAI,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,qBAAqB;QAC3B,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,4CAA8B,EAAE;gBACxD,MAAM,EAAE,KAAK;aACd,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,eAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,aAAW,CAAC,IAAI,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,eAAe;QACrB,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,sCAAwB,EAAE;gBAClD,MAAM,EAAE,KAAK;aACd,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,eAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,aAAW,CAAC,IAAI,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAhDY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;6CAGQ,0BAAY;QACV,gBAAS;GAHnB,WAAW,CAgDvB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SERVICES = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const auth_service_1 = require("./auth/auth.service");
|
|
6
|
+
tslib_1.__exportStar(require("./auth/auth.service"), exports);
|
|
7
|
+
exports.SERVICES = [auth_service_1.AuthService];
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/auth/shell/app-services/src/lib/services/index.ts"],"names":[],"mappings":";;;;AAAA,sDAAkD;AAElD,8DAAoC;AAEvB,QAAA,QAAQ,GAAG,CAAC,0BAAW,CAAC,CAAC"}
|
package/test-setup.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-setup.js","sourceRoot":"","sources":["../../../../../packages/auth/shell/app-services/test-setup.ts"],"names":[],"mappings":""}
|
package/index.js
DELETED
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
-
if (decorator = decorators[i])
|
|
7
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
-
if (kind && result) __defProp(target, key, result);
|
|
9
|
-
return result;
|
|
10
|
-
};
|
|
11
|
-
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
12
|
-
|
|
13
|
-
// packages/auth/shell/app-services/src/lib/services/auth/auth.service.ts
|
|
14
|
-
import { Injectable as Injectable3, Logger } from "@nestjs/common";
|
|
15
|
-
|
|
16
|
-
// packages/auth/domain/src/lib/entities/user.entity.ts
|
|
17
|
-
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
|
|
18
|
-
var User = class {
|
|
19
|
-
id;
|
|
20
|
-
permissions;
|
|
21
|
-
username;
|
|
22
|
-
password;
|
|
23
|
-
disabled;
|
|
24
|
-
lastLoginDate;
|
|
25
|
-
authRefreshToken;
|
|
26
|
-
facebookUserId;
|
|
27
|
-
googleUserId;
|
|
28
|
-
};
|
|
29
|
-
__decorateClass([
|
|
30
|
-
PrimaryGeneratedColumn()
|
|
31
|
-
], User.prototype, "id", 2);
|
|
32
|
-
__decorateClass([
|
|
33
|
-
Column("permissions")
|
|
34
|
-
], User.prototype, "permissions", 2);
|
|
35
|
-
__decorateClass([
|
|
36
|
-
Column("username")
|
|
37
|
-
], User.prototype, "username", 2);
|
|
38
|
-
__decorateClass([
|
|
39
|
-
Column("password")
|
|
40
|
-
], User.prototype, "password", 2);
|
|
41
|
-
__decorateClass([
|
|
42
|
-
Column("disabled")
|
|
43
|
-
], User.prototype, "disabled", 2);
|
|
44
|
-
__decorateClass([
|
|
45
|
-
Column("lastLoginDate")
|
|
46
|
-
], User.prototype, "lastLoginDate", 2);
|
|
47
|
-
__decorateClass([
|
|
48
|
-
Column("authRefreshToken")
|
|
49
|
-
], User.prototype, "authRefreshToken", 2);
|
|
50
|
-
__decorateClass([
|
|
51
|
-
Column("facebookUserId")
|
|
52
|
-
], User.prototype, "facebookUserId", 2);
|
|
53
|
-
__decorateClass([
|
|
54
|
-
Column("googleUserId")
|
|
55
|
-
], User.prototype, "googleUserId", 2);
|
|
56
|
-
User = __decorateClass([
|
|
57
|
-
Entity("users")
|
|
58
|
-
], User);
|
|
59
|
-
|
|
60
|
-
// packages/auth/domain/src/lib/feature-create-token/token.factory.ts
|
|
61
|
-
import { Injectable } from "@nestjs/common";
|
|
62
|
-
import { InjectRepository } from "@nestjs/typeorm";
|
|
63
|
-
import { Guid as Guid2 } from "guid-typescript";
|
|
64
|
-
|
|
65
|
-
// packages/shared/models/src/lib/decorators/model/model.decorator.ts
|
|
66
|
-
import "reflect-metadata";
|
|
67
|
-
|
|
68
|
-
// packages/shared/models/src/lib/decorators/field/field.decorator.ts
|
|
69
|
-
import "reflect-metadata";
|
|
70
|
-
|
|
71
|
-
// packages/shared/utils/src/lib/services/array/array.service.ts
|
|
72
|
-
import * as _ from "lodash";
|
|
73
|
-
|
|
74
|
-
// packages/shared/utils/src/lib/services/guid/guid.service.ts
|
|
75
|
-
import { Guid } from "guid-typescript";
|
|
76
|
-
|
|
77
|
-
// packages/shared/utils/src/lib/services/object/object.service.ts
|
|
78
|
-
import { stringify } from "flatted";
|
|
79
|
-
|
|
80
|
-
// packages/shared/utils/src/lib/services/password/password.service.ts
|
|
81
|
-
import md5 from "md5";
|
|
82
|
-
var PasswordService = class _PasswordService {
|
|
83
|
-
/**
|
|
84
|
-
* Hash password text
|
|
85
|
-
* @param p {string} - text
|
|
86
|
-
* @return - hashed text
|
|
87
|
-
*/
|
|
88
|
-
static hash(p) {
|
|
89
|
-
return Promise.resolve(md5(p));
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Compare password text with hashed text
|
|
93
|
-
* @param p {string} - password text
|
|
94
|
-
* @param h {string} - hashed text
|
|
95
|
-
*/
|
|
96
|
-
static async compare(p, h) {
|
|
97
|
-
const hp = await _PasswordService.hash(p);
|
|
98
|
-
return hp === h;
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
// packages/shared/domain-core/src/lib/errors.ts
|
|
103
|
-
var DomainValidationError = class _DomainValidationError extends Error {
|
|
104
|
-
type = _DomainValidationError;
|
|
105
|
-
constructor(msg) {
|
|
106
|
-
super(msg);
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
// packages/auth/domain/src/lib/feature-create-token/token.factory.ts
|
|
111
|
-
var TokenFactory = class {
|
|
112
|
-
constructor(config, repository, jwtService, fbService, googleService) {
|
|
113
|
-
this.config = config;
|
|
114
|
-
this.repository = repository;
|
|
115
|
-
this.jwtService = jwtService;
|
|
116
|
-
this.fbService = fbService;
|
|
117
|
-
this.googleService = googleService;
|
|
118
|
-
}
|
|
119
|
-
config;
|
|
120
|
-
repository;
|
|
121
|
-
jwtService;
|
|
122
|
-
fbService;
|
|
123
|
-
googleService;
|
|
124
|
-
_invalidUsernameOrPasswordMessage = "Invalid username or password";
|
|
125
|
-
static getQuery(config, customProvider = false) {
|
|
126
|
-
switch (config.grant_type) {
|
|
127
|
-
case "fb":
|
|
128
|
-
return { facebookUserId: config.fb_user_id };
|
|
129
|
-
case "google":
|
|
130
|
-
return { googleUserId: config.google_user_id };
|
|
131
|
-
case "password":
|
|
132
|
-
return { username: config.username };
|
|
133
|
-
case "refresh_token":
|
|
134
|
-
return { authRefreshToken: config.refresh_token };
|
|
135
|
-
default:
|
|
136
|
-
if (!customProvider) {
|
|
137
|
-
throw new DomainValidationError("Invalid grand type");
|
|
138
|
-
}
|
|
139
|
-
return null;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
static checkDisabled(user) {
|
|
143
|
-
if (user.disabled) throw new DomainValidationError("user disabled");
|
|
144
|
-
}
|
|
145
|
-
async create(options) {
|
|
146
|
-
if (options.request.grant_type === "fb") {
|
|
147
|
-
options.request.fb_user_id = await this.fbService.getUserId(
|
|
148
|
-
options.request.fb_token
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
if (options.request.grant_type === "google") {
|
|
152
|
-
options.request.google_user_id = await this.googleService.getUserId(
|
|
153
|
-
options.request.google_token
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
this.valid(options.request);
|
|
157
|
-
const query = TokenFactory.getQuery(
|
|
158
|
-
options.request,
|
|
159
|
-
!!options.userProvider
|
|
160
|
-
);
|
|
161
|
-
const user = options.userProvider ? await options.userProvider.get(query, options.request, options.httpReq) : await this.repository.findOne(query);
|
|
162
|
-
if (!options.validationProvider || !options.validationProvider.replace) {
|
|
163
|
-
this.checkUser(options.request, user);
|
|
164
|
-
TokenFactory.checkDisabled(user);
|
|
165
|
-
await this.checkPassword(options.request, user);
|
|
166
|
-
}
|
|
167
|
-
if (options.validationProvider) {
|
|
168
|
-
await options.validationProvider.check({
|
|
169
|
-
request: options.request,
|
|
170
|
-
user
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
const refreshToken = Guid2.raw();
|
|
174
|
-
await this.repository.update(
|
|
175
|
-
{
|
|
176
|
-
...query,
|
|
177
|
-
disabled: { $ne: true }
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
lastLoginDate: /* @__PURE__ */ new Date(),
|
|
181
|
-
authRefreshToken: refreshToken
|
|
182
|
-
}
|
|
183
|
-
);
|
|
184
|
-
const payload = {
|
|
185
|
-
permissions: user.permissions,
|
|
186
|
-
scope: options.request.scope
|
|
187
|
-
};
|
|
188
|
-
if (options.payloadProvider) {
|
|
189
|
-
await options.payloadProvider.change(payload, {
|
|
190
|
-
user,
|
|
191
|
-
request: options.request,
|
|
192
|
-
httpReq: options.httpReq
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
return {
|
|
196
|
-
expired_in: this.config.expiredIn,
|
|
197
|
-
token_type: "bearer",
|
|
198
|
-
access_token: this.jwtService.sign(payload, {
|
|
199
|
-
expiresIn: this.config.expiredIn,
|
|
200
|
-
subject: user.username
|
|
201
|
-
}),
|
|
202
|
-
refresh_token: refreshToken,
|
|
203
|
-
username: user.username
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
checkUser(config, user) {
|
|
207
|
-
if (!user)
|
|
208
|
-
throw new DomainValidationError(
|
|
209
|
-
config.grant_type === "password" ? this._invalidUsernameOrPasswordMessage : "Invalid token"
|
|
210
|
-
);
|
|
211
|
-
}
|
|
212
|
-
async checkPassword(config, user) {
|
|
213
|
-
if (config.grant_type === "password" && !await PasswordService.compare(config.password, user.password))
|
|
214
|
-
throw new DomainValidationError(this._invalidUsernameOrPasswordMessage);
|
|
215
|
-
}
|
|
216
|
-
valid(req) {
|
|
217
|
-
if (!req) throw new DomainValidationError("config is empty");
|
|
218
|
-
if (!req.grant_type) throw new DomainValidationError("grant_type is empty");
|
|
219
|
-
if (req.grant_type === "password") {
|
|
220
|
-
if (!req.username) throw new DomainValidationError("username is empty");
|
|
221
|
-
if (!req.password) throw new DomainValidationError("password is empty");
|
|
222
|
-
if (!req.client_id) throw new DomainValidationError("client_id is empty");
|
|
223
|
-
if (!this.config.clients.some((c) => c === req.client_id))
|
|
224
|
-
throw new DomainValidationError("client_id is incorrect");
|
|
225
|
-
} else if (req.grant_type === "refresh_token") {
|
|
226
|
-
if (!req.refresh_token)
|
|
227
|
-
throw new DomainValidationError("refresh_token is empty");
|
|
228
|
-
} else if (req.grant_type === "fb") {
|
|
229
|
-
if (!req.fb_token) throw new DomainValidationError("fb_token is empty");
|
|
230
|
-
if (!req.fb_user_id)
|
|
231
|
-
throw new DomainValidationError("fb_user_id is empty");
|
|
232
|
-
} else if (req.grant_type === "google") {
|
|
233
|
-
if (!req.google_token)
|
|
234
|
-
throw new DomainValidationError("google_token is empty");
|
|
235
|
-
if (!req.google_user_id)
|
|
236
|
-
throw new DomainValidationError("google_user_id is empty");
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
};
|
|
240
|
-
TokenFactory = __decorateClass([
|
|
241
|
-
Injectable(),
|
|
242
|
-
__decorateParam(1, InjectRepository(User))
|
|
243
|
-
], TokenFactory);
|
|
244
|
-
|
|
245
|
-
// packages/auth/domain/src/lib/feature-create-token/token.config.ts
|
|
246
|
-
import { Injectable as Injectable2 } from "@nestjs/common";
|
|
247
|
-
var TokenConfig = class {
|
|
248
|
-
expiredIn;
|
|
249
|
-
clients = [];
|
|
250
|
-
secretOrPrivateKey;
|
|
251
|
-
};
|
|
252
|
-
TokenConfig = __decorateClass([
|
|
253
|
-
Injectable2()
|
|
254
|
-
], TokenConfig);
|
|
255
|
-
|
|
256
|
-
// packages/auth/domain/src/lib/feature-create-token/token-payload.provider.ts
|
|
257
|
-
var AUTH_TOKEN_PAYLOAD_PROVIDER = "AUTH_TOKEN_PAYLOAD_PROVIDER";
|
|
258
|
-
|
|
259
|
-
// packages/auth/domain/src/lib/feature-create-token/token-validation.provider.ts
|
|
260
|
-
var AUTH_TOKEN_VALIDATION_PROVIDER = "AUTH_TOKEN_VALIDATION_PROVIDER";
|
|
261
|
-
|
|
262
|
-
// packages/auth/domain/src/lib/feature-create-token/token-user.provider.ts
|
|
263
|
-
var AUTH_TOKEN_USER_PROVIDER = "AUTH_TOKEN_USER_PROVIDER";
|
|
264
|
-
|
|
265
|
-
// packages/auth/shell/app-services/src/lib/services/auth/auth.service.ts
|
|
266
|
-
var AuthService = class {
|
|
267
|
-
constructor(factory, moduleRef) {
|
|
268
|
-
this.factory = factory;
|
|
269
|
-
this.moduleRef = moduleRef;
|
|
270
|
-
}
|
|
271
|
-
factory;
|
|
272
|
-
moduleRef;
|
|
273
|
-
create(req, httpReq) {
|
|
274
|
-
return this.factory.create({
|
|
275
|
-
httpReq,
|
|
276
|
-
request: req,
|
|
277
|
-
payloadProvider: this.getPayloadProvider(),
|
|
278
|
-
validationProvider: this.getValidationProvider(),
|
|
279
|
-
userProvider: this.getUserProvider()
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
getPayloadProvider() {
|
|
283
|
-
try {
|
|
284
|
-
return this.moduleRef.get(AUTH_TOKEN_PAYLOAD_PROVIDER, {
|
|
285
|
-
strict: false
|
|
286
|
-
});
|
|
287
|
-
} catch (e) {
|
|
288
|
-
Logger.debug(e.message, AuthService.name);
|
|
289
|
-
}
|
|
290
|
-
return null;
|
|
291
|
-
}
|
|
292
|
-
getValidationProvider() {
|
|
293
|
-
try {
|
|
294
|
-
return this.moduleRef.get(AUTH_TOKEN_VALIDATION_PROVIDER, {
|
|
295
|
-
strict: false
|
|
296
|
-
});
|
|
297
|
-
} catch (e) {
|
|
298
|
-
Logger.debug(e.message, AuthService.name);
|
|
299
|
-
}
|
|
300
|
-
return null;
|
|
301
|
-
}
|
|
302
|
-
getUserProvider() {
|
|
303
|
-
try {
|
|
304
|
-
return this.moduleRef.get(AUTH_TOKEN_USER_PROVIDER, {
|
|
305
|
-
strict: false
|
|
306
|
-
});
|
|
307
|
-
} catch (e) {
|
|
308
|
-
Logger.debug(e.message, AuthService.name);
|
|
309
|
-
}
|
|
310
|
-
return null;
|
|
311
|
-
}
|
|
312
|
-
};
|
|
313
|
-
AuthService = __decorateClass([
|
|
314
|
-
Injectable3()
|
|
315
|
-
], AuthService);
|
|
316
|
-
export {
|
|
317
|
-
AuthService
|
|
318
|
-
};
|