@nestia/core 1.1.0 → 1.1.2-dev.20230503
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/lib/decorators/DynamicModule.d.ts +26 -23
- package/lib/decorators/DynamicModule.js +103 -103
- package/lib/decorators/DynamicModule.js.map +1 -1
- package/lib/decorators/EncryptedBody.d.ts +23 -23
- package/lib/decorators/EncryptedBody.js +125 -125
- package/lib/decorators/EncryptedController.d.ts +31 -31
- package/lib/decorators/EncryptedController.js +41 -41
- package/lib/decorators/EncryptedModule.d.ts +52 -49
- package/lib/decorators/EncryptedModule.js +161 -161
- package/lib/decorators/EncryptedModule.js.map +1 -1
- package/lib/decorators/EncryptedRoute.d.ts +78 -78
- package/lib/decorators/EncryptedRoute.js +216 -216
- package/lib/decorators/PlainBody.d.ts +22 -22
- package/lib/decorators/PlainBody.js +82 -82
- package/lib/decorators/TypedBody.d.ts +16 -16
- package/lib/decorators/TypedBody.js +94 -94
- package/lib/decorators/TypedParam.d.ts +31 -31
- package/lib/decorators/TypedParam.js +68 -65
- package/lib/decorators/TypedParam.js.map +1 -1
- package/lib/decorators/TypedQuery.d.ts +14 -14
- package/lib/decorators/TypedQuery.js +124 -103
- package/lib/decorators/TypedQuery.js.map +1 -1
- package/lib/decorators/TypedRoute.d.ts +72 -72
- package/lib/decorators/TypedRoute.js +185 -185
- package/lib/decorators/internal/EncryptedConstant.d.ts +1 -1
- package/lib/decorators/internal/EncryptedConstant.js +7 -7
- package/lib/decorators/internal/TransformError.d.ts +1 -1
- package/lib/decorators/internal/TransformError.js +10 -10
- package/lib/decorators/internal/TransformError.js.map +1 -1
- package/lib/decorators/internal/get_path_and_stringify.d.ts +1 -1
- package/lib/decorators/internal/get_path_and_stringify.js +78 -78
- package/lib/decorators/internal/headers_to_object.d.ts +3 -3
- package/lib/decorators/internal/headers_to_object.js +49 -49
- package/lib/decorators/internal/load_controller.d.ts +5 -2
- package/lib/decorators/internal/load_controller.js +152 -151
- package/lib/decorators/internal/load_controller.js.map +1 -1
- package/lib/decorators/internal/route_error.d.ts +2 -2
- package/lib/decorators/internal/route_error.js +86 -86
- package/lib/decorators/internal/validate_request_body.d.ts +2 -2
- package/lib/decorators/internal/validate_request_body.js +57 -57
- package/lib/index.d.ts +3 -3
- package/lib/index.js +31 -31
- package/lib/module.d.ts +12 -12
- package/lib/module.js +28 -28
- package/lib/options/INestiaTransformOptions.d.ts +4 -4
- package/lib/options/INestiaTransformOptions.js +2 -2
- package/lib/options/INestiaTransformProject.d.ts +5 -5
- package/lib/options/INestiaTransformProject.js +2 -2
- package/lib/options/IRequestBodyValidator.d.ts +16 -16
- package/lib/options/IRequestBodyValidator.js +2 -2
- package/lib/options/IResponseBodyStringifier.d.ts +20 -20
- package/lib/options/IResponseBodyStringifier.js +2 -2
- package/lib/programmers/TypedBodyProgrammer.d.ts +5 -5
- package/lib/programmers/TypedBodyProgrammer.js +47 -45
- package/lib/programmers/TypedBodyProgrammer.js.map +1 -1
- package/lib/programmers/TypedParamProgrammer.d.ts +5 -5
- package/lib/programmers/TypedParamProgrammer.js +107 -107
- package/lib/programmers/TypedQueryProgrammer.d.ts +5 -5
- package/lib/programmers/TypedQueryProgrammer.js +263 -260
- package/lib/programmers/TypedQueryProgrammer.js.map +1 -1
- package/lib/programmers/TypedRouteProgrammer.d.ts +5 -5
- package/lib/programmers/TypedRouteProgrammer.js +49 -47
- package/lib/programmers/TypedRouteProgrammer.js.map +1 -1
- package/lib/transform.d.ts +3 -3
- package/lib/transform.js +20 -20
- package/lib/transformers/FileTransformer.d.ts +5 -5
- package/lib/transformers/FileTransformer.js +32 -32
- package/lib/transformers/MethodDecoratorTransformer.d.ts +5 -5
- package/lib/transformers/MethodDecoratorTransformer.js +87 -87
- package/lib/transformers/MethodDecoratorTransformer.js.map +1 -1
- package/lib/transformers/MethodTransformer.d.ts +5 -5
- package/lib/transformers/MethodTransformer.js +54 -54
- package/lib/transformers/NodeTransformer.d.ts +5 -5
- package/lib/transformers/NodeTransformer.js +20 -20
- package/lib/transformers/ParameterDecoratorTransformer.d.ts +5 -5
- package/lib/transformers/ParameterDecoratorTransformer.js +65 -65
- package/lib/transformers/ParameterDecoratorTransformer.js.map +1 -1
- package/lib/transformers/ParameterTransformer.d.ts +5 -5
- package/lib/transformers/ParameterTransformer.js +33 -33
- package/lib/typings/Creator.d.ts +3 -3
- package/lib/typings/Creator.js +2 -2
- package/lib/utils/ExceptionManager.d.ts +64 -64
- package/lib/utils/ExceptionManager.js +112 -112
- package/lib/utils/Singleton.d.ts +1 -1
- package/lib/utils/Singleton.js +23 -23
- package/lib/utils/SourceFinder.d.ts +9 -0
- package/lib/utils/SourceFinder.js +239 -0
- package/lib/utils/SourceFinder.js.map +1 -0
- package/package.json +7 -7
- package/src/decorators/DynamicModule.ts +1 -1
- package/src/decorators/EncryptedModule.ts +1 -1
- package/src/decorators/TypedParam.ts +4 -1
- package/src/decorators/TypedQuery.ts +27 -4
- package/src/decorators/internal/TransformError.ts +1 -1
- package/src/decorators/internal/load_controller.ts +32 -25
- package/src/programmers/TypedBodyProgrammer.ts +2 -1
- package/src/programmers/TypedQueryProgrammer.ts +3 -1
- package/src/programmers/TypedRouteProgrammer.ts +2 -1
- package/src/transformers/MethodDecoratorTransformer.ts +1 -2
- package/src/transformers/ParameterDecoratorTransformer.ts +3 -3
- package/src/utils/SourceFinder.ts +60 -0
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EncryptedController = void 0;
|
|
4
|
-
var common_1 = require("@nestjs/common");
|
|
5
|
-
var EncryptedConstant_1 = require("./internal/EncryptedConstant");
|
|
6
|
-
/**
|
|
7
|
-
* Encrypted controller.
|
|
8
|
-
*
|
|
9
|
-
* `EncryptedController` is an extension of the {@link nest.Controller} class decorator
|
|
10
|
-
* function who configures encryption password of the AES-128/256 algorithm. The
|
|
11
|
-
* encryption algorithm and password would be used by {@link EncryptedRoute} and
|
|
12
|
-
* {@link EncryptedBody} to encrypt the request and response body of the HTTP protocol.
|
|
13
|
-
*
|
|
14
|
-
* > However, if you've configure the {@link IEncryptionPassword.disabled} to be `true`,
|
|
15
|
-
* > you can disable the encryption and decryption algorithm. Therefore, when the
|
|
16
|
-
* > {@link IEncryptionPassword.disable} becomes the `true`, content like request and
|
|
17
|
-
* > response body would be considered as a plain text instead.
|
|
18
|
-
*
|
|
19
|
-
* By the way, you can configure the encryption password in the global level by using
|
|
20
|
-
* {@link EncryptedModule} instead of the {@link nest.Module} in the module level. In
|
|
21
|
-
* that case, you don't need to use this `EncryptedController` more. Just use the
|
|
22
|
-
* {@link nest.Controller} without duplicated encryption password definitions.
|
|
23
|
-
*
|
|
24
|
-
* Of course, if you want to use different encryption password from the
|
|
25
|
-
* {@link EncryptedModule}, this `EncryptedController` would be useful again. Therefore,
|
|
26
|
-
* I recommend to use this `EncryptedController` decorator function only when you must
|
|
27
|
-
* configure different encryption password from the {@link EncryptedModule}.
|
|
28
|
-
*
|
|
29
|
-
* @param path Path of the HTTP request
|
|
30
|
-
* @param password Encryption password or its getter function
|
|
31
|
-
* @returns Class decorator
|
|
32
|
-
*
|
|
33
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
34
|
-
*/
|
|
35
|
-
function EncryptedController(path, password) {
|
|
36
|
-
return function (target) {
|
|
37
|
-
Reflect.defineMetadata(EncryptedConstant_1.ENCRYPTION_METADATA_KEY, password, target);
|
|
38
|
-
(0, common_1.Controller)(path)(target);
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
exports.EncryptedController = EncryptedController;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EncryptedController = void 0;
|
|
4
|
+
var common_1 = require("@nestjs/common");
|
|
5
|
+
var EncryptedConstant_1 = require("./internal/EncryptedConstant");
|
|
6
|
+
/**
|
|
7
|
+
* Encrypted controller.
|
|
8
|
+
*
|
|
9
|
+
* `EncryptedController` is an extension of the {@link nest.Controller} class decorator
|
|
10
|
+
* function who configures encryption password of the AES-128/256 algorithm. The
|
|
11
|
+
* encryption algorithm and password would be used by {@link EncryptedRoute} and
|
|
12
|
+
* {@link EncryptedBody} to encrypt the request and response body of the HTTP protocol.
|
|
13
|
+
*
|
|
14
|
+
* > However, if you've configure the {@link IEncryptionPassword.disabled} to be `true`,
|
|
15
|
+
* > you can disable the encryption and decryption algorithm. Therefore, when the
|
|
16
|
+
* > {@link IEncryptionPassword.disable} becomes the `true`, content like request and
|
|
17
|
+
* > response body would be considered as a plain text instead.
|
|
18
|
+
*
|
|
19
|
+
* By the way, you can configure the encryption password in the global level by using
|
|
20
|
+
* {@link EncryptedModule} instead of the {@link nest.Module} in the module level. In
|
|
21
|
+
* that case, you don't need to use this `EncryptedController` more. Just use the
|
|
22
|
+
* {@link nest.Controller} without duplicated encryption password definitions.
|
|
23
|
+
*
|
|
24
|
+
* Of course, if you want to use different encryption password from the
|
|
25
|
+
* {@link EncryptedModule}, this `EncryptedController` would be useful again. Therefore,
|
|
26
|
+
* I recommend to use this `EncryptedController` decorator function only when you must
|
|
27
|
+
* configure different encryption password from the {@link EncryptedModule}.
|
|
28
|
+
*
|
|
29
|
+
* @param path Path of the HTTP request
|
|
30
|
+
* @param password Encryption password or its getter function
|
|
31
|
+
* @returns Class decorator
|
|
32
|
+
*
|
|
33
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
34
|
+
*/
|
|
35
|
+
function EncryptedController(path, password) {
|
|
36
|
+
return function (target) {
|
|
37
|
+
Reflect.defineMetadata(EncryptedConstant_1.ENCRYPTION_METADATA_KEY, password, target);
|
|
38
|
+
(0, common_1.Controller)(path)(target);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
exports.EncryptedController = EncryptedController;
|
|
42
42
|
//# sourceMappingURL=EncryptedController.js.map
|
|
@@ -1,49 +1,52 @@
|
|
|
1
|
-
import { IEncryptionPassword } from "@nestia/fetcher/lib/IEncryptionPassword";
|
|
2
|
-
import { Module } from "@nestjs/common";
|
|
3
|
-
/**
|
|
4
|
-
* Encrypted module.
|
|
5
|
-
*
|
|
6
|
-
* `EncryptedModule` is an extension of the {@link Module} class decorator function
|
|
7
|
-
* who configures encryption password of the AES-128/256 algorithm. The encryption
|
|
8
|
-
* algorithm and password would be used by {@link EncryptedRoute} and {@link EncryptedBody}
|
|
9
|
-
* to encrypt the request and response bod of the HTTP protocol.
|
|
10
|
-
*
|
|
11
|
-
* By using this `EncryptedModule` decorator function, all of the
|
|
12
|
-
* {@link Controller controllers} configured in the *metadata* would be automatically
|
|
13
|
-
* changed to the {@link EncryptedController} with the *password*. If there're some
|
|
14
|
-
* original {@link EncryptedController} decorated classes in the *metadata*, their
|
|
15
|
-
* encryption password would be kept.
|
|
16
|
-
*
|
|
17
|
-
* Therefore, if you're planning to place original {@link EncryptedController} decorated
|
|
18
|
-
* classes in the *metadata*, I hope them to have different encryption password from the
|
|
19
|
-
* module level. If not, I recommend you use the {@link Controller} decorator
|
|
20
|
-
* function instead.
|
|
21
|
-
*
|
|
22
|
-
* In addition, the `EncryptedModule` supports a convenient dynamic controller importing
|
|
23
|
-
* function, {@link EncryptedModule.dynamic}. If you utilize the function with directory
|
|
24
|
-
* path of the controller classes, it imports and configures the controller classes into
|
|
25
|
-
* the `Module`, automatically.
|
|
26
|
-
*
|
|
27
|
-
* @param metadata Module configuration metadata
|
|
28
|
-
* @param password Encryption password or its getter function
|
|
29
|
-
* @returns Class decorator
|
|
30
|
-
*
|
|
31
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
32
|
-
*/
|
|
33
|
-
export declare function EncryptedModule(metadata: Parameters<typeof Module>[0], password: IEncryptionPassword | IEncryptionPassword.Closure): ClassDecorator;
|
|
34
|
-
export declare namespace EncryptedModule {
|
|
35
|
-
/**
|
|
36
|
-
* Dynamic encrypted module.
|
|
37
|
-
*
|
|
38
|
-
* `EncryptedModule.dynamic` is an extension of the {@link EncryptedModule} function
|
|
39
|
-
* who configures controller classes by the dynamic importing. By specifying directory
|
|
40
|
-
* path of the controller classes, those controllers would be automatically imported
|
|
41
|
-
* and configured.
|
|
42
|
-
*
|
|
43
|
-
* @param path Directory path of the controller classes
|
|
44
|
-
* @param password Encryption password or its getter function
|
|
45
|
-
* @param options Additional options except controller
|
|
46
|
-
* @returns Class decorated module instance
|
|
47
|
-
*/
|
|
48
|
-
function dynamic(path: string
|
|
49
|
-
|
|
1
|
+
import { IEncryptionPassword } from "@nestia/fetcher/lib/IEncryptionPassword";
|
|
2
|
+
import { Module } from "@nestjs/common";
|
|
3
|
+
/**
|
|
4
|
+
* Encrypted module.
|
|
5
|
+
*
|
|
6
|
+
* `EncryptedModule` is an extension of the {@link Module} class decorator function
|
|
7
|
+
* who configures encryption password of the AES-128/256 algorithm. The encryption
|
|
8
|
+
* algorithm and password would be used by {@link EncryptedRoute} and {@link EncryptedBody}
|
|
9
|
+
* to encrypt the request and response bod of the HTTP protocol.
|
|
10
|
+
*
|
|
11
|
+
* By using this `EncryptedModule` decorator function, all of the
|
|
12
|
+
* {@link Controller controllers} configured in the *metadata* would be automatically
|
|
13
|
+
* changed to the {@link EncryptedController} with the *password*. If there're some
|
|
14
|
+
* original {@link EncryptedController} decorated classes in the *metadata*, their
|
|
15
|
+
* encryption password would be kept.
|
|
16
|
+
*
|
|
17
|
+
* Therefore, if you're planning to place original {@link EncryptedController} decorated
|
|
18
|
+
* classes in the *metadata*, I hope them to have different encryption password from the
|
|
19
|
+
* module level. If not, I recommend you use the {@link Controller} decorator
|
|
20
|
+
* function instead.
|
|
21
|
+
*
|
|
22
|
+
* In addition, the `EncryptedModule` supports a convenient dynamic controller importing
|
|
23
|
+
* function, {@link EncryptedModule.dynamic}. If you utilize the function with directory
|
|
24
|
+
* path of the controller classes, it imports and configures the controller classes into
|
|
25
|
+
* the `Module`, automatically.
|
|
26
|
+
*
|
|
27
|
+
* @param metadata Module configuration metadata
|
|
28
|
+
* @param password Encryption password or its getter function
|
|
29
|
+
* @returns Class decorator
|
|
30
|
+
*
|
|
31
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
32
|
+
*/
|
|
33
|
+
export declare function EncryptedModule(metadata: Parameters<typeof Module>[0], password: IEncryptionPassword | IEncryptionPassword.Closure): ClassDecorator;
|
|
34
|
+
export declare namespace EncryptedModule {
|
|
35
|
+
/**
|
|
36
|
+
* Dynamic encrypted module.
|
|
37
|
+
*
|
|
38
|
+
* `EncryptedModule.dynamic` is an extension of the {@link EncryptedModule} function
|
|
39
|
+
* who configures controller classes by the dynamic importing. By specifying directory
|
|
40
|
+
* path of the controller classes, those controllers would be automatically imported
|
|
41
|
+
* and configured.
|
|
42
|
+
*
|
|
43
|
+
* @param path Directory path of the controller classes
|
|
44
|
+
* @param password Encryption password or its getter function
|
|
45
|
+
* @param options Additional options except controller
|
|
46
|
+
* @returns Class decorated module instance
|
|
47
|
+
*/
|
|
48
|
+
function dynamic(path: string | string[] | {
|
|
49
|
+
include: string[];
|
|
50
|
+
exclude?: string[];
|
|
51
|
+
}, password: IEncryptionPassword | IEncryptionPassword.Closure, options?: Omit<Parameters<typeof Module>[0], "controllers">): Promise<object>;
|
|
52
|
+
}
|
|
@@ -1,162 +1,162 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
14
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
15
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
16
|
-
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;
|
|
17
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
18
|
-
};
|
|
19
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
20
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
21
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
22
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
23
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
24
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
25
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
29
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
30
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
31
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
32
|
-
function step(op) {
|
|
33
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
34
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
35
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
36
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
37
|
-
switch (op[0]) {
|
|
38
|
-
case 0: case 1: t = op; break;
|
|
39
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
40
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
41
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
42
|
-
default:
|
|
43
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
44
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
45
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
46
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
47
|
-
if (t[2]) _.ops.pop();
|
|
48
|
-
_.trys.pop(); continue;
|
|
49
|
-
}
|
|
50
|
-
op = body.call(thisArg, _);
|
|
51
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
52
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
var __values = (this && this.__values) || function(o) {
|
|
56
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
57
|
-
if (m) return m.call(o);
|
|
58
|
-
if (o && typeof o.length === "number") return {
|
|
59
|
-
next: function () {
|
|
60
|
-
if (o && i >= o.length) o = void 0;
|
|
61
|
-
return { value: o && o[i++], done: !o };
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
65
|
-
};
|
|
66
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
67
|
-
exports.EncryptedModule = void 0;
|
|
68
|
-
var common_1 = require("@nestjs/common");
|
|
69
|
-
var EncryptedConstant_1 = require("./internal/EncryptedConstant");
|
|
70
|
-
var load_controller_1 = require("./internal/load_controller");
|
|
71
|
-
/**
|
|
72
|
-
* Encrypted module.
|
|
73
|
-
*
|
|
74
|
-
* `EncryptedModule` is an extension of the {@link Module} class decorator function
|
|
75
|
-
* who configures encryption password of the AES-128/256 algorithm. The encryption
|
|
76
|
-
* algorithm and password would be used by {@link EncryptedRoute} and {@link EncryptedBody}
|
|
77
|
-
* to encrypt the request and response bod of the HTTP protocol.
|
|
78
|
-
*
|
|
79
|
-
* By using this `EncryptedModule` decorator function, all of the
|
|
80
|
-
* {@link Controller controllers} configured in the *metadata* would be automatically
|
|
81
|
-
* changed to the {@link EncryptedController} with the *password*. If there're some
|
|
82
|
-
* original {@link EncryptedController} decorated classes in the *metadata*, their
|
|
83
|
-
* encryption password would be kept.
|
|
84
|
-
*
|
|
85
|
-
* Therefore, if you're planning to place original {@link EncryptedController} decorated
|
|
86
|
-
* classes in the *metadata*, I hope them to have different encryption password from the
|
|
87
|
-
* module level. If not, I recommend you use the {@link Controller} decorator
|
|
88
|
-
* function instead.
|
|
89
|
-
*
|
|
90
|
-
* In addition, the `EncryptedModule` supports a convenient dynamic controller importing
|
|
91
|
-
* function, {@link EncryptedModule.dynamic}. If you utilize the function with directory
|
|
92
|
-
* path of the controller classes, it imports and configures the controller classes into
|
|
93
|
-
* the `Module`, automatically.
|
|
94
|
-
*
|
|
95
|
-
* @param metadata Module configuration metadata
|
|
96
|
-
* @param password Encryption password or its getter function
|
|
97
|
-
* @returns Class decorator
|
|
98
|
-
*
|
|
99
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
100
|
-
*/
|
|
101
|
-
function EncryptedModule(metadata, password) {
|
|
102
|
-
return function (target) {
|
|
103
|
-
var e_1, _a;
|
|
104
|
-
(0, common_1.Module)(metadata)(target);
|
|
105
|
-
if (metadata.controllers === undefined)
|
|
106
|
-
return;
|
|
107
|
-
try {
|
|
108
|
-
for (var _b = __values(metadata.controllers), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
109
|
-
var c = _c.value;
|
|
110
|
-
if (Reflect.hasMetadata(EncryptedConstant_1.ENCRYPTION_METADATA_KEY, c) === false)
|
|
111
|
-
Reflect.defineMetadata(EncryptedConstant_1.ENCRYPTION_METADATA_KEY, password, c);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
115
|
-
finally {
|
|
116
|
-
try {
|
|
117
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
118
|
-
}
|
|
119
|
-
finally { if (e_1) throw e_1.error; }
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
exports.EncryptedModule = EncryptedModule;
|
|
124
|
-
(function (EncryptedModule) {
|
|
125
|
-
/**
|
|
126
|
-
* Dynamic encrypted module.
|
|
127
|
-
*
|
|
128
|
-
* `EncryptedModule.dynamic` is an extension of the {@link EncryptedModule} function
|
|
129
|
-
* who configures controller classes by the dynamic importing. By specifying directory
|
|
130
|
-
* path of the controller classes, those controllers would be automatically imported
|
|
131
|
-
* and configured.
|
|
132
|
-
*
|
|
133
|
-
* @param path Directory path of the controller classes
|
|
134
|
-
* @param password Encryption password or its getter function
|
|
135
|
-
* @param options Additional options except controller
|
|
136
|
-
* @returns Class decorated module instance
|
|
137
|
-
*/
|
|
138
|
-
function dynamic(path, password, options) {
|
|
139
|
-
if (options === void 0) { options = {}; }
|
|
140
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
141
|
-
var controllers, NestiaModule;
|
|
142
|
-
return __generator(this, function (_a) {
|
|
143
|
-
switch (_a.label) {
|
|
144
|
-
case 0: return [4 /*yield*/, (0, load_controller_1.load_controllers)(path)];
|
|
145
|
-
case 1:
|
|
146
|
-
controllers = _a.sent();
|
|
147
|
-
NestiaModule = /** @class */ (function () {
|
|
148
|
-
function NestiaModule() {
|
|
149
|
-
}
|
|
150
|
-
NestiaModule = __decorate([
|
|
151
|
-
EncryptedModule(__assign(__assign({}, options), { controllers: controllers }), password)
|
|
152
|
-
], NestiaModule);
|
|
153
|
-
return NestiaModule;
|
|
154
|
-
}());
|
|
155
|
-
return [2 /*return*/, NestiaModule];
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
EncryptedModule.dynamic = dynamic;
|
|
161
|
-
})(EncryptedModule = exports.EncryptedModule || (exports.EncryptedModule = {}));
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
14
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
15
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
16
|
+
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;
|
|
17
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
18
|
+
};
|
|
19
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
20
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
21
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
22
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
23
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
24
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
25
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
29
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
30
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
31
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
32
|
+
function step(op) {
|
|
33
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
34
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
35
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
36
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
37
|
+
switch (op[0]) {
|
|
38
|
+
case 0: case 1: t = op; break;
|
|
39
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
40
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
41
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
42
|
+
default:
|
|
43
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
44
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
45
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
46
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
47
|
+
if (t[2]) _.ops.pop();
|
|
48
|
+
_.trys.pop(); continue;
|
|
49
|
+
}
|
|
50
|
+
op = body.call(thisArg, _);
|
|
51
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
52
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var __values = (this && this.__values) || function(o) {
|
|
56
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
57
|
+
if (m) return m.call(o);
|
|
58
|
+
if (o && typeof o.length === "number") return {
|
|
59
|
+
next: function () {
|
|
60
|
+
if (o && i >= o.length) o = void 0;
|
|
61
|
+
return { value: o && o[i++], done: !o };
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
65
|
+
};
|
|
66
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
67
|
+
exports.EncryptedModule = void 0;
|
|
68
|
+
var common_1 = require("@nestjs/common");
|
|
69
|
+
var EncryptedConstant_1 = require("./internal/EncryptedConstant");
|
|
70
|
+
var load_controller_1 = require("./internal/load_controller");
|
|
71
|
+
/**
|
|
72
|
+
* Encrypted module.
|
|
73
|
+
*
|
|
74
|
+
* `EncryptedModule` is an extension of the {@link Module} class decorator function
|
|
75
|
+
* who configures encryption password of the AES-128/256 algorithm. The encryption
|
|
76
|
+
* algorithm and password would be used by {@link EncryptedRoute} and {@link EncryptedBody}
|
|
77
|
+
* to encrypt the request and response bod of the HTTP protocol.
|
|
78
|
+
*
|
|
79
|
+
* By using this `EncryptedModule` decorator function, all of the
|
|
80
|
+
* {@link Controller controllers} configured in the *metadata* would be automatically
|
|
81
|
+
* changed to the {@link EncryptedController} with the *password*. If there're some
|
|
82
|
+
* original {@link EncryptedController} decorated classes in the *metadata*, their
|
|
83
|
+
* encryption password would be kept.
|
|
84
|
+
*
|
|
85
|
+
* Therefore, if you're planning to place original {@link EncryptedController} decorated
|
|
86
|
+
* classes in the *metadata*, I hope them to have different encryption password from the
|
|
87
|
+
* module level. If not, I recommend you use the {@link Controller} decorator
|
|
88
|
+
* function instead.
|
|
89
|
+
*
|
|
90
|
+
* In addition, the `EncryptedModule` supports a convenient dynamic controller importing
|
|
91
|
+
* function, {@link EncryptedModule.dynamic}. If you utilize the function with directory
|
|
92
|
+
* path of the controller classes, it imports and configures the controller classes into
|
|
93
|
+
* the `Module`, automatically.
|
|
94
|
+
*
|
|
95
|
+
* @param metadata Module configuration metadata
|
|
96
|
+
* @param password Encryption password or its getter function
|
|
97
|
+
* @returns Class decorator
|
|
98
|
+
*
|
|
99
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
100
|
+
*/
|
|
101
|
+
function EncryptedModule(metadata, password) {
|
|
102
|
+
return function (target) {
|
|
103
|
+
var e_1, _a;
|
|
104
|
+
(0, common_1.Module)(metadata)(target);
|
|
105
|
+
if (metadata.controllers === undefined)
|
|
106
|
+
return;
|
|
107
|
+
try {
|
|
108
|
+
for (var _b = __values(metadata.controllers), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
109
|
+
var c = _c.value;
|
|
110
|
+
if (Reflect.hasMetadata(EncryptedConstant_1.ENCRYPTION_METADATA_KEY, c) === false)
|
|
111
|
+
Reflect.defineMetadata(EncryptedConstant_1.ENCRYPTION_METADATA_KEY, password, c);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
115
|
+
finally {
|
|
116
|
+
try {
|
|
117
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
118
|
+
}
|
|
119
|
+
finally { if (e_1) throw e_1.error; }
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
exports.EncryptedModule = EncryptedModule;
|
|
124
|
+
(function (EncryptedModule) {
|
|
125
|
+
/**
|
|
126
|
+
* Dynamic encrypted module.
|
|
127
|
+
*
|
|
128
|
+
* `EncryptedModule.dynamic` is an extension of the {@link EncryptedModule} function
|
|
129
|
+
* who configures controller classes by the dynamic importing. By specifying directory
|
|
130
|
+
* path of the controller classes, those controllers would be automatically imported
|
|
131
|
+
* and configured.
|
|
132
|
+
*
|
|
133
|
+
* @param path Directory path of the controller classes
|
|
134
|
+
* @param password Encryption password or its getter function
|
|
135
|
+
* @param options Additional options except controller
|
|
136
|
+
* @returns Class decorated module instance
|
|
137
|
+
*/
|
|
138
|
+
function dynamic(path, password, options) {
|
|
139
|
+
if (options === void 0) { options = {}; }
|
|
140
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
141
|
+
var controllers, NestiaModule;
|
|
142
|
+
return __generator(this, function (_a) {
|
|
143
|
+
switch (_a.label) {
|
|
144
|
+
case 0: return [4 /*yield*/, (0, load_controller_1.load_controllers)(path)];
|
|
145
|
+
case 1:
|
|
146
|
+
controllers = _a.sent();
|
|
147
|
+
NestiaModule = /** @class */ (function () {
|
|
148
|
+
function NestiaModule() {
|
|
149
|
+
}
|
|
150
|
+
NestiaModule = __decorate([
|
|
151
|
+
EncryptedModule(__assign(__assign({}, options), { controllers: controllers }), password)
|
|
152
|
+
], NestiaModule);
|
|
153
|
+
return NestiaModule;
|
|
154
|
+
}());
|
|
155
|
+
return [2 /*return*/, NestiaModule];
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
EncryptedModule.dynamic = dynamic;
|
|
161
|
+
})(EncryptedModule = exports.EncryptedModule || (exports.EncryptedModule = {}));
|
|
162
162
|
//# sourceMappingURL=EncryptedModule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EncryptedModule.js","sourceRoot":"","sources":["../../src/decorators/EncryptedModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAAwC;AAGxC,kEAAuE;AACvE,8DAA8D;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,SAAgB,eAAe,CAC3B,QAAsC,EACtC,QAA2D;IAE3D,OAAO,UAAU,MAAW;;QACxB,IAAA,eAAM,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;QACzB,IAAI,QAAQ,CAAC,WAAW,KAAK,SAAS;YAAE,OAAO;;YAE/C,KAAgB,IAAA,KAAA,SAAA,QAAQ,CAAC,WAAW,CAAA,gBAAA;gBAA/B,IAAM,CAAC,WAAA;gBACR,IAAI,OAAO,CAAC,WAAW,CAAC,2CAAuB,EAAE,CAAC,CAAC,KAAK,KAAK;oBACzD,OAAO,CAAC,cAAc,CAAC,2CAAuB,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;aAAA;;;;;;;;;IACzE,CAAC,CAAC;AACN,CAAC;AAZD,0CAYC;AAED,WAAiB,eAAe;IAC5B;;;;;;;;;;;;OAYG;IACH,SAAsB,OAAO,CACzB,
|
|
1
|
+
{"version":3,"file":"EncryptedModule.js","sourceRoot":"","sources":["../../src/decorators/EncryptedModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAAwC;AAGxC,kEAAuE;AACvE,8DAA8D;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,SAAgB,eAAe,CAC3B,QAAsC,EACtC,QAA2D;IAE3D,OAAO,UAAU,MAAW;;QACxB,IAAA,eAAM,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;QACzB,IAAI,QAAQ,CAAC,WAAW,KAAK,SAAS;YAAE,OAAO;;YAE/C,KAAgB,IAAA,KAAA,SAAA,QAAQ,CAAC,WAAW,CAAA,gBAAA;gBAA/B,IAAM,CAAC,WAAA;gBACR,IAAI,OAAO,CAAC,WAAW,CAAC,2CAAuB,EAAE,CAAC,CAAC,KAAK,KAAK;oBACzD,OAAO,CAAC,cAAc,CAAC,2CAAuB,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;aAAA;;;;;;;;;IACzE,CAAC,CAAC;AACN,CAAC;AAZD,0CAYC;AAED,WAAiB,eAAe;IAC5B;;;;;;;;;;;;OAYG;IACH,SAAsB,OAAO,CACzB,IAAmE,EACnE,QAA2D,EAC3D,OAA+D;QAA/D,wBAAA,EAAA,YAA+D;;;;;4BAGxB,qBAAM,IAAA,kCAAgB,EAAC,IAAI,CAAC,EAAA;;wBAA7D,WAAW,GAAsB,SAA4B;;4BAInE;4BAAoB,CAAC;4BAAf,YAAY;gCADjB,eAAe,uBAAM,OAAO,KAAE,WAAW,aAAA,KAAI,QAAQ,CAAC;+BACjD,YAAY,CAAG;4BAAD,mBAAC;yBAAA,AAArB;wBACA,sBAAO,YAAY,EAAC;;;;KACvB;IAZqB,uBAAO,UAY5B,CAAA;AACL,CAAC,EA3BgB,eAAe,GAAf,uBAAe,KAAf,uBAAe,QA2B/B"}
|