@nestia/core 1.3.6 → 1.3.8

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.
Files changed (97) hide show
  1. package/lib/decorators/DynamicModule.d.ts +26 -26
  2. package/lib/decorators/DynamicModule.js +103 -103
  3. package/lib/decorators/DynamicModule.js.map +1 -1
  4. package/lib/decorators/EncryptedBody.d.ts +23 -23
  5. package/lib/decorators/EncryptedBody.js +128 -128
  6. package/lib/decorators/EncryptedController.d.ts +26 -26
  7. package/lib/decorators/EncryptedController.js +36 -36
  8. package/lib/decorators/EncryptedModule.d.ts +52 -52
  9. package/lib/decorators/EncryptedModule.js +161 -161
  10. package/lib/decorators/EncryptedModule.js.map +1 -1
  11. package/lib/decorators/EncryptedRoute.d.ts +78 -78
  12. package/lib/decorators/EncryptedRoute.js +209 -209
  13. package/lib/decorators/EncryptedRoute.js.map +1 -1
  14. package/lib/decorators/PlainBody.d.ts +22 -22
  15. package/lib/decorators/PlainBody.js +82 -82
  16. package/lib/decorators/TypedBody.d.ts +16 -16
  17. package/lib/decorators/TypedBody.js +45 -45
  18. package/lib/decorators/TypedParam.d.ts +31 -31
  19. package/lib/decorators/TypedParam.js +76 -76
  20. package/lib/decorators/TypedQuery.d.ts +14 -14
  21. package/lib/decorators/TypedQuery.js +109 -109
  22. package/lib/decorators/TypedQuery.js.map +1 -1
  23. package/lib/decorators/TypedRoute.d.ts +72 -72
  24. package/lib/decorators/TypedRoute.js +185 -185
  25. package/lib/decorators/TypedRoute.js.map +1 -1
  26. package/lib/decorators/internal/EncryptedConstant.d.ts +1 -1
  27. package/lib/decorators/internal/EncryptedConstant.js +7 -7
  28. package/lib/decorators/internal/TransformError.d.ts +1 -1
  29. package/lib/decorators/internal/TransformError.js +10 -10
  30. package/lib/decorators/internal/get_path_and_stringify.d.ts +1 -1
  31. package/lib/decorators/internal/get_path_and_stringify.js +83 -83
  32. package/lib/decorators/internal/get_text_body.d.ts +3 -3
  33. package/lib/decorators/internal/get_text_body.js +62 -62
  34. package/lib/decorators/internal/headers_to_object.d.ts +3 -3
  35. package/lib/decorators/internal/headers_to_object.js +49 -49
  36. package/lib/decorators/internal/load_controller.d.ts +5 -5
  37. package/lib/decorators/internal/load_controller.js +151 -152
  38. package/lib/decorators/internal/load_controller.js.map +1 -1
  39. package/lib/decorators/internal/route_error.d.ts +3 -3
  40. package/lib/decorators/internal/route_error.js +88 -88
  41. package/lib/decorators/internal/validate_request_body.d.ts +3 -3
  42. package/lib/decorators/internal/validate_request_body.js +66 -66
  43. package/lib/index.d.ts +3 -3
  44. package/lib/index.js +31 -31
  45. package/lib/module.d.ts +12 -12
  46. package/lib/module.js +28 -28
  47. package/lib/options/INestiaTransformOptions.d.ts +4 -4
  48. package/lib/options/INestiaTransformOptions.js +2 -2
  49. package/lib/options/INestiaTransformProject.d.ts +5 -5
  50. package/lib/options/INestiaTransformProject.js +2 -2
  51. package/lib/options/IRequestBodyValidator.d.ts +16 -16
  52. package/lib/options/IRequestBodyValidator.js +2 -2
  53. package/lib/options/IResponseBodyStringifier.d.ts +20 -20
  54. package/lib/options/IResponseBodyStringifier.js +2 -2
  55. package/lib/programmers/TypedBodyProgrammer.d.ts +5 -5
  56. package/lib/programmers/TypedBodyProgrammer.js +58 -58
  57. package/lib/programmers/TypedBodyProgrammer.js.map +1 -1
  58. package/lib/programmers/TypedParamProgrammer.d.ts +5 -5
  59. package/lib/programmers/TypedParamProgrammer.js +110 -110
  60. package/lib/programmers/TypedParamProgrammer.js.map +1 -1
  61. package/lib/programmers/TypedQueryProgrammer.d.ts +5 -5
  62. package/lib/programmers/TypedQueryProgrammer.js +264 -264
  63. package/lib/programmers/TypedQueryProgrammer.js.map +1 -1
  64. package/lib/programmers/TypedRouteProgrammer.d.ts +5 -5
  65. package/lib/programmers/TypedRouteProgrammer.js +49 -49
  66. package/lib/programmers/TypedRouteProgrammer.js.map +1 -1
  67. package/lib/transform.d.ts +4 -4
  68. package/lib/transform.js +25 -25
  69. package/lib/transformers/FileTransformer.d.ts +5 -5
  70. package/lib/transformers/FileTransformer.js +40 -40
  71. package/lib/transformers/FileTransformer.js.map +1 -1
  72. package/lib/transformers/MethodDecoratorTransformer.d.ts +5 -5
  73. package/lib/transformers/MethodDecoratorTransformer.js +92 -92
  74. package/lib/transformers/MethodDecoratorTransformer.js.map +1 -1
  75. package/lib/transformers/MethodTransformer.d.ts +5 -5
  76. package/lib/transformers/MethodTransformer.js +62 -62
  77. package/lib/transformers/MethodTransformer.js.map +1 -1
  78. package/lib/transformers/NodeTransformer.d.ts +5 -5
  79. package/lib/transformers/NodeTransformer.js +21 -21
  80. package/lib/transformers/NodeTransformer.js.map +1 -1
  81. package/lib/transformers/ParameterDecoratorTransformer.d.ts +5 -5
  82. package/lib/transformers/ParameterDecoratorTransformer.js +68 -68
  83. package/lib/transformers/ParameterDecoratorTransformer.js.map +1 -1
  84. package/lib/transformers/ParameterTransformer.d.ts +5 -5
  85. package/lib/transformers/ParameterTransformer.js +34 -34
  86. package/lib/transformers/ParameterTransformer.js.map +1 -1
  87. package/lib/typings/Creator.d.ts +3 -3
  88. package/lib/typings/Creator.js +2 -2
  89. package/lib/utils/ExceptionManager.d.ts +64 -64
  90. package/lib/utils/ExceptionManager.js +112 -112
  91. package/lib/utils/ExceptionManager.js.map +1 -1
  92. package/lib/utils/Singleton.d.ts +1 -1
  93. package/lib/utils/Singleton.js +23 -23
  94. package/lib/utils/SourceFinder.d.ts +9 -9
  95. package/lib/utils/SourceFinder.js +238 -238
  96. package/lib/utils/SourceFinder.js.map +1 -1
  97. package/package.json +7 -7
@@ -1,78 +1,78 @@
1
- import { IResponseBodyStringifier } from "../options/IResponseBodyStringifier";
2
- /**
3
- * Encrypted router decorator functions.
4
- *
5
- * `EncryptedRoute` is a module containing router decorator functions which encrypts
6
- * response body data through AES-128/256 encryption. Furthermore, they can boost
7
- * up JSON string conversion speed about 50x times faster than `class-transformer`,
8
- * even type safe through [typia](https://github.com/samchon/typia).
9
- *
10
- * For reference, router functions of `EncryptedRoute` can convert custom error classes
11
- * to regular {@link nest.HttpException} class automatically, through
12
- * {@link ExceptionManager}. Also, `EncryptedRoute` encrypts response body using those
13
- * options.
14
- *
15
- * - AES-128/256
16
- * - CBC mode
17
- * - PKCS #5 Padding
18
- * - Base64 Encoding
19
- *
20
- * @author Jeongho Nam - https://github.com/samchon
21
- */
22
- export declare namespace EncryptedRoute {
23
- /**
24
- * Encrypted router decorator function for the GET method.
25
- *
26
- * @param paths Path(s) of the HTTP request
27
- * @returns Method decorator
28
- */
29
- const Get: {
30
- (path?: string | string[]): MethodDecorator;
31
- <T>(stringify?: IResponseBodyStringifier<T> | null | undefined): MethodDecorator;
32
- <T_1>(path: string | string[], stringify?: IResponseBodyStringifier<T_1> | null | undefined): MethodDecorator;
33
- };
34
- /**
35
- * Encrypted router decorator function for the GET method.
36
- *
37
- * @param paths Path(s) of the HTTP request
38
- * @returns Method decorator
39
- */
40
- const Post: {
41
- (path?: string | string[]): MethodDecorator;
42
- <T>(stringify?: IResponseBodyStringifier<T> | null | undefined): MethodDecorator;
43
- <T_1>(path: string | string[], stringify?: IResponseBodyStringifier<T_1> | null | undefined): MethodDecorator;
44
- };
45
- /**
46
- * Encrypted router decorator function for the PATCH method.
47
- *
48
- * @param path Path of the HTTP request
49
- * @returns Method decorator
50
- */
51
- const Patch: {
52
- (path?: string | string[]): MethodDecorator;
53
- <T>(stringify?: IResponseBodyStringifier<T> | null | undefined): MethodDecorator;
54
- <T_1>(path: string | string[], stringify?: IResponseBodyStringifier<T_1> | null | undefined): MethodDecorator;
55
- };
56
- /**
57
- * Encrypted router decorator function for the PUT method.
58
- *
59
- * @param path Path of the HTTP request
60
- * @returns Method decorator
61
- */
62
- const Put: {
63
- (path?: string | string[]): MethodDecorator;
64
- <T>(stringify?: IResponseBodyStringifier<T> | null | undefined): MethodDecorator;
65
- <T_1>(path: string | string[], stringify?: IResponseBodyStringifier<T_1> | null | undefined): MethodDecorator;
66
- };
67
- /**
68
- * Encrypted router decorator function for the DELETE method.
69
- *
70
- * @param path Path of the HTTP request
71
- * @returns Method decorator
72
- */
73
- const Delete: {
74
- (path?: string | string[]): MethodDecorator;
75
- <T>(stringify?: IResponseBodyStringifier<T> | null | undefined): MethodDecorator;
76
- <T_1>(path: string | string[], stringify?: IResponseBodyStringifier<T_1> | null | undefined): MethodDecorator;
77
- };
78
- }
1
+ import { IResponseBodyStringifier } from "../options/IResponseBodyStringifier";
2
+ /**
3
+ * Encrypted router decorator functions.
4
+ *
5
+ * `EncryptedRoute` is a module containing router decorator functions which encrypts
6
+ * response body data through AES-128/256 encryption. Furthermore, they can boost
7
+ * up JSON string conversion speed about 50x times faster than `class-transformer`,
8
+ * even type safe through [typia](https://github.com/samchon/typia).
9
+ *
10
+ * For reference, router functions of `EncryptedRoute` can convert custom error classes
11
+ * to regular {@link nest.HttpException} class automatically, through
12
+ * {@link ExceptionManager}. Also, `EncryptedRoute` encrypts response body using those
13
+ * options.
14
+ *
15
+ * - AES-128/256
16
+ * - CBC mode
17
+ * - PKCS #5 Padding
18
+ * - Base64 Encoding
19
+ *
20
+ * @author Jeongho Nam - https://github.com/samchon
21
+ */
22
+ export declare namespace EncryptedRoute {
23
+ /**
24
+ * Encrypted router decorator function for the GET method.
25
+ *
26
+ * @param paths Path(s) of the HTTP request
27
+ * @returns Method decorator
28
+ */
29
+ const Get: {
30
+ (path?: string | string[]): MethodDecorator;
31
+ <T>(stringify?: IResponseBodyStringifier<T> | null | undefined): MethodDecorator;
32
+ <T_1>(path: string | string[], stringify?: IResponseBodyStringifier<T_1> | null | undefined): MethodDecorator;
33
+ };
34
+ /**
35
+ * Encrypted router decorator function for the GET method.
36
+ *
37
+ * @param paths Path(s) of the HTTP request
38
+ * @returns Method decorator
39
+ */
40
+ const Post: {
41
+ (path?: string | string[]): MethodDecorator;
42
+ <T>(stringify?: IResponseBodyStringifier<T> | null | undefined): MethodDecorator;
43
+ <T_1>(path: string | string[], stringify?: IResponseBodyStringifier<T_1> | null | undefined): MethodDecorator;
44
+ };
45
+ /**
46
+ * Encrypted router decorator function for the PATCH method.
47
+ *
48
+ * @param path Path of the HTTP request
49
+ * @returns Method decorator
50
+ */
51
+ const Patch: {
52
+ (path?: string | string[]): MethodDecorator;
53
+ <T>(stringify?: IResponseBodyStringifier<T> | null | undefined): MethodDecorator;
54
+ <T_1>(path: string | string[], stringify?: IResponseBodyStringifier<T_1> | null | undefined): MethodDecorator;
55
+ };
56
+ /**
57
+ * Encrypted router decorator function for the PUT method.
58
+ *
59
+ * @param path Path of the HTTP request
60
+ * @returns Method decorator
61
+ */
62
+ const Put: {
63
+ (path?: string | string[]): MethodDecorator;
64
+ <T>(stringify?: IResponseBodyStringifier<T> | null | undefined): MethodDecorator;
65
+ <T_1>(path: string | string[], stringify?: IResponseBodyStringifier<T_1> | null | undefined): MethodDecorator;
66
+ };
67
+ /**
68
+ * Encrypted router decorator function for the DELETE method.
69
+ *
70
+ * @param path Path of the HTTP request
71
+ * @returns Method decorator
72
+ */
73
+ const Delete: {
74
+ (path?: string | string[]): MethodDecorator;
75
+ <T>(stringify?: IResponseBodyStringifier<T> | null | undefined): MethodDecorator;
76
+ <T_1>(path: string | string[], stringify?: IResponseBodyStringifier<T_1> | null | undefined): MethodDecorator;
77
+ };
78
+ }
@@ -1,210 +1,210 @@
1
- "use strict";
2
- var __read = (this && this.__read) || function (o, n) {
3
- var m = typeof Symbol === "function" && o[Symbol.iterator];
4
- if (!m) return o;
5
- var i = m.call(o), r, ar = [], e;
6
- try {
7
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
- }
9
- catch (error) { e = { error: error }; }
10
- finally {
11
- try {
12
- if (r && !r.done && (m = i["return"])) m.call(i);
13
- }
14
- finally { if (e) throw e.error; }
15
- }
16
- return ar;
17
- };
18
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
19
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
20
- if (ar || !(i in from)) {
21
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
22
- ar[i] = from[i];
23
- }
24
- }
25
- return to.concat(ar || Array.prototype.slice.call(from));
26
- };
27
- var __values = (this && this.__values) || function(o) {
28
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
29
- if (m) return m.call(o);
30
- if (o && typeof o.length === "number") return {
31
- next: function () {
32
- if (o && i >= o.length) o = void 0;
33
- return { value: o && o[i++], done: !o };
34
- }
35
- };
36
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
37
- };
38
- var e_1, _a, e_2, _b, e_3, _c;
39
- Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.EncryptedRoute = void 0;
41
- var fetcher_1 = require("@nestia/fetcher");
42
- var common_1 = require("@nestjs/common");
43
- var operators_1 = require("rxjs/operators");
44
- var typia_1 = require("typia");
45
- var Singleton_1 = require("../utils/Singleton");
46
- var EncryptedConstant_1 = require("./internal/EncryptedConstant");
47
- var TransformError_1 = require("./internal/TransformError");
48
- var get_path_and_stringify_1 = require("./internal/get_path_and_stringify");
49
- var headers_to_object_1 = require("./internal/headers_to_object");
50
- var route_error_1 = require("./internal/route_error");
51
- /**
52
- * Encrypted router decorator functions.
53
- *
54
- * `EncryptedRoute` is a module containing router decorator functions which encrypts
55
- * response body data through AES-128/256 encryption. Furthermore, they can boost
56
- * up JSON string conversion speed about 50x times faster than `class-transformer`,
57
- * even type safe through [typia](https://github.com/samchon/typia).
58
- *
59
- * For reference, router functions of `EncryptedRoute` can convert custom error classes
60
- * to regular {@link nest.HttpException} class automatically, through
61
- * {@link ExceptionManager}. Also, `EncryptedRoute` encrypts response body using those
62
- * options.
63
- *
64
- * - AES-128/256
65
- * - CBC mode
66
- * - PKCS #5 Padding
67
- * - Base64 Encoding
68
- *
69
- * @author Jeongho Nam - https://github.com/samchon
70
- */
71
- var EncryptedRoute;
72
- (function (EncryptedRoute) {
73
- /**
74
- * Encrypted router decorator function for the GET method.
75
- *
76
- * @param paths Path(s) of the HTTP request
77
- * @returns Method decorator
78
- */
79
- EncryptedRoute.Get = Generator("Get");
80
- /**
81
- * Encrypted router decorator function for the GET method.
82
- *
83
- * @param paths Path(s) of the HTTP request
84
- * @returns Method decorator
85
- */
86
- EncryptedRoute.Post = Generator("Post");
87
- /**
88
- * Encrypted router decorator function for the PATCH method.
89
- *
90
- * @param path Path of the HTTP request
91
- * @returns Method decorator
92
- */
93
- EncryptedRoute.Patch = Generator("Patch");
94
- /**
95
- * Encrypted router decorator function for the PUT method.
96
- *
97
- * @param path Path of the HTTP request
98
- * @returns Method decorator
99
- */
100
- EncryptedRoute.Put = Generator("Put");
101
- /**
102
- * Encrypted router decorator function for the DELETE method.
103
- *
104
- * @param path Path of the HTTP request
105
- * @returns Method decorator
106
- */
107
- EncryptedRoute.Delete = Generator("Delete");
108
- function Generator(method) {
109
- function route() {
110
- var args = [];
111
- for (var _i = 0; _i < arguments.length; _i++) {
112
- args[_i] = arguments[_i];
113
- }
114
- var _a = __read((0, get_path_and_stringify_1.get_path_and_stringify)("EncryptedRoute.".concat(method)).apply(void 0, __spreadArray([], __read(args), false)), 2), path = _a[0], stringify = _a[1];
115
- return (0, common_1.applyDecorators)(ROUTERS[method](path), (0, common_1.UseInterceptors)(new EncryptedRouteInterceptor(method, stringify)));
116
- }
117
- return route;
118
- }
119
- })(EncryptedRoute = exports.EncryptedRoute || (exports.EncryptedRoute = {}));
120
- try {
121
- for (var _d = __values([
122
- typia_1.isStringify,
123
- typia_1.assertStringify,
124
- typia_1.validateStringify,
125
- typia_1.stringify,
126
- ]), _e = _d.next(); !_e.done; _e = _d.next()) {
127
- var method = _e.value;
128
- try {
129
- for (var _f = (e_2 = void 0, __values(Object.entries(method))), _g = _f.next(); !_g.done; _g = _f.next()) {
130
- var _h = __read(_g.value, 2), key = _h[0], value = _h[1];
131
- try {
132
- for (var _j = (e_3 = void 0, __values([
133
- EncryptedRoute.Get,
134
- EncryptedRoute.Delete,
135
- EncryptedRoute.Post,
136
- EncryptedRoute.Put,
137
- EncryptedRoute.Patch,
138
- ])), _k = _j.next(); !_k.done; _k = _j.next()) {
139
- var deco = _k.value;
140
- deco[key] = value;
141
- }
142
- }
143
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
144
- finally {
145
- try {
146
- if (_k && !_k.done && (_c = _j.return)) _c.call(_j);
147
- }
148
- finally { if (e_3) throw e_3.error; }
149
- }
150
- }
151
- }
152
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
153
- finally {
154
- try {
155
- if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
156
- }
157
- finally { if (e_2) throw e_2.error; }
158
- }
159
- }
160
- }
161
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
162
- finally {
163
- try {
164
- if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
165
- }
166
- finally { if (e_1) throw e_1.error; }
167
- }
168
- /**
169
- * @internal
170
- */
171
- var EncryptedRouteInterceptor = /** @class */ (function () {
172
- function EncryptedRouteInterceptor(method, stringify) {
173
- this.method = method;
174
- this.stringify = stringify;
175
- }
176
- EncryptedRouteInterceptor.prototype.intercept = function (context, next) {
177
- var _this = this;
178
- var http = context.switchToHttp();
179
- return next.handle().pipe((0, operators_1.map)(function (value) {
180
- var param = Reflect.getMetadata(EncryptedConstant_1.ENCRYPTION_METADATA_KEY, context.getClass());
181
- if (!param)
182
- throw (0, TransformError_1.TransformError)("EncryptedRoute.".concat(_this.method));
183
- var headers = new Singleton_1.Singleton(function () {
184
- var request = http.getRequest();
185
- return (0, headers_to_object_1.headers_to_object)(request.headers);
186
- });
187
- var body = _this.stringify(value);
188
- var password = typeof param === "function"
189
- ? param({ headers: headers.get(), body: body }, false)
190
- : param;
191
- var response = http.getResponse();
192
- response.header("Content-Type", "text/plain");
193
- if (body === undefined)
194
- return body;
195
- return fetcher_1.AesPkcs5.encrypt(body, password.key, password.iv);
196
- }), (0, operators_1.catchError)(function (err) { return (0, route_error_1.route_error)(http.getRequest(), err); }));
197
- };
198
- return EncryptedRouteInterceptor;
199
- }());
200
- /**
201
- * @internal
202
- */
203
- var ROUTERS = {
204
- Get: common_1.Get,
205
- Post: common_1.Post,
206
- Put: common_1.Put,
207
- Patch: common_1.Patch,
208
- Delete: common_1.Delete,
209
- };
1
+ "use strict";
2
+ var __read = (this && this.__read) || function (o, n) {
3
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
4
+ if (!m) return o;
5
+ var i = m.call(o), r, ar = [], e;
6
+ try {
7
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
+ }
9
+ catch (error) { e = { error: error }; }
10
+ finally {
11
+ try {
12
+ if (r && !r.done && (m = i["return"])) m.call(i);
13
+ }
14
+ finally { if (e) throw e.error; }
15
+ }
16
+ return ar;
17
+ };
18
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
19
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
20
+ if (ar || !(i in from)) {
21
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
22
+ ar[i] = from[i];
23
+ }
24
+ }
25
+ return to.concat(ar || Array.prototype.slice.call(from));
26
+ };
27
+ var __values = (this && this.__values) || function(o) {
28
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
29
+ if (m) return m.call(o);
30
+ if (o && typeof o.length === "number") return {
31
+ next: function () {
32
+ if (o && i >= o.length) o = void 0;
33
+ return { value: o && o[i++], done: !o };
34
+ }
35
+ };
36
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
37
+ };
38
+ var e_1, _a, e_2, _b, e_3, _c;
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.EncryptedRoute = void 0;
41
+ var fetcher_1 = require("@nestia/fetcher");
42
+ var common_1 = require("@nestjs/common");
43
+ var operators_1 = require("rxjs/operators");
44
+ var typia_1 = require("typia");
45
+ var Singleton_1 = require("../utils/Singleton");
46
+ var EncryptedConstant_1 = require("./internal/EncryptedConstant");
47
+ var TransformError_1 = require("./internal/TransformError");
48
+ var get_path_and_stringify_1 = require("./internal/get_path_and_stringify");
49
+ var headers_to_object_1 = require("./internal/headers_to_object");
50
+ var route_error_1 = require("./internal/route_error");
51
+ /**
52
+ * Encrypted router decorator functions.
53
+ *
54
+ * `EncryptedRoute` is a module containing router decorator functions which encrypts
55
+ * response body data through AES-128/256 encryption. Furthermore, they can boost
56
+ * up JSON string conversion speed about 50x times faster than `class-transformer`,
57
+ * even type safe through [typia](https://github.com/samchon/typia).
58
+ *
59
+ * For reference, router functions of `EncryptedRoute` can convert custom error classes
60
+ * to regular {@link nest.HttpException} class automatically, through
61
+ * {@link ExceptionManager}. Also, `EncryptedRoute` encrypts response body using those
62
+ * options.
63
+ *
64
+ * - AES-128/256
65
+ * - CBC mode
66
+ * - PKCS #5 Padding
67
+ * - Base64 Encoding
68
+ *
69
+ * @author Jeongho Nam - https://github.com/samchon
70
+ */
71
+ var EncryptedRoute;
72
+ (function (EncryptedRoute) {
73
+ /**
74
+ * Encrypted router decorator function for the GET method.
75
+ *
76
+ * @param paths Path(s) of the HTTP request
77
+ * @returns Method decorator
78
+ */
79
+ EncryptedRoute.Get = Generator("Get");
80
+ /**
81
+ * Encrypted router decorator function for the GET method.
82
+ *
83
+ * @param paths Path(s) of the HTTP request
84
+ * @returns Method decorator
85
+ */
86
+ EncryptedRoute.Post = Generator("Post");
87
+ /**
88
+ * Encrypted router decorator function for the PATCH method.
89
+ *
90
+ * @param path Path of the HTTP request
91
+ * @returns Method decorator
92
+ */
93
+ EncryptedRoute.Patch = Generator("Patch");
94
+ /**
95
+ * Encrypted router decorator function for the PUT method.
96
+ *
97
+ * @param path Path of the HTTP request
98
+ * @returns Method decorator
99
+ */
100
+ EncryptedRoute.Put = Generator("Put");
101
+ /**
102
+ * Encrypted router decorator function for the DELETE method.
103
+ *
104
+ * @param path Path of the HTTP request
105
+ * @returns Method decorator
106
+ */
107
+ EncryptedRoute.Delete = Generator("Delete");
108
+ function Generator(method) {
109
+ function route() {
110
+ var args = [];
111
+ for (var _i = 0; _i < arguments.length; _i++) {
112
+ args[_i] = arguments[_i];
113
+ }
114
+ var _a = __read((0, get_path_and_stringify_1.get_path_and_stringify)("EncryptedRoute.".concat(method)).apply(void 0, __spreadArray([], __read(args), false)), 2), path = _a[0], stringify = _a[1];
115
+ return (0, common_1.applyDecorators)(ROUTERS[method](path), (0, common_1.UseInterceptors)(new EncryptedRouteInterceptor(method, stringify)));
116
+ }
117
+ return route;
118
+ }
119
+ })(EncryptedRoute || (exports.EncryptedRoute = EncryptedRoute = {}));
120
+ try {
121
+ for (var _d = __values([
122
+ typia_1.isStringify,
123
+ typia_1.assertStringify,
124
+ typia_1.validateStringify,
125
+ typia_1.stringify,
126
+ ]), _e = _d.next(); !_e.done; _e = _d.next()) {
127
+ var method = _e.value;
128
+ try {
129
+ for (var _f = (e_2 = void 0, __values(Object.entries(method))), _g = _f.next(); !_g.done; _g = _f.next()) {
130
+ var _h = __read(_g.value, 2), key = _h[0], value = _h[1];
131
+ try {
132
+ for (var _j = (e_3 = void 0, __values([
133
+ EncryptedRoute.Get,
134
+ EncryptedRoute.Delete,
135
+ EncryptedRoute.Post,
136
+ EncryptedRoute.Put,
137
+ EncryptedRoute.Patch,
138
+ ])), _k = _j.next(); !_k.done; _k = _j.next()) {
139
+ var deco = _k.value;
140
+ deco[key] = value;
141
+ }
142
+ }
143
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
144
+ finally {
145
+ try {
146
+ if (_k && !_k.done && (_c = _j.return)) _c.call(_j);
147
+ }
148
+ finally { if (e_3) throw e_3.error; }
149
+ }
150
+ }
151
+ }
152
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
153
+ finally {
154
+ try {
155
+ if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
156
+ }
157
+ finally { if (e_2) throw e_2.error; }
158
+ }
159
+ }
160
+ }
161
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
162
+ finally {
163
+ try {
164
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
165
+ }
166
+ finally { if (e_1) throw e_1.error; }
167
+ }
168
+ /**
169
+ * @internal
170
+ */
171
+ var EncryptedRouteInterceptor = /** @class */ (function () {
172
+ function EncryptedRouteInterceptor(method, stringify) {
173
+ this.method = method;
174
+ this.stringify = stringify;
175
+ }
176
+ EncryptedRouteInterceptor.prototype.intercept = function (context, next) {
177
+ var _this = this;
178
+ var http = context.switchToHttp();
179
+ return next.handle().pipe((0, operators_1.map)(function (value) {
180
+ var param = Reflect.getMetadata(EncryptedConstant_1.ENCRYPTION_METADATA_KEY, context.getClass());
181
+ if (!param)
182
+ throw (0, TransformError_1.TransformError)("EncryptedRoute.".concat(_this.method));
183
+ var headers = new Singleton_1.Singleton(function () {
184
+ var request = http.getRequest();
185
+ return (0, headers_to_object_1.headers_to_object)(request.headers);
186
+ });
187
+ var body = _this.stringify(value);
188
+ var password = typeof param === "function"
189
+ ? param({ headers: headers.get(), body: body }, false)
190
+ : param;
191
+ var response = http.getResponse();
192
+ response.header("Content-Type", "text/plain");
193
+ if (body === undefined)
194
+ return body;
195
+ return fetcher_1.AesPkcs5.encrypt(body, password.key, password.iv);
196
+ }), (0, operators_1.catchError)(function (err) { return (0, route_error_1.route_error)(http.getRequest(), err); }));
197
+ };
198
+ return EncryptedRouteInterceptor;
199
+ }());
200
+ /**
201
+ * @internal
202
+ */
203
+ var ROUTERS = {
204
+ Get: common_1.Get,
205
+ Post: common_1.Post,
206
+ Put: common_1.Put,
207
+ Patch: common_1.Patch,
208
+ Delete: common_1.Delete,
209
+ };
210
210
  //# sourceMappingURL=EncryptedRoute.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EncryptedRoute.js","sourceRoot":"","sources":["../../src/decorators/EncryptedRoute.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAgE;AAChE,yCAWwB;AAGxB,4CAAiD;AAEjD,+BAKe;AAGf,gD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AC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC;QAC7D,CAAC,CAAC,EACF,IAAA,sBAAU,EAAC,UAAC,GAAG,IAAK,OAAA,IAAA,yBAAW,EAAC,IAAI,CAAC,UAAU,EAAE,EAAE,GAAG,CAAC,EAAnC,CAAmC,CAAC,CAC3D,CAAC;IACN,CAAC;IACL,gCAAC;AAAD,CAAC,AAxCD,IAwCC;AAED;;GAEG;AACH,IAAM,OAAO,GAAG;IACZ,GAAG,cAAA;IACH,IAAI,eAAA;IACJ,GAAG,cAAA;IACH,KAAK,gBAAA;IACL,MAAM,iBAAA;CACT,CAAC"}
@@ -1,22 +1,22 @@
1
- /**
2
- * Plain body decorator.
3
- *
4
- * `PlainBody` is a decorator function getting full body text from the HTTP request.
5
- *
6
- * If you adjust the regular {@link Body} decorator function to the body parameter,
7
- * you can't get the full body text because the {@link Body} tries to convert the
8
- * body text to JSON object. Therefore, `@nestia/core` provides this `PlainBody`
9
- * decorator function to get the full body text.
10
- *
11
- * ```typescript
12
- * \@TypedRoute.Post("memo")
13
- * public store
14
- * (
15
- * \@PlainBody() body: string
16
- * ): void;
17
- * ```
18
- *
19
- * @return Parameter decorator
20
- * @author Jeongho Nam - https://github.com/samchon
21
- */
22
- export declare const PlainBody: () => ParameterDecorator;
1
+ /**
2
+ * Plain body decorator.
3
+ *
4
+ * `PlainBody` is a decorator function getting full body text from the HTTP request.
5
+ *
6
+ * If you adjust the regular {@link Body} decorator function to the body parameter,
7
+ * you can't get the full body text because the {@link Body} tries to convert the
8
+ * body text to JSON object. Therefore, `@nestia/core` provides this `PlainBody`
9
+ * decorator function to get the full body text.
10
+ *
11
+ * ```typescript
12
+ * \@TypedRoute.Post("memo")
13
+ * public store
14
+ * (
15
+ * \@PlainBody() body: string
16
+ * ): void;
17
+ * ```
18
+ *
19
+ * @return Parameter decorator
20
+ * @author Jeongho Nam - https://github.com/samchon
21
+ */
22
+ export declare const PlainBody: () => ParameterDecorator;