@eventista/ticketing-common 1.0.15 → 1.0.17
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/auth.guard.d.ts +9 -0
- package/dist/auth/auth.guard.js +65 -0
- package/dist/auth/auth.guard.js.map +1 -0
- package/dist/auth/index.d.ts +1 -0
- package/dist/auth/index.js +18 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/decorators/index.d.ts +1 -0
- package/dist/decorators/index.js +18 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/decorators/public.decorator.d.ts +2 -0
- package/dist/decorators/public.decorator.js +8 -0
- package/dist/decorators/public.decorator.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/schemas/index.d.ts +2 -0
- package/dist/schemas/index.js +2 -0
- package/dist/schemas/index.js.map +1 -1
- package/dist/shared.module.js +6 -0
- package/dist/shared.module.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -2
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CanActivate, ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import { Reflector } from '@nestjs/core';
|
|
3
|
+
import { ConfigService } from '@nestjs/config';
|
|
4
|
+
export declare class AuthGuard implements CanActivate {
|
|
5
|
+
private readonly reflector;
|
|
6
|
+
private readonly configService;
|
|
7
|
+
constructor(reflector: Reflector, configService: ConfigService);
|
|
8
|
+
canActivate(context: ExecutionContext): boolean | Promise<boolean>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AuthGuard = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const core_1 = require("@nestjs/core");
|
|
15
|
+
const jwt = require("jsonwebtoken");
|
|
16
|
+
const uuid_1 = require("uuid");
|
|
17
|
+
const config_1 = require("@nestjs/config");
|
|
18
|
+
const public_decorator_1 = require("../decorators/public.decorator");
|
|
19
|
+
let AuthGuard = class AuthGuard {
|
|
20
|
+
constructor(reflector, configService) {
|
|
21
|
+
this.reflector = reflector;
|
|
22
|
+
this.configService = configService;
|
|
23
|
+
}
|
|
24
|
+
canActivate(context) {
|
|
25
|
+
const isPublic = this.reflector.get(public_decorator_1.IS_PUBLIC_KEY, context.getHandler());
|
|
26
|
+
if (isPublic) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
const request = context.switchToHttp().getRequest();
|
|
30
|
+
const { headers } = request;
|
|
31
|
+
const token = headers?.authorization || request?.query?.token || request?.body?.token;
|
|
32
|
+
if (!token) {
|
|
33
|
+
throw new common_1.UnauthorizedException('Token not provided');
|
|
34
|
+
}
|
|
35
|
+
if ((0, uuid_1.validate)(token)) {
|
|
36
|
+
if (token !== this.configService.get('UUID_TEST')) {
|
|
37
|
+
throw new common_1.UnauthorizedException('Token not provided');
|
|
38
|
+
}
|
|
39
|
+
request.user = {
|
|
40
|
+
email: token,
|
|
41
|
+
};
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
const match = token.match(/^Bearer (.*)$/);
|
|
45
|
+
if (!match || match.length < 2) {
|
|
46
|
+
throw new common_1.UnauthorizedException('Invalid Bearer token');
|
|
47
|
+
}
|
|
48
|
+
const extractedToken = match[1];
|
|
49
|
+
try {
|
|
50
|
+
const decoded = jwt.verify(extractedToken, this.configService.get('CLIENT_SECRET_KEY'));
|
|
51
|
+
request.user = decoded;
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
throw new common_1.UnauthorizedException('Invalid or expired token');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
exports.AuthGuard = AuthGuard;
|
|
60
|
+
exports.AuthGuard = AuthGuard = __decorate([
|
|
61
|
+
(0, common_1.Injectable)(),
|
|
62
|
+
__metadata("design:paramtypes", [core_1.Reflector,
|
|
63
|
+
config_1.ConfigService])
|
|
64
|
+
], AuthGuard);
|
|
65
|
+
//# sourceMappingURL=auth.guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.guard.js","sourceRoot":"","sources":["../../src/auth/auth.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAKwB;AACxB,uCAAyC;AACzC,oCAAoC;AACpC,+BAAgC;AAChC,2CAA+C;AAC/C,qEAA+D;AAGxD,IAAM,SAAS,GAAf,MAAM,SAAS;IACpB,YACmB,SAAoB,EACpB,aAA4B;QAD5B,cAAS,GAAT,SAAS,CAAW;QACpB,kBAAa,GAAb,aAAa,CAAe;IAC3C,CAAC;IAEL,WAAW,CAAC,OAAyB;QACnC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAU,gCAAa,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;QAClF,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QAEpD,M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sBAAa;GAHpC,SAAS,CAsDrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './auth.guard';
|
|
@@ -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("./auth.guard"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './public.decorator';
|
|
@@ -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("./public.decorator"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Public = exports.IS_PUBLIC_KEY = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
exports.IS_PUBLIC_KEY = 'isPublic';
|
|
6
|
+
const Public = () => (0, common_1.SetMetadata)(exports.IS_PUBLIC_KEY, true);
|
|
7
|
+
exports.Public = Public;
|
|
8
|
+
//# sourceMappingURL=public.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public.decorator.js","sourceRoot":"","sources":["../../src/decorators/public.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAEhC,QAAA,aAAa,GAAG,UAAU,CAAC;AACjC,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,IAAA,oBAAW,EAAC,qBAAa,EAAE,IAAI,CAAC,CAAC;AAAhD,QAAA,MAAM,UAA0C"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -22,5 +22,7 @@ __exportStar(require("./pipes/custom-validation.pipe"), exports);
|
|
|
22
22
|
__exportStar(require("./response/response.interceptor"), exports);
|
|
23
23
|
__exportStar(require("./schemas"), exports);
|
|
24
24
|
__exportStar(require("./cluster/index"), exports);
|
|
25
|
+
__exportStar(require("./decorators/index"), exports);
|
|
26
|
+
__exportStar(require("./auth/index"), exports);
|
|
25
27
|
__exportStar(require("./shared.module"), exports);
|
|
26
28
|
//# 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":";;;;;;;;;;;;;;;;AACA,6CAA2B;AAC3B,+DAA6C;AAC7C,uDAAqC;AAErC,2CAAyB;AAEzB,iEAA+C;AAC/C,kEAA+C;AAE/C,4CAA0B;AAE1B,kDAAgC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,6CAA2B;AAC3B,+DAA6C;AAC7C,uDAAqC;AAErC,2CAAyB;AAEzB,iEAA+C;AAC/C,kEAA+C;AAE/C,4CAA0B;AAE1B,kDAAgC;AAEhC,qDAAmC;AAEnC,+CAA6B;AAG7B,kDAAgC"}
|
package/dist/schemas/index.d.ts
CHANGED
|
@@ -12,3 +12,5 @@ export * from './event/event.interfaces';
|
|
|
12
12
|
export * from './event/event.schema';
|
|
13
13
|
export * from './user-fanpass/user-fanpass.interfaces';
|
|
14
14
|
export * from './user-fanpass/user-fanpass.schemas';
|
|
15
|
+
export * from './promotions/promotions.interfaces';
|
|
16
|
+
export * from './promotions/promotions.schema';
|
package/dist/schemas/index.js
CHANGED
|
@@ -28,4 +28,6 @@ __exportStar(require("./event/event.interfaces"), exports);
|
|
|
28
28
|
__exportStar(require("./event/event.schema"), exports);
|
|
29
29
|
__exportStar(require("./user-fanpass/user-fanpass.interfaces"), exports);
|
|
30
30
|
__exportStar(require("./user-fanpass/user-fanpass.schemas"), exports);
|
|
31
|
+
__exportStar(require("./promotions/promotions.interfaces"), exports);
|
|
32
|
+
__exportStar(require("./promotions/promotions.schema"), exports);
|
|
31
33
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,kDAAgC;AAChC,6EAA2D;AAC3D,yEAAuD;AACvD,6EAA2D;AAC3D,0EAAwD;AACxD,yDAAuC;AACvC,qDAAmC;AACnC,2DAAyC;AACzC,uDAAqC;AACrC,2DAAyC;AACzC,uDAAqC;AACrC,yEAAuD;AACvD,sEAAoD"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,kDAAgC;AAChC,6EAA2D;AAC3D,yEAAuD;AACvD,6EAA2D;AAC3D,0EAAwD;AACxD,yDAAuC;AACvC,qDAAmC;AACnC,2DAAyC;AACzC,uDAAqC;AACrC,2DAAyC;AACzC,uDAAqC;AACrC,yEAAuD;AACvD,sEAAoD;AACpD,qEAAmD;AACnD,iEAA+C"}
|
package/dist/shared.module.js
CHANGED
|
@@ -13,6 +13,8 @@ const logger_module_1 = require("./logger/logger.module");
|
|
|
13
13
|
const mongodb_module_1 = require("./database/mongodb/mongodb.module");
|
|
14
14
|
const cluster_module_1 = require("./cluster/modules/cluster.module");
|
|
15
15
|
const redis_module_1 = require("./database/redis/redis.module");
|
|
16
|
+
const auth_guard_1 = require("./auth/auth.guard");
|
|
17
|
+
const core_1 = require("@nestjs/core");
|
|
16
18
|
let SharedModule = class SharedModule {
|
|
17
19
|
};
|
|
18
20
|
exports.SharedModule = SharedModule;
|
|
@@ -36,6 +38,10 @@ exports.SharedModule = SharedModule = __decorate([
|
|
|
36
38
|
cluster_module_1.ClusterModule,
|
|
37
39
|
redis_module_1.RedisModule,
|
|
38
40
|
],
|
|
41
|
+
providers: [{
|
|
42
|
+
provide: core_1.APP_GUARD,
|
|
43
|
+
useClass: auth_guard_1.AuthGuard,
|
|
44
|
+
}],
|
|
39
45
|
})
|
|
40
46
|
], SharedModule);
|
|
41
47
|
//# sourceMappingURL=shared.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.module.js","sourceRoot":"","sources":["../src/shared.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAgD;AAChD,2CAA8C;AAC9C,0DAAsD;AACtD,sEAAkE;AAClE,qEAAiE;AACjE,gEAA4D;
|
|
1
|
+
{"version":3,"file":"shared.module.js","sourceRoot":"","sources":["../src/shared.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAgD;AAChD,2CAA8C;AAC9C,0DAAsD;AACtD,sEAAkE;AAClE,qEAAiE;AACjE,gEAA4D;AAC5D,kDAA8C;AAC9C,uCAAyC;AA2BlC,IAAM,YAAY,GAAlB,MAAM,YAAY;CAAG,CAAA;AAAf,oCAAY;uBAAZ,YAAY;IAzBxB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,qBAAY,CAAC,OAAO,CAAC;gBACnB,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,CAAC,WAAW,EAAE,YAAY,EAAE,UAAU,CAAC;aACrD,CAAC;YAEF,8BAAa;YACb,4BAAY;YACZ,8BAAa;YACb,0BAAW;SACZ;QACD,OAAO,EAAE;YACP,qBAAY;YACZ,8BAAa;YACb,4BAAY;YACZ,8BAAa;YACb,0BAAW;SACZ;QACD,SAAS,EAAE,CAAC;gBACV,OAAO,EAAE,gBAAS;gBAClB,QAAQ,EAAE,sBAAS;aACpB,CAAC;KACH,CAAC;GACW,YAAY,CAAG"}
|