@loopstack/auth 0.29.0 → 0.31.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/dist/auth.module.d.ts +4 -4
- package/dist/auth.module.d.ts.map +1 -1
- package/dist/auth.module.js +35 -37
- package/dist/auth.module.js.map +1 -1
- package/dist/commands/assign-role.command.js +19 -22
- package/dist/commands/assign-role.command.js.map +1 -1
- package/dist/controllers/auth.controller.d.ts +5 -5
- package/dist/controllers/auth.controller.d.ts.map +1 -1
- package/dist/controllers/auth.controller.js +32 -47
- package/dist/controllers/auth.controller.js.map +1 -1
- package/dist/controllers/index.d.ts +1 -1
- package/dist/controllers/index.d.ts.map +1 -1
- package/dist/controllers/index.js +1 -17
- package/dist/controllers/index.js.map +1 -1
- package/dist/dtos/auth-response.dto.js +1 -5
- package/dist/dtos/auth-response.dto.js.map +1 -1
- package/dist/dtos/hub-login-request.dto.d.ts.map +1 -1
- package/dist/dtos/hub-login-request.dto.js +3 -9
- package/dist/dtos/hub-login-request.dto.js.map +1 -1
- package/dist/dtos/hub-login-response.dto.d.ts.map +1 -1
- package/dist/dtos/hub-login-response.dto.js +4 -11
- package/dist/dtos/hub-login-response.dto.js.map +1 -1
- package/dist/dtos/user-response.dto.js +1 -5
- package/dist/dtos/user-response.dto.js.map +1 -1
- package/dist/dtos/worker-info.dto.d.ts.map +1 -1
- package/dist/dtos/worker-info.dto.js +5 -19
- package/dist/dtos/worker-info.dto.js.map +1 -1
- package/dist/guards/hub-auth.guard.js +6 -9
- package/dist/guards/hub-auth.guard.js.map +1 -1
- package/dist/guards/index.d.ts +2 -2
- package/dist/guards/index.d.ts.map +1 -1
- package/dist/guards/index.js +2 -18
- package/dist/guards/index.js.map +1 -1
- package/dist/guards/jwt-auth.guard.js +16 -19
- package/dist/guards/jwt-auth.guard.js.map +1 -1
- package/dist/guards/roles.guard.js +8 -11
- package/dist/guards/roles.guard.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -22
- package/dist/index.js.map +1 -1
- package/dist/interfaces/auth-config.interface.js +1 -2
- package/dist/interfaces/index.d.ts +1 -1
- package/dist/interfaces/index.d.ts.map +1 -1
- package/dist/interfaces/index.js +1 -17
- package/dist/interfaces/index.js.map +1 -1
- package/dist/repositories/index.d.ts +1 -1
- package/dist/repositories/index.d.ts.map +1 -1
- package/dist/repositories/index.js +1 -17
- package/dist/repositories/index.js.map +1 -1
- package/dist/repositories/user.repository.js +11 -14
- package/dist/repositories/user.repository.js.map +1 -1
- package/dist/seeds/local-dev-user.seed.d.ts +1 -1
- package/dist/seeds/local-dev-user.seed.d.ts.map +1 -1
- package/dist/seeds/local-dev-user.seed.js +10 -13
- package/dist/seeds/local-dev-user.seed.js.map +1 -1
- package/dist/services/auth.service.d.ts +5 -5
- package/dist/services/auth.service.d.ts.map +1 -1
- package/dist/services/auth.service.js +19 -22
- package/dist/services/auth.service.js.map +1 -1
- package/dist/services/config-validation.service.js +6 -9
- package/dist/services/config-validation.service.js.map +1 -1
- package/dist/services/index.d.ts +2 -2
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +2 -18
- package/dist/services/index.js.map +1 -1
- package/dist/services/token.service.js +8 -11
- package/dist/services/token.service.js.map +1 -1
- package/dist/strategies/hub.strategy.d.ts +1 -1
- package/dist/strategies/hub.strategy.d.ts.map +1 -1
- package/dist/strategies/hub.strategy.js +25 -28
- package/dist/strategies/hub.strategy.js.map +1 -1
- package/dist/strategies/index.d.ts +2 -2
- package/dist/strategies/index.d.ts.map +1 -1
- package/dist/strategies/index.js +2 -18
- package/dist/strategies/index.js.map +1 -1
- package/dist/strategies/jwt.strategy.js +11 -14
- package/dist/strategies/jwt.strategy.js.map +1 -1
- package/package.json +18 -28
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
6
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const passport_1 = require("@nestjs/passport");
|
|
12
|
-
let HubAuthGuard = class HubAuthGuard extends (0, passport_1.AuthGuard)('hub') {
|
|
7
|
+
import { Injectable } from '@nestjs/common';
|
|
8
|
+
import { AuthGuard } from '@nestjs/passport';
|
|
9
|
+
let HubAuthGuard = class HubAuthGuard extends AuthGuard('hub') {
|
|
13
10
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
(0, common_1.Injectable)()
|
|
11
|
+
HubAuthGuard = __decorate([
|
|
12
|
+
Injectable()
|
|
17
13
|
], HubAuthGuard);
|
|
14
|
+
export { HubAuthGuard };
|
|
18
15
|
//# sourceMappingURL=hub-auth.guard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hub-auth.guard.js","sourceRoot":"","sources":["../../src/guards/hub-auth.guard.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hub-auth.guard.js","sourceRoot":"","sources":["../../src/guards/hub-auth.guard.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGtC,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,SAAS,CAAC,KAAK,CAAC;CAAG,CAAA;AAAxC,YAAY;IADxB,UAAU,EAAE;GACA,YAAY,CAA4B"}
|
package/dist/guards/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './jwt-auth.guard';
|
|
2
|
-
export * from './roles.guard';
|
|
1
|
+
export * from './jwt-auth.guard.js';
|
|
2
|
+
export * from './roles.guard.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/guards/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/guards/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC"}
|
package/dist/guards/index.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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("./jwt-auth.guard"), exports);
|
|
18
|
-
__exportStar(require("./roles.guard"), exports);
|
|
1
|
+
export * from './jwt-auth.guard.js';
|
|
2
|
+
export * from './roles.guard.js';
|
|
19
3
|
//# sourceMappingURL=index.js.map
|
package/dist/guards/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/guards/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/guards/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -8,15 +7,13 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const common_3 = require("@loopstack/common");
|
|
19
|
-
let JwtAuthGuard = class JwtAuthGuard extends (0, passport_1.AuthGuard)('jwt') {
|
|
10
|
+
import { Injectable } from '@nestjs/common';
|
|
11
|
+
import { ConfigService } from '@nestjs/config';
|
|
12
|
+
import { Reflector } from '@nestjs/core';
|
|
13
|
+
import { AuthGuard } from '@nestjs/passport';
|
|
14
|
+
import { IS_PUBLIC_KEY } from '@loopstack/common';
|
|
15
|
+
import { UserTypeEnum } from '@loopstack/common';
|
|
16
|
+
let JwtAuthGuard = class JwtAuthGuard extends AuthGuard('jwt') {
|
|
20
17
|
reflector;
|
|
21
18
|
configService;
|
|
22
19
|
constructor(reflector, configService) {
|
|
@@ -25,7 +22,7 @@ let JwtAuthGuard = class JwtAuthGuard extends (0, passport_1.AuthGuard)('jwt') {
|
|
|
25
22
|
this.configService = configService;
|
|
26
23
|
}
|
|
27
24
|
async canActivate(context) {
|
|
28
|
-
const isPublic = this.reflector.getAllAndOverride(
|
|
25
|
+
const isPublic = this.reflector.getAllAndOverride(IS_PUBLIC_KEY, [
|
|
29
26
|
context.getHandler(),
|
|
30
27
|
context.getClass(),
|
|
31
28
|
]);
|
|
@@ -37,18 +34,18 @@ let JwtAuthGuard = class JwtAuthGuard extends (0, passport_1.AuthGuard)('jwt') {
|
|
|
37
34
|
return false;
|
|
38
35
|
}
|
|
39
36
|
const { user } = context.switchToHttp().getRequest();
|
|
40
|
-
const
|
|
41
|
-
if (
|
|
42
|
-
return user.type ===
|
|
37
|
+
const enableAuth = this.configService.get('app.enableAuth');
|
|
38
|
+
if (!enableAuth) {
|
|
39
|
+
return user.type === UserTypeEnum.Local;
|
|
43
40
|
}
|
|
44
41
|
const clientId = this.configService.get('auth.clientId');
|
|
45
42
|
return clientId === user.workerId;
|
|
46
43
|
}
|
|
47
44
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
(
|
|
51
|
-
|
|
52
|
-
config_1.ConfigService])
|
|
45
|
+
JwtAuthGuard = __decorate([
|
|
46
|
+
Injectable(),
|
|
47
|
+
__metadata("design:paramtypes", [Reflector,
|
|
48
|
+
ConfigService])
|
|
53
49
|
], JwtAuthGuard);
|
|
50
|
+
export { JwtAuthGuard };
|
|
54
51
|
//# sourceMappingURL=jwt-auth.guard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwt-auth.guard.js","sourceRoot":"","sources":["../../src/guards/jwt-auth.guard.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"jwt-auth.guard.js","sourceRoot":"","sources":["../../src/guards/jwt-auth.guard.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAoB,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EA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AxCY,YAAY;IADxB,UAAU,EAAE;qCAGmB,SAAS;QACL,aAAa;GAHpC,YAAY,CAwCxB"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -8,18 +7,16 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const core_1 = require("@nestjs/core");
|
|
15
|
-
const common_2 = require("@loopstack/common");
|
|
10
|
+
import { Injectable } from '@nestjs/common';
|
|
11
|
+
import { Reflector } from '@nestjs/core';
|
|
12
|
+
import { ROLES_KEY } from '@loopstack/common';
|
|
16
13
|
let RolesGuard = class RolesGuard {
|
|
17
14
|
reflector;
|
|
18
15
|
constructor(reflector) {
|
|
19
16
|
this.reflector = reflector;
|
|
20
17
|
}
|
|
21
18
|
canActivate(context) {
|
|
22
|
-
const requiredRoles = this.reflector.getAllAndOverride(
|
|
19
|
+
const requiredRoles = this.reflector.getAllAndOverride(ROLES_KEY, [
|
|
23
20
|
context.getHandler(),
|
|
24
21
|
context.getClass(),
|
|
25
22
|
]);
|
|
@@ -30,9 +27,9 @@ let RolesGuard = class RolesGuard {
|
|
|
30
27
|
return requiredRoles.some((role) => user.roles?.includes(role));
|
|
31
28
|
}
|
|
32
29
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
(
|
|
36
|
-
__metadata("design:paramtypes", [core_1.Reflector])
|
|
30
|
+
RolesGuard = __decorate([
|
|
31
|
+
Injectable(),
|
|
32
|
+
__metadata("design:paramtypes", [Reflector])
|
|
37
33
|
], RolesGuard);
|
|
34
|
+
export { RolesGuard };
|
|
38
35
|
//# sourceMappingURL=roles.guard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roles.guard.js","sourceRoot":"","sources":["../../src/guards/roles.guard.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"roles.guard.js","sourceRoot":"","sources":["../../src/guards/roles.guard.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAiC,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAwB,SAAS,EAAY,MAAM,mBAAmB,CAAC;AAGvE,IAAM,UAAU,GAAhB,MAAM,UAAU;IACD;IAApB,YAAoB,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAE5C,WAAW,CAAC,OAAyB;QACnC,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAa,SAAS,EAAE;YAC5E,OAAO,CAAC,UAAU,EAAE;YACpB,OAAO,CAAC,QAAQ,EAAE;SACnB,CAAC,CAAC;QACH,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAA4C,CAAC;QAC/F,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IAClE,CAAC;CACF,CAAA;AAdY,UAAU;IADtB,UAAU,EAAE;qCAEoB,SAAS;GAD7B,UAAU,CActB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from './auth.module';
|
|
2
|
-
export * from './controllers';
|
|
3
|
-
export * from './guards';
|
|
4
|
-
export * from './interfaces';
|
|
5
|
-
export * from './repositories';
|
|
6
|
-
export * from './services';
|
|
1
|
+
export * from './auth.module.js';
|
|
2
|
+
export * from './controllers/index.js';
|
|
3
|
+
export * from './guards/index.js';
|
|
4
|
+
export * from './interfaces/index.js';
|
|
5
|
+
export * from './repositories/index.js';
|
|
6
|
+
export * from './services/index.js';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AAEjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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("./auth.module"), exports);
|
|
18
|
-
__exportStar(require("./controllers"), exports);
|
|
19
|
-
__exportStar(require("./guards"), exports);
|
|
20
|
-
__exportStar(require("./interfaces"), exports);
|
|
21
|
-
__exportStar(require("./repositories"), exports);
|
|
22
|
-
__exportStar(require("./services"), exports);
|
|
1
|
+
export * from './auth.module.js';
|
|
2
|
+
export * from './controllers/index.js';
|
|
3
|
+
export * from './guards/index.js';
|
|
4
|
+
export * from './interfaces/index.js';
|
|
5
|
+
export * from './repositories/index.js';
|
|
6
|
+
export * from './services/index.js';
|
|
23
7
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AAEjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './auth-config.interface';
|
|
1
|
+
export * from './auth-config.interface.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC"}
|
package/dist/interfaces/index.js
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
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("./auth-config.interface"), exports);
|
|
1
|
+
export * from './auth-config.interface.js';
|
|
18
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './user.repository';
|
|
1
|
+
export * from './user.repository.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/repositories/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/repositories/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
|
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
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("./user.repository"), exports);
|
|
1
|
+
export * from './user.repository.js';
|
|
18
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/repositories/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/repositories/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -11,13 +10,11 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
10
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
11
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
12
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const common_2 = require("@loopstack/common");
|
|
20
|
-
const common_3 = require("@loopstack/common");
|
|
13
|
+
import { Injectable } from '@nestjs/common';
|
|
14
|
+
import { InjectRepository } from '@nestjs/typeorm';
|
|
15
|
+
import { Repository } from 'typeorm';
|
|
16
|
+
import { User } from '@loopstack/common';
|
|
17
|
+
import { UserTypeEnum } from '@loopstack/common';
|
|
21
18
|
let UserRepository = class UserRepository {
|
|
22
19
|
repository;
|
|
23
20
|
constructor(repository) {
|
|
@@ -32,7 +29,7 @@ let UserRepository = class UserRepository {
|
|
|
32
29
|
async findLocalUser() {
|
|
33
30
|
return this.repository.findOne({
|
|
34
31
|
where: {
|
|
35
|
-
type:
|
|
32
|
+
type: UserTypeEnum.Local,
|
|
36
33
|
},
|
|
37
34
|
relations: ['roles'],
|
|
38
35
|
});
|
|
@@ -49,10 +46,10 @@ let UserRepository = class UserRepository {
|
|
|
49
46
|
return this.repository;
|
|
50
47
|
}
|
|
51
48
|
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
(0,
|
|
55
|
-
|
|
56
|
-
__metadata("design:paramtypes", [typeorm_2.Repository])
|
|
49
|
+
UserRepository = __decorate([
|
|
50
|
+
Injectable(),
|
|
51
|
+
__param(0, InjectRepository(User)),
|
|
52
|
+
__metadata("design:paramtypes", [Repository])
|
|
57
53
|
], UserRepository);
|
|
54
|
+
export { UserRepository };
|
|
58
55
|
//# sourceMappingURL=user.repository.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.repository.js","sourceRoot":"","sources":["../../src/repositories/user.repository.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"user.repository.js","sourceRoot":"","sources":["../../src/repositories/user.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAG1C,IAAM,cAAc,GAApB,MAAM,cAAc;IAGf;IAFV,YAEU,UAA4B;QAA5B,eAAU,GAAV,UAAU,CAAkB;IACnC,CAAC;IAEJ,KAAK,CAAC,QAAQ,CAAC,EAAU;QACvB,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;YAC7B,KAAK,EAAE,EAAE,EAAE,EAAE;YACb,SAAS,EAAE,CAAC,OAAO,CAAC;SACrB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;YAC7B,KAAK,EAAE;gBACL,IAAI,EAAE,YAAY,CAAC,KAAK;aACzB;YACD,SAAS,EAAE,CAAC,OAAO,CAAC;SACrB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,QAAuB;QAClC,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAU,EAAE,QAAuB;QAC9C,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC3B,CAAC;IAED,aAAa;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF,CAAA;AAnCY,cAAc;IAD1B,UAAU,EAAE;IAGR,WAAA,gBAAgB,CAAC,IAAI,CAAC,CAAA;qCACH,UAAU;GAHrB,cAAc,CAmC1B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OnModuleInit } from '@nestjs/common';
|
|
2
2
|
import { ConfigService } from '@nestjs/config';
|
|
3
|
-
import { UserRepository } from '../repositories';
|
|
3
|
+
import { UserRepository } from '../repositories/index.js';
|
|
4
4
|
export declare class LocalDevUserSeeder implements OnModuleInit {
|
|
5
5
|
private readonly configService;
|
|
6
6
|
private readonly userRepository;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-dev-user.seed.d.ts","sourceRoot":"","sources":["../../src/seeds/local-dev-user.seed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"local-dev-user.seed.d.ts","sourceRoot":"","sources":["../../src/seeds/local-dev-user.seed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,qBACa,kBAAmB,YAAW,YAAY;IAInD,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAJjC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA0C;gBAGzD,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,cAAc;IAG3C,YAAY;IAkBlB,iBAAiB,IAAI,MAAM;CAG5B"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -8,11 +7,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const config_1 = require("@nestjs/config");
|
|
15
|
-
const repositories_1 = require("../repositories");
|
|
10
|
+
import { Injectable } from '@nestjs/common';
|
|
11
|
+
import { ConfigService } from '@nestjs/config';
|
|
12
|
+
import { UserRepository } from '../repositories/index.js';
|
|
16
13
|
let LocalDevUserSeeder = class LocalDevUserSeeder {
|
|
17
14
|
configService;
|
|
18
15
|
userRepository;
|
|
@@ -22,8 +19,8 @@ let LocalDevUserSeeder = class LocalDevUserSeeder {
|
|
|
22
19
|
this.userRepository = userRepository;
|
|
23
20
|
}
|
|
24
21
|
async onModuleInit() {
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
22
|
+
const enableAuth = this.configService.get('app.enableAuth');
|
|
23
|
+
if (enableAuth)
|
|
27
24
|
return;
|
|
28
25
|
const existingUser = await this.userRepository.findById(this.LOCAL_DEV_USER_ID);
|
|
29
26
|
if (!existingUser) {
|
|
@@ -39,10 +36,10 @@ let LocalDevUserSeeder = class LocalDevUserSeeder {
|
|
|
39
36
|
return this.LOCAL_DEV_USER_ID;
|
|
40
37
|
}
|
|
41
38
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
(
|
|
45
|
-
|
|
46
|
-
repositories_1.UserRepository])
|
|
39
|
+
LocalDevUserSeeder = __decorate([
|
|
40
|
+
Injectable(),
|
|
41
|
+
__metadata("design:paramtypes", [ConfigService,
|
|
42
|
+
UserRepository])
|
|
47
43
|
], LocalDevUserSeeder);
|
|
44
|
+
export { LocalDevUserSeeder };
|
|
48
45
|
//# sourceMappingURL=local-dev-user.seed.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-dev-user.seed.js","sourceRoot":"","sources":["../../src/seeds/local-dev-user.seed.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"local-dev-user.seed.js","sourceRoot":"","sources":["../../src/seeds/local-dev-user.seed.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAgB,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAGnD,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAIV;IACA;IAJF,iBAAiB,GAAG,sCAAsC,CAAC;IAE5E,YACmB,aAA4B,EAC5B,cAA8B;QAD9B,kBAAa,GAAb,aAAa,CAAe;QAC5B,mBAAc,GAAd,cAAc,CAAgB;IAC9C,CAAC;IAEJ,KAAK,CAAC,YAAY;QAChB,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAU,gBAAgB,CAAC,CAAC;QACrE,IAAI,UAAU;YAAE,OAAO;QAGvB,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAEhF,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,MAAM,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC;gBAC/B,EAAE,EAAE,IAAI,CAAC,iBAAiB;gBAC1B,QAAQ,EAAE,IAAI;gBACd,KAAK,EAAE,EAAE;aACc,CAAC,CAAC;YAE3B,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;IAED,iBAAiB;QACf,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAChC,CAAC;CACF,CAAA;AA7BY,kBAAkB;IAD9B,UAAU,EAAE;qCAKuB,aAAa;QACZ,cAAc;GALtC,kBAAkB,CA6B9B"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ConfigService } from '@nestjs/config';
|
|
2
2
|
import { User } from '@loopstack/common';
|
|
3
|
-
import { AuthResponseDto } from '../dtos/auth-response.dto';
|
|
4
|
-
import { UserResponseDto } from '../dtos/user-response.dto';
|
|
5
|
-
import { WorkerInfoDto } from '../dtos/worker-info.dto';
|
|
6
|
-
import { UserRepository } from '../repositories';
|
|
7
|
-
import { TokenService } from './token.service';
|
|
3
|
+
import { AuthResponseDto } from '../dtos/auth-response.dto.js';
|
|
4
|
+
import { UserResponseDto } from '../dtos/user-response.dto.js';
|
|
5
|
+
import { WorkerInfoDto } from '../dtos/worker-info.dto.js';
|
|
6
|
+
import { UserRepository } from '../repositories/index.js';
|
|
7
|
+
import { TokenService } from './token.service.js';
|
|
8
8
|
export declare class AuthService {
|
|
9
9
|
private readonly configService;
|
|
10
10
|
private userRepository;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.service.d.ts","sourceRoot":"","sources":["../../src/services/auth.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAuB,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"auth.service.d.ts","sourceRoot":"","sources":["../../src/services/auth.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAuB,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,qBACa,WAAW;IAEpB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,YAAY;gBAFH,aAAa,EAAE,aAAa,EACrC,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,YAAY;IAG9B,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,eAAe,CAAC;IAgB3C,OAAO,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IA2B7D,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,eAAe;IAUxC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAQ9D,mBAAmB,IAAI,aAAa;CAcrC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -8,14 +7,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const repositories_1 = require("../repositories");
|
|
18
|
-
const token_service_1 = require("./token.service");
|
|
10
|
+
import { Injectable, UnauthorizedException } from '@nestjs/common';
|
|
11
|
+
import { ConfigService } from '@nestjs/config';
|
|
12
|
+
import { plainToInstance } from 'class-transformer';
|
|
13
|
+
import { WorkerInfoDto } from '../dtos/worker-info.dto.js';
|
|
14
|
+
import { UserRepository } from '../repositories/index.js';
|
|
15
|
+
import { TokenService } from './token.service.js';
|
|
19
16
|
let AuthService = class AuthService {
|
|
20
17
|
configService;
|
|
21
18
|
userRepository;
|
|
@@ -44,7 +41,7 @@ let AuthService = class AuthService {
|
|
|
44
41
|
const payload = this.tokenService.verifyRefreshToken(refreshToken);
|
|
45
42
|
const user = await this.userRepository.findById(payload.sub);
|
|
46
43
|
if (!user || !user.isActive) {
|
|
47
|
-
throw new
|
|
44
|
+
throw new UnauthorizedException('Invalid refresh token');
|
|
48
45
|
}
|
|
49
46
|
const newPayload = {
|
|
50
47
|
sub: payload.sub,
|
|
@@ -59,7 +56,7 @@ let AuthService = class AuthService {
|
|
|
59
56
|
};
|
|
60
57
|
}
|
|
61
58
|
catch {
|
|
62
|
-
throw new
|
|
59
|
+
throw new UnauthorizedException('Invalid refresh token');
|
|
63
60
|
}
|
|
64
61
|
}
|
|
65
62
|
mapUserToResponse(user) {
|
|
@@ -74,26 +71,26 @@ let AuthService = class AuthService {
|
|
|
74
71
|
async getCurrentUser(userId) {
|
|
75
72
|
const user = await this.userRepository.findById(userId);
|
|
76
73
|
if (!user) {
|
|
77
|
-
throw new
|
|
74
|
+
throw new UnauthorizedException('User not found');
|
|
78
75
|
}
|
|
79
76
|
return this.mapUserToResponse(user);
|
|
80
77
|
}
|
|
81
78
|
getWorkerHealthInfo() {
|
|
82
|
-
const
|
|
83
|
-
return
|
|
84
|
-
clientId:
|
|
85
|
-
isConfigured:
|
|
79
|
+
const enableAuth = this.configService.get('app.enableAuth');
|
|
80
|
+
return plainToInstance(WorkerInfoDto, {
|
|
81
|
+
clientId: enableAuth ? this.configService.get('auth.clientId') : 'local',
|
|
82
|
+
isConfigured: !enableAuth || !!this.configService.get('auth.hub.jwksUri'),
|
|
86
83
|
timestamp: new Date(),
|
|
87
84
|
}, {
|
|
88
85
|
excludeExtraneousValues: true,
|
|
89
86
|
});
|
|
90
87
|
}
|
|
91
88
|
};
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
token_service_1.TokenService])
|
|
89
|
+
AuthService = __decorate([
|
|
90
|
+
Injectable(),
|
|
91
|
+
__metadata("design:paramtypes", [ConfigService,
|
|
92
|
+
UserRepository,
|
|
93
|
+
TokenService])
|
|
98
94
|
], AuthService);
|
|
95
|
+
export { AuthService };
|
|
99
96
|
//# sourceMappingURL=auth.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../../src/services/auth.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../../src/services/auth.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAIpD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAG3C,IAAM,WAAW,GAAjB,MAAM,WAAW;IAEH;IACT;IACA;IAHV,YACmB,aAA4B,EACrC,cAA8B,EAC9B,YAA0B;QAFjB,kBAAa,GAAb,aAAa,CAAe;QACrC,mBAAc,GAAd,cAAc,CAAgB;QAC9B,iBAAY,GAAZ,YAAY,CAAc;IACjC,CAAC;IAEJ,KAAK,CAAC,KAAK,CAAC,IAAU;QACpB,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,eAAe,CAAC,IAAI,EAAE,CAAC;QACvE,MAAM,OAAO,GAAwB;YACnC,GAAG,EAAE,IAAI,CAAC,EAAE;YACZ,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,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