itlab-internal-services 2.0.2 → 2.1.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/env.d.ts +5 -0
- package/dist/env.js +8 -0
- package/dist/guards/index.d.ts +0 -2
- package/dist/guards/index.js +0 -2
- package/dist/guards/perms.guard.js +1 -1
- package/dist/index.d.ts +1 -4
- package/dist/index.js +1 -4
- package/dist/modules/authentication/authentication.module.d.ts +7 -0
- package/dist/modules/authentication/authentication.module.js +26 -0
- package/dist/modules/authentication/index.d.ts +3 -0
- package/dist/{services → modules/authentication}/index.js +5 -8
- package/dist/modules/authentication/internal/index.d.ts +3 -0
- package/dist/modules/authentication/internal/index.js +19 -0
- package/dist/modules/authentication/internal/internal.constants.d.ts +5 -0
- package/dist/modules/authentication/internal/internal.constants.js +8 -0
- package/dist/modules/authentication/internal/internal.decorators.d.ts +1 -0
- package/dist/modules/authentication/internal/internal.decorators.js +9 -0
- package/dist/modules/authentication/internal/internal.guard.d.ts +4 -0
- package/dist/modules/authentication/internal/internal.guard.js +18 -0
- package/dist/modules/authentication/internal/internal.strategy.d.ts +10 -0
- package/dist/modules/authentication/internal/internal.strategy.js +36 -0
- package/dist/modules/authentication/jwt/index.d.ts +3 -0
- package/dist/modules/authentication/jwt/index.js +19 -0
- package/dist/modules/authentication/jwt/jwt.constants.d.ts +8 -0
- package/dist/modules/authentication/jwt/jwt.constants.js +10 -0
- package/dist/modules/authentication/jwt/jwt.decorators.d.ts +5 -0
- package/dist/modules/authentication/jwt/jwt.decorators.js +21 -0
- package/dist/modules/authentication/jwt/jwt.guard.d.ts +9 -0
- package/dist/modules/authentication/jwt/jwt.guard.js +37 -0
- package/dist/modules/authentication/jwt/jwt.strategy.d.ts +9 -0
- package/dist/modules/authentication/jwt/jwt.strategy.js +35 -0
- package/dist/modules/database/database.module-options.d.ts +4 -0
- package/dist/modules/database/database.module.d.ts +6 -0
- package/dist/modules/database/database.module.js +69 -0
- package/dist/modules/database/index.d.ts +5 -0
- package/dist/modules/database/index.js +11 -0
- package/dist/{services → modules/database/model-service}/model.service.d.ts +25 -25
- package/dist/{services → modules/database/model-service}/model.service.js +11 -11
- package/dist/{model-schemas → modules/database/model-service/schemas}/hub-account.schemas.d.ts +1 -1
- package/dist/{model-schemas → modules/database/model-service/schemas}/hub-books.schemas.d.ts +1 -1
- package/dist/{model-schemas → modules/database/model-service/schemas}/hub-comments.schemas.d.ts +1 -1
- package/dist/{model-schemas → modules/database/model-service/schemas}/hub-content.schemas.d.ts +1 -1
- package/dist/{model-schemas → modules/database/model-service/schemas}/hub-demo-hive.schemas.d.ts +1 -1
- package/dist/{model-schemas → modules/database/model-service/schemas}/hub-events.schemas.d.ts +1 -1
- package/dist/{model-schemas → modules/database/model-service/schemas}/hub-hackschool.schemas.d.ts +3 -3
- package/dist/{model-schemas → modules/database/model-service/schemas}/hub-newsroom.schemas.d.ts +1 -1
- package/dist/{model-schemas → modules/database/model-service/schemas}/hub-podcasts.schemas.d.ts +1 -1
- package/dist/{model-schemas → modules/database/model-service/schemas}/hub-team.schemas.d.ts +1 -1
- package/dist/{model-schemas → modules/database/model-service/schemas}/hub-tech-radar.schemas.d.ts +2 -2
- package/dist/{services → modules/database/populate-service}/populate.service.d.ts +1 -1
- package/dist/{services → modules/database/populate-service}/populate.service.js +2 -2
- package/dist/{services → modules/database/service-mapper-service}/service-mapper.service.d.ts +1 -1
- package/dist/{services → modules/database/service-mapper-service}/service-mapper.service.js +1 -1
- package/dist/modules/index.d.ts +3 -0
- package/dist/modules/index.js +19 -0
- package/dist/{services → modules/services/account-service}/account.service.d.ts +3 -3
- package/dist/{services → modules/services/account-service}/account.service.js +10 -16
- package/dist/modules/services/comment-service/comment-service.definitions.d.ts +5 -0
- package/dist/modules/services/comment-service/comment-service.definitions.js +28 -0
- package/dist/{services → modules/services/comment-service}/comment.service.d.ts +6 -10
- package/dist/{services → modules/services/comment-service}/comment.service.js +15 -36
- package/dist/{services → modules/services/content-service}/content.service.d.ts +5 -5
- package/dist/{services → modules/services/content-service}/content.service.js +14 -19
- package/dist/modules/services/index.d.ts +9 -0
- package/dist/modules/services/index.js +22 -0
- package/dist/modules/services/mail-service/mail-service.definitions.d.ts +13 -0
- package/dist/modules/services/mail-service/mail-service.definitions.js +55 -0
- package/dist/modules/services/mail-service/mail.service.d.ts +11 -0
- package/dist/{services → modules/services/mail-service}/mail.service.js +19 -30
- package/dist/modules/services/search-service/search-service.definitions.d.ts +6 -0
- package/dist/modules/services/search-service/search-service.definitions.js +32 -0
- package/dist/modules/services/search-service/search.service.d.ts +11 -0
- package/dist/modules/services/search-service/search.service.js +46 -0
- package/dist/modules/services/services.module-utils.d.ts +7 -0
- package/dist/modules/services/services.module-utils.js +15 -0
- package/dist/modules/services/services.module.d.ts +7 -0
- package/dist/modules/services/services.module.js +30 -0
- package/dist/swagger.config.js +2 -2
- package/package.json +3 -3
- package/dist/guards/internal.guard.d.ts +0 -15
- package/dist/guards/internal.guard.js +0 -49
- package/dist/guards/jwt.guard.d.ts +0 -25
- package/dist/guards/jwt.guard.js +0 -74
- package/dist/itlab.interfaces.d.ts +0 -4
- package/dist/itlab.module-definition.d.ts +0 -4
- package/dist/itlab.module-definition.js +0 -10
- package/dist/itlab.module.d.ts +0 -3
- package/dist/itlab.module.js +0 -32
- package/dist/mongo.factory.d.ts +0 -6
- package/dist/mongo.factory.js +0 -34
- package/dist/services/index.d.ts +0 -8
- package/dist/services/mail.service.d.ts +0 -23
- package/dist/services/search.service.d.ts +0 -16
- package/dist/services/search.service.js +0 -71
- /package/dist/{itlab.interfaces.js → modules/database/database.module-options.js} +0 -0
- /package/dist/{model-schemas → modules/database/model-service/schemas}/hub-account.schemas.js +0 -0
- /package/dist/{model-schemas → modules/database/model-service/schemas}/hub-books.schemas.js +0 -0
- /package/dist/{model-schemas → modules/database/model-service/schemas}/hub-comments.schemas.js +0 -0
- /package/dist/{model-schemas → modules/database/model-service/schemas}/hub-content.schemas.js +0 -0
- /package/dist/{model-schemas → modules/database/model-service/schemas}/hub-demo-hive.schemas.js +0 -0
- /package/dist/{model-schemas → modules/database/model-service/schemas}/hub-events.schemas.js +0 -0
- /package/dist/{model-schemas → modules/database/model-service/schemas}/hub-hackschool.schemas.js +0 -0
- /package/dist/{model-schemas → modules/database/model-service/schemas}/hub-newsroom.schemas.js +0 -0
- /package/dist/{model-schemas → modules/database/model-service/schemas}/hub-podcasts.schemas.js +0 -0
- /package/dist/{model-schemas → modules/database/model-service/schemas}/hub-team.schemas.js +0 -0
- /package/dist/{model-schemas → modules/database/model-service/schemas}/hub-tech-radar.schemas.js +0 -0
package/dist/env.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const ENV_K8S_TOKEN = "K8S_TOKEN";
|
|
2
|
+
export declare const ENV_JWT_SECRET = "JWT_SECRET";
|
|
3
|
+
export declare const ENV_MONGO_SRV = "MONGO_SRV";
|
|
4
|
+
export declare const ENV_MONGO_USERNAME = "MONGO_USERNAME";
|
|
5
|
+
export declare const ENV_MONGO_PASSWORD = "MONGO_PASSWORD";
|
package/dist/env.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ENV_MONGO_PASSWORD = exports.ENV_MONGO_USERNAME = exports.ENV_MONGO_SRV = exports.ENV_JWT_SECRET = exports.ENV_K8S_TOKEN = void 0;
|
|
4
|
+
exports.ENV_K8S_TOKEN = 'K8S_TOKEN';
|
|
5
|
+
exports.ENV_JWT_SECRET = 'JWT_SECRET';
|
|
6
|
+
exports.ENV_MONGO_SRV = 'MONGO_SRV';
|
|
7
|
+
exports.ENV_MONGO_USERNAME = 'MONGO_USERNAME';
|
|
8
|
+
exports.ENV_MONGO_PASSWORD = 'MONGO_PASSWORD';
|
package/dist/guards/index.d.ts
CHANGED
package/dist/guards/index.js
CHANGED
|
@@ -14,7 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./internal.guard"), exports);
|
|
18
|
-
__exportStar(require("./jwt.guard"), exports);
|
|
19
17
|
__exportStar(require("./perms.guard"), exports);
|
|
20
18
|
__exportStar(require("./puplic.guard"), exports);
|
|
@@ -14,7 +14,7 @@ const common_1 = require("@nestjs/common");
|
|
|
14
14
|
const core_1 = require("@nestjs/core");
|
|
15
15
|
const swagger_1 = require("@nestjs/swagger");
|
|
16
16
|
const itlab_functions_1 = require("itlab-functions");
|
|
17
|
-
const jwt_guard_1 = require("
|
|
17
|
+
const jwt_guard_1 = require("../modules/authentication/jwt/jwt.guard");
|
|
18
18
|
const META = 'itlab-internal-perms-guard';
|
|
19
19
|
const description = 'Insufficient permissions';
|
|
20
20
|
const status = common_1.HttpStatus.FORBIDDEN;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,11 +2,8 @@ export * from './exceptions';
|
|
|
2
2
|
export * from './guards';
|
|
3
3
|
export * from './http.logger';
|
|
4
4
|
export * from './interceptors';
|
|
5
|
-
export * from './itlab.interfaces';
|
|
6
|
-
export * from './itlab.module';
|
|
7
5
|
export * from './liveness.probe';
|
|
8
|
-
export * from './
|
|
6
|
+
export * from './modules';
|
|
9
7
|
export * from './pipes';
|
|
10
|
-
export * from './services';
|
|
11
8
|
export * from './swagger.config';
|
|
12
9
|
export * from './virtuals';
|
package/dist/index.js
CHANGED
|
@@ -18,11 +18,8 @@ __exportStar(require("./exceptions"), exports);
|
|
|
18
18
|
__exportStar(require("./guards"), exports);
|
|
19
19
|
__exportStar(require("./http.logger"), exports);
|
|
20
20
|
__exportStar(require("./interceptors"), exports);
|
|
21
|
-
__exportStar(require("./itlab.interfaces"), exports);
|
|
22
|
-
__exportStar(require("./itlab.module"), exports);
|
|
23
21
|
__exportStar(require("./liveness.probe"), exports);
|
|
24
|
-
__exportStar(require("./
|
|
22
|
+
__exportStar(require("./modules"), exports);
|
|
25
23
|
__exportStar(require("./pipes"), exports);
|
|
26
|
-
__exportStar(require("./services"), exports);
|
|
27
24
|
__exportStar(require("./swagger.config"), exports);
|
|
28
25
|
__exportStar(require("./virtuals"), exports);
|
|
@@ -0,0 +1,26 @@
|
|
|
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 AuthenticationModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.AuthenticationModule = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const internal_strategy_1 = require("./internal/internal.strategy");
|
|
13
|
+
const jwt_strategy_1 = require("./jwt/jwt.strategy");
|
|
14
|
+
let AuthenticationModule = AuthenticationModule_1 = class AuthenticationModule {
|
|
15
|
+
static forRoot(options) {
|
|
16
|
+
return {
|
|
17
|
+
global: options ? options.isGlobal : false,
|
|
18
|
+
module: AuthenticationModule_1,
|
|
19
|
+
providers: [internal_strategy_1.InternalStrategy, jwt_strategy_1.JwtStrategy],
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
AuthenticationModule = AuthenticationModule_1 = __decorate([
|
|
24
|
+
(0, common_1.Module)({})
|
|
25
|
+
], AuthenticationModule);
|
|
26
|
+
exports.AuthenticationModule = AuthenticationModule;
|
|
@@ -14,11 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
__exportStar(require("./
|
|
21
|
-
__exportStar(require("./
|
|
22
|
-
__exportStar(require("./populate.service"), exports);
|
|
23
|
-
__exportStar(require("./search.service"), exports);
|
|
24
|
-
__exportStar(require("./service-mapper.service"), exports);
|
|
17
|
+
exports.AuthenticationModule = void 0;
|
|
18
|
+
var authentication_module_1 = require("./authentication.module");
|
|
19
|
+
Object.defineProperty(exports, "AuthenticationModule", { enumerable: true, get: function () { return authentication_module_1.AuthenticationModule; } });
|
|
20
|
+
__exportStar(require("./internal"), exports);
|
|
21
|
+
__exportStar(require("./jwt"), exports);
|
|
@@ -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("./internal.decorators"), exports);
|
|
18
|
+
__exportStar(require("./internal.guard"), exports);
|
|
19
|
+
__exportStar(require("./internal.strategy"), exports);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { HttpStatus } from '@nestjs/common';
|
|
2
|
+
export declare const INTERNAL_HEADER_KEY = "X-itlab-k8s-auth";
|
|
3
|
+
export declare const INTERNAL_STRATEGY_NAME = "itlab-internal-auth";
|
|
4
|
+
export declare const INTERNAL_DESCRIPTION = "Application unauthorized";
|
|
5
|
+
export declare const INTERNAL_STATUS = HttpStatus.FORBIDDEN;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.INTERNAL_STATUS = exports.INTERNAL_DESCRIPTION = exports.INTERNAL_STRATEGY_NAME = exports.INTERNAL_HEADER_KEY = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
exports.INTERNAL_HEADER_KEY = 'X-itlab-k8s-auth';
|
|
6
|
+
exports.INTERNAL_STRATEGY_NAME = 'itlab-internal-auth';
|
|
7
|
+
exports.INTERNAL_DESCRIPTION = 'Application unauthorized';
|
|
8
|
+
exports.INTERNAL_STATUS = common_1.HttpStatus.FORBIDDEN;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Internal: () => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Internal = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
6
|
+
const internal_constants_1 = require("./internal.constants");
|
|
7
|
+
const internal_guard_1 = require("./internal.guard");
|
|
8
|
+
const Internal = () => (0, common_1.applyDecorators)((0, swagger_1.ApiBasicAuth)(internal_constants_1.INTERNAL_HEADER_KEY), (0, common_1.UseGuards)(internal_guard_1.InternalGuard), (0, swagger_1.ApiResponse)({ description: internal_constants_1.INTERNAL_DESCRIPTION, status: internal_constants_1.INTERNAL_STATUS }));
|
|
9
|
+
exports.Internal = Internal;
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.InternalGuard = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const passport_1 = require("@nestjs/passport");
|
|
12
|
+
const internal_constants_1 = require("./internal.constants");
|
|
13
|
+
let InternalGuard = class InternalGuard extends (0, passport_1.AuthGuard)(internal_constants_1.INTERNAL_STRATEGY_NAME) {
|
|
14
|
+
};
|
|
15
|
+
InternalGuard = __decorate([
|
|
16
|
+
(0, common_1.Injectable)()
|
|
17
|
+
], InternalGuard);
|
|
18
|
+
exports.InternalGuard = InternalGuard;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ConfigService } from '@nestjs/config';
|
|
2
|
+
import { Request } from 'express';
|
|
3
|
+
import { Strategy, VerifiedCallback } from 'passport-custom';
|
|
4
|
+
declare const InternalStrategy_base: new (...args: any[]) => Strategy;
|
|
5
|
+
export declare class InternalStrategy extends InternalStrategy_base {
|
|
6
|
+
private readonly configService;
|
|
7
|
+
constructor(configService: ConfigService);
|
|
8
|
+
validate(req: Request, done: VerifiedCallback): void;
|
|
9
|
+
}
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
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.InternalStrategy = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const config_1 = require("@nestjs/config");
|
|
15
|
+
const passport_1 = require("@nestjs/passport");
|
|
16
|
+
const passport_custom_1 = require("passport-custom");
|
|
17
|
+
const env_1 = require("../../../env");
|
|
18
|
+
const internal_constants_1 = require("./internal.constants");
|
|
19
|
+
let InternalStrategy = class InternalStrategy extends (0, passport_1.PassportStrategy)(passport_custom_1.Strategy, internal_constants_1.INTERNAL_STRATEGY_NAME) {
|
|
20
|
+
constructor(configService) {
|
|
21
|
+
super();
|
|
22
|
+
this.configService = configService;
|
|
23
|
+
}
|
|
24
|
+
validate(req, done) {
|
|
25
|
+
const headerToken = req.header(internal_constants_1.INTERNAL_HEADER_KEY);
|
|
26
|
+
const token = this.configService.getOrThrow(env_1.ENV_K8S_TOKEN);
|
|
27
|
+
if (token && token === headerToken)
|
|
28
|
+
return done(null, true);
|
|
29
|
+
return done(new common_1.HttpException(internal_constants_1.INTERNAL_DESCRIPTION, internal_constants_1.INTERNAL_STATUS), false);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
InternalStrategy = __decorate([
|
|
33
|
+
(0, common_1.Injectable)(),
|
|
34
|
+
__metadata("design:paramtypes", [config_1.ConfigService])
|
|
35
|
+
], InternalStrategy);
|
|
36
|
+
exports.InternalStrategy = InternalStrategy;
|
|
@@ -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("./jwt.decorators"), exports);
|
|
18
|
+
__exportStar(require("./jwt.guard"), exports);
|
|
19
|
+
__exportStar(require("./jwt.strategy"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { HttpStatus } from '@nestjs/common';
|
|
2
|
+
export declare const JWT_STRATEGY_NAME = "itlab-jwt-auth";
|
|
3
|
+
export declare const JWT_DESCRIPTION = "Unauthorized";
|
|
4
|
+
export declare const JWT_STATUS = HttpStatus.UNAUTHORIZED;
|
|
5
|
+
export declare class LabAccount {
|
|
6
|
+
id: string;
|
|
7
|
+
perms: string[];
|
|
8
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LabAccount = exports.JWT_STATUS = exports.JWT_DESCRIPTION = exports.JWT_STRATEGY_NAME = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
exports.JWT_STRATEGY_NAME = 'itlab-jwt-auth';
|
|
6
|
+
exports.JWT_DESCRIPTION = 'Unauthorized';
|
|
7
|
+
exports.JWT_STATUS = common_1.HttpStatus.UNAUTHORIZED;
|
|
8
|
+
class LabAccount {
|
|
9
|
+
}
|
|
10
|
+
exports.LabAccount = LabAccount;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const Jwt: () => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
2
|
+
export declare const Account: (...dataOrPipes: (string | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
|
|
3
|
+
export declare const AccountId: () => ParameterDecorator;
|
|
4
|
+
export declare const AccountPerms: () => ParameterDecorator;
|
|
5
|
+
export declare const JwtToken: (...dataOrPipes: any[]) => ParameterDecorator;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JwtToken = exports.AccountPerms = exports.AccountId = exports.Account = exports.Jwt = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
6
|
+
const jwt_constants_1 = require("./jwt.constants");
|
|
7
|
+
const jwt_guard_1 = require("./jwt.guard");
|
|
8
|
+
const Jwt = () => (0, common_1.applyDecorators)((0, swagger_1.ApiBearerAuth)(), (0, common_1.UseGuards)(jwt_guard_1.JwtGuard), (0, swagger_1.ApiUnauthorizedResponse)({ description: jwt_constants_1.JWT_DESCRIPTION, status: jwt_constants_1.JWT_STATUS }));
|
|
9
|
+
exports.Jwt = Jwt;
|
|
10
|
+
exports.Account = (0, common_1.createParamDecorator)((param, ctx) => {
|
|
11
|
+
const { user } = ctx.switchToHttp().getRequest();
|
|
12
|
+
return param ? user === null || user === void 0 ? void 0 : user[param] : user;
|
|
13
|
+
});
|
|
14
|
+
const AccountId = () => (0, exports.Account)('id');
|
|
15
|
+
exports.AccountId = AccountId;
|
|
16
|
+
const AccountPerms = () => (0, exports.Account)('perms');
|
|
17
|
+
exports.AccountPerms = AccountPerms;
|
|
18
|
+
exports.JwtToken = (0, common_1.createParamDecorator)((_, ctx) => {
|
|
19
|
+
const h = ctx.switchToHttp().getRequest().header('Authorization');
|
|
20
|
+
return h.replace('Bearer ', '');
|
|
21
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import { Reflector } from '@nestjs/core';
|
|
3
|
+
declare const JwtGuard_base: import("@nestjs/passport").Type<import("@nestjs/passport").IAuthGuard>;
|
|
4
|
+
export declare class JwtGuard extends JwtGuard_base {
|
|
5
|
+
private readonly reflector;
|
|
6
|
+
constructor(reflector: Reflector);
|
|
7
|
+
canActivate(context: ExecutionContext): boolean | Promise<boolean> | import("rxjs").Observable<boolean>;
|
|
8
|
+
}
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
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.JwtGuard = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const core_1 = require("@nestjs/core");
|
|
15
|
+
const passport_1 = require("@nestjs/passport");
|
|
16
|
+
const puplic_guard_1 = require("../../../guards/puplic.guard");
|
|
17
|
+
const jwt_constants_1 = require("./jwt.constants");
|
|
18
|
+
let JwtGuard = class JwtGuard extends (0, passport_1.AuthGuard)(jwt_constants_1.JWT_STRATEGY_NAME) {
|
|
19
|
+
constructor(reflector) {
|
|
20
|
+
super();
|
|
21
|
+
this.reflector = reflector;
|
|
22
|
+
}
|
|
23
|
+
canActivate(context) {
|
|
24
|
+
const isPublic = this.reflector.getAllAndOverride(puplic_guard_1.IS_PUBLIC_META, [
|
|
25
|
+
context.getHandler(),
|
|
26
|
+
context.getClass(),
|
|
27
|
+
]);
|
|
28
|
+
if (isPublic)
|
|
29
|
+
return true;
|
|
30
|
+
return super.canActivate(context);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
JwtGuard = __decorate([
|
|
34
|
+
(0, common_1.Injectable)(),
|
|
35
|
+
__metadata("design:paramtypes", [core_1.Reflector])
|
|
36
|
+
], JwtGuard);
|
|
37
|
+
exports.JwtGuard = JwtGuard;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ConfigService } from '@nestjs/config';
|
|
2
|
+
import { LabAccount } from './jwt.constants';
|
|
3
|
+
declare const JwtStrategy_base: new (...args: any[]) => any;
|
|
4
|
+
export declare class JwtStrategy extends JwtStrategy_base {
|
|
5
|
+
private readonly configService;
|
|
6
|
+
constructor(configService: ConfigService);
|
|
7
|
+
validate(payload: any): LabAccount;
|
|
8
|
+
}
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
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.JwtStrategy = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const config_1 = require("@nestjs/config");
|
|
15
|
+
const passport_1 = require("@nestjs/passport");
|
|
16
|
+
const passport_jwt_1 = require("passport-jwt");
|
|
17
|
+
const env_1 = require("../../../env");
|
|
18
|
+
const jwt_constants_1 = require("./jwt.constants");
|
|
19
|
+
let JwtStrategy = class JwtStrategy extends (0, passport_1.PassportStrategy)(passport_jwt_1.Strategy, jwt_constants_1.JWT_STRATEGY_NAME) {
|
|
20
|
+
constructor(configService) {
|
|
21
|
+
super({
|
|
22
|
+
jwtFromRequest: passport_jwt_1.ExtractJwt.fromAuthHeaderAsBearerToken(),
|
|
23
|
+
secretOrKey: configService.getOrThrow(env_1.ENV_JWT_SECRET),
|
|
24
|
+
});
|
|
25
|
+
this.configService = configService;
|
|
26
|
+
}
|
|
27
|
+
validate(payload) {
|
|
28
|
+
return { id: payload.id, perms: payload.perms || [] };
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
JwtStrategy = __decorate([
|
|
32
|
+
(0, common_1.Injectable)(),
|
|
33
|
+
__metadata("design:paramtypes", [config_1.ConfigService])
|
|
34
|
+
], JwtStrategy);
|
|
35
|
+
exports.JwtStrategy = JwtStrategy;
|
|
@@ -0,0 +1,69 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
var DatabaseModule_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.DatabaseModule = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const config_1 = require("@nestjs/config");
|
|
16
|
+
const mongoose_1 = require("@nestjs/mongoose");
|
|
17
|
+
const mongoose_2 = __importDefault(require("mongoose"));
|
|
18
|
+
const path_1 = require("path");
|
|
19
|
+
const model_service_1 = require("./model-service/model.service");
|
|
20
|
+
const populate_service_1 = require("./populate-service/populate.service");
|
|
21
|
+
const service_mapper_service_1 = require("./service-mapper-service/service-mapper.service");
|
|
22
|
+
let DatabaseModule = DatabaseModule_1 = class DatabaseModule {
|
|
23
|
+
static forRoot(options) {
|
|
24
|
+
return {
|
|
25
|
+
global: true,
|
|
26
|
+
module: DatabaseModule_1,
|
|
27
|
+
providers: [model_service_1.ModelService, populate_service_1.PopulateService, service_mapper_service_1.ServiceMapperService],
|
|
28
|
+
exports: [model_service_1.ModelService, populate_service_1.PopulateService, service_mapper_service_1.ServiceMapperService],
|
|
29
|
+
imports: [
|
|
30
|
+
mongoose_1.MongooseModule.forRootAsync({
|
|
31
|
+
inject: [config_1.ConfigService],
|
|
32
|
+
useFactory: (configService) => {
|
|
33
|
+
mongoose_2.default.set('strictQuery', true);
|
|
34
|
+
const production = configService.getOrThrow('NODE_ENV', 'development') === 'production';
|
|
35
|
+
if (production)
|
|
36
|
+
this.logger.log('Running in production mode... Connecting internally without tls');
|
|
37
|
+
else
|
|
38
|
+
this.logger.log('Running in development mode... Connecting externally with tls');
|
|
39
|
+
const uri = configService.getOrThrow('MONGO_SRV');
|
|
40
|
+
const username = configService.getOrThrow('MONGO_USERNAME');
|
|
41
|
+
const password = configService.getOrThrow('MONGO_PASSWORD');
|
|
42
|
+
const generalOpts = {
|
|
43
|
+
uri: `mongodb+srv://${uri}`,
|
|
44
|
+
auth: { username, password },
|
|
45
|
+
appName: options.appName,
|
|
46
|
+
dbName: options.dbName,
|
|
47
|
+
authMechanism: 'SCRAM-SHA-256',
|
|
48
|
+
authSource: 'admin',
|
|
49
|
+
replicaSet: 'organisation-hub-mongodb',
|
|
50
|
+
serverSelectionTimeoutMS: 2000,
|
|
51
|
+
};
|
|
52
|
+
const certDir = () => configService.getOrThrow('MONGO_CERT_DIR');
|
|
53
|
+
const tlsOpts = {
|
|
54
|
+
tls: true,
|
|
55
|
+
tlsCAFile: (0, path_1.join)(process.cwd(), certDir(), 'ca.crt'),
|
|
56
|
+
tlsCertificateKeyFile: (0, path_1.join)(process.cwd(), certDir(), 'certificate-key.pem'),
|
|
57
|
+
};
|
|
58
|
+
return Object.assign({}, generalOpts, production ? {} : tlsOpts);
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
61
|
+
],
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
DatabaseModule.logger = new common_1.Logger(DatabaseModule_1.name);
|
|
66
|
+
DatabaseModule = DatabaseModule_1 = __decorate([
|
|
67
|
+
(0, common_1.Module)({})
|
|
68
|
+
], DatabaseModule);
|
|
69
|
+
exports.DatabaseModule = DatabaseModule;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { DatabaseModule } from './database.module';
|
|
2
|
+
export { DatabaseModuleOptions } from './database.module-options';
|
|
3
|
+
export { ModelService } from './model-service/model.service';
|
|
4
|
+
export { PopulateService } from './populate-service/populate.service';
|
|
5
|
+
export { ServiceMapperService } from './service-mapper-service/service-mapper.service';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ServiceMapperService = exports.PopulateService = exports.ModelService = exports.DatabaseModule = void 0;
|
|
4
|
+
var database_module_1 = require("./database.module");
|
|
5
|
+
Object.defineProperty(exports, "DatabaseModule", { enumerable: true, get: function () { return database_module_1.DatabaseModule; } });
|
|
6
|
+
var model_service_1 = require("./model-service/model.service");
|
|
7
|
+
Object.defineProperty(exports, "ModelService", { enumerable: true, get: function () { return model_service_1.ModelService; } });
|
|
8
|
+
var populate_service_1 = require("./populate-service/populate.service");
|
|
9
|
+
Object.defineProperty(exports, "PopulateService", { enumerable: true, get: function () { return populate_service_1.PopulateService; } });
|
|
10
|
+
var service_mapper_service_1 = require("./service-mapper-service/service-mapper.service");
|
|
11
|
+
Object.defineProperty(exports, "ServiceMapperService", { enumerable: true, get: function () { return service_mapper_service_1.ServiceMapperService; } });
|