@nestia/fetcher 10.0.2 → 11.0.0-dev.20260312
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/LICENSE +21 -0
- package/README.md +93 -93
- package/lib/AesPkcs5.js +5 -5
- package/lib/AesPkcs5.js.map +1 -1
- package/lib/EncryptedFetcher.js +54 -95
- package/lib/EncryptedFetcher.js.map +1 -1
- package/lib/HttpError.d.ts +1 -1
- package/lib/HttpError.js +2 -2
- package/lib/HttpError.js.map +1 -1
- package/lib/NestiaSimulator.js +29 -47
- package/lib/NestiaSimulator.js.map +1 -1
- package/lib/PlainFetcher.js +17 -48
- package/lib/PlainFetcher.js.map +1 -1
- package/lib/index.d.ts +4 -0
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -1
- package/lib/internal/FetcherBase.js +141 -304
- package/lib/internal/FetcherBase.js.map +1 -1
- package/package.json +20 -13
- package/src/AesPkcs5.ts +41 -49
- package/src/HttpError.ts +1 -1
- package/src/index.ts +12 -7
- package/lib/MigrateFetcher.d.ts +0 -19
- package/lib/MigrateFetcher.js +0 -179
- package/lib/MigrateFetcher.js.map +0 -1
- package/src/MigrateFetcher.ts +0 -118
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Jeongho Nam
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
# Nestia
|
|
2
|
-

|
|
3
|
-
|
|
4
|
-
[](https://github.com/samchon/nestia/blob/master/LICENSE)
|
|
5
|
-
[](https://www.npmjs.com/package/@nestia/fetcher)
|
|
6
|
-
[](https://www.npmjs.com/package/@nestia/fetcher)
|
|
7
|
-
[](https://nestia.io/docs/)
|
|
9
|
-
[](https://gurubase.io/g/nestia)
|
|
10
|
-
[](https://discord.gg/E94XhzrUCZ)
|
|
11
|
-
|
|
12
|
-
Nestia is a set of helper libraries for NestJS, supporting below features:
|
|
13
|
-
|
|
14
|
-
- `@nestia/core`:
|
|
15
|
-
- Super-fast/easy decorators
|
|
16
|
-
- Advanced WebSocket routes
|
|
17
|
-
- `@nestia/sdk`:
|
|
18
|
-
- Swagger generator, more evolved than ever
|
|
19
|
-
- SDK library generator for clients
|
|
20
|
-
- Mockup Simulator for client applications
|
|
21
|
-
- Automatic E2E test functions generator
|
|
22
|
-
- `@nestia/e2e`: Test program utilizing e2e test functions
|
|
23
|
-
- `@nestia/benchmark`: Benchmark program using e2e test functions
|
|
24
|
-
- `@nestia/editor`: Swagger-UI with Online TypeScript Editor
|
|
25
|
-
- [`@agentica`](https://github.com/wrtnlabs/agentica): Agentic AI library specialized in LLM function calling
|
|
26
|
-
- [`@autobe`](https://github.com/wrtnlabs/autobe): Vibe coding agent generating NestJS application
|
|
27
|
-
- `nestia`: Just CLI (command line interface) tool
|
|
28
|
-
|
|
29
|
-
> [!NOTE]
|
|
30
|
-
>
|
|
31
|
-
> - **Only one line** required, with pure TypeScript type
|
|
32
|
-
> - Enhance performance **30x** up
|
|
33
|
-
> - Runtime validator is **20,000x faster** than `class-validator`
|
|
34
|
-
> - JSON serialization is **200x faster** than `class-transformer`
|
|
35
|
-
> - Software Development Kit
|
|
36
|
-
> - Collection of typed `fetch` functions with DTO structures like [tRPC](https://trpc.io/)
|
|
37
|
-
> - Mockup simulator means embedded backend simulator in the SDK
|
|
38
|
-
> - similar with [msw](https://mswjs.io/), but fully automated
|
|
39
|
-
|
|
40
|
-

|
|
41
|
-
|
|
42
|
-
> Left is NestJS server code, and right is client (frontend) code utilizing SDK
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
## Sponsors and Backers
|
|
48
|
-
Thanks for your support.
|
|
49
|
-
|
|
50
|
-
Your donation would encourage `nestia` development.
|
|
51
|
-
|
|
52
|
-
[](https://opencollective.com/nestia)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
## Guide Documents
|
|
58
|
-
Check out the document in the [website](https://nestia.io/docs/):
|
|
59
|
-
|
|
60
|
-
### 🏠 Home
|
|
61
|
-
- [Introduction](https://nestia.io/docs/)
|
|
62
|
-
- [Setup](https://nestia.io/docs/setup/)
|
|
63
|
-
- [Pure TypeScript](https://nestia.io/docs/pure)
|
|
64
|
-
|
|
65
|
-
### 📖 Features
|
|
66
|
-
- Core Library
|
|
67
|
-
- [`@WebSocketRoute`](https://nestia.io/docs/core/WebSocketRoute)
|
|
68
|
-
- [`@TypedRoute`](https://nestia.io/docs/core/TypedRoute/)
|
|
69
|
-
- [**`@TypedBody`**](https://nestia.io/docs/core/TypedBody/)
|
|
70
|
-
- [`@TypedParam`](https://nestia.io/docs/core/TypedParam/)
|
|
71
|
-
- [`@TypedQuery`](https://nestia.io/docs/core/TypedQuery/)
|
|
72
|
-
- [`@TypedFormData`](https://nestia.io/docs/core/TypedFormData/)
|
|
73
|
-
- [`@TypedHeaders`](https://nestia.io/docs/core/TypedHeaders/)
|
|
74
|
-
- [`@TypedException`](https://nestia.io/docs/core/TypedException/)
|
|
75
|
-
- Software Development Kit
|
|
76
|
-
- [SDK Builder](https://nestia.io/docs/sdk/)
|
|
77
|
-
- [Mockup Simulator](https://nestia.io/docs/sdk/simulate/)
|
|
78
|
-
- [E2E Test Functions](https://nestia.io/docs/sdk/e2e/)
|
|
79
|
-
- [Distribution](https://nestia.io/docs/sdk/distribute/)
|
|
80
|
-
- Swagger Document
|
|
81
|
-
- [Swagger Builder](https://nestia.io/docs/swagger/)
|
|
82
|
-
- [**AI Chatbot Development**](https://nestia.io/docs/swagger/chat/)
|
|
83
|
-
- [Cloud Swagger Editor](https://nestia.io/docs/swagger/editor/)
|
|
84
|
-
- [Documentation Strategy](https://nestia.io/docs/swagger/strategy/)
|
|
85
|
-
- E2E Testing
|
|
86
|
-
- [Why E2E Test?](https://nestia.io/docs/e2e/why/)
|
|
87
|
-
- [Test Program Development](https://nestia.io/docs/e2e/development/)
|
|
88
|
-
- [Performance Benchmark](https://nestia.io/docs/e2e/benchmark/)
|
|
89
|
-
|
|
90
|
-
### 🔗 Appendix
|
|
91
|
-
- [API Documents](https://nestia.io/api)
|
|
92
|
-
- [⇲ Benchmark Result](https://github.com/samchon/nestia/tree/master/benchmark/results/11th%20Gen%20Intel(R)%20Core(TM)%20i5-1135G7%20%40%202.40GHz)
|
|
93
|
-
- [⇲ `dev.to` Articles](https://dev.to/samchon/series/22751)
|
|
1
|
+
# Nestia
|
|
2
|
+

|
|
3
|
+
|
|
4
|
+
[](https://github.com/samchon/nestia/blob/master/LICENSE)
|
|
5
|
+
[](https://www.npmjs.com/package/@nestia/fetcher)
|
|
6
|
+
[](https://www.npmjs.com/package/@nestia/fetcher)
|
|
7
|
+
[](https://github.com/samchon/nestia/actions?query=workflow%3Atest)
|
|
8
|
+
[](https://nestia.io/docs/)
|
|
9
|
+
[](https://gurubase.io/g/nestia)
|
|
10
|
+
[](https://discord.gg/E94XhzrUCZ)
|
|
11
|
+
|
|
12
|
+
Nestia is a set of helper libraries for NestJS, supporting below features:
|
|
13
|
+
|
|
14
|
+
- `@nestia/core`:
|
|
15
|
+
- Super-fast/easy decorators
|
|
16
|
+
- Advanced WebSocket routes
|
|
17
|
+
- `@nestia/sdk`:
|
|
18
|
+
- Swagger generator, more evolved than ever
|
|
19
|
+
- SDK library generator for clients
|
|
20
|
+
- Mockup Simulator for client applications
|
|
21
|
+
- Automatic E2E test functions generator
|
|
22
|
+
- `@nestia/e2e`: Test program utilizing e2e test functions
|
|
23
|
+
- `@nestia/benchmark`: Benchmark program using e2e test functions
|
|
24
|
+
- `@nestia/editor`: Swagger-UI with Online TypeScript Editor
|
|
25
|
+
- [`@agentica`](https://github.com/wrtnlabs/agentica): Agentic AI library specialized in LLM function calling
|
|
26
|
+
- [`@autobe`](https://github.com/wrtnlabs/autobe): Vibe coding agent generating NestJS application
|
|
27
|
+
- `nestia`: Just CLI (command line interface) tool
|
|
28
|
+
|
|
29
|
+
> [!NOTE]
|
|
30
|
+
>
|
|
31
|
+
> - **Only one line** required, with pure TypeScript type
|
|
32
|
+
> - Enhance performance **30x** up
|
|
33
|
+
> - Runtime validator is **20,000x faster** than `class-validator`
|
|
34
|
+
> - JSON serialization is **200x faster** than `class-transformer`
|
|
35
|
+
> - Software Development Kit
|
|
36
|
+
> - Collection of typed `fetch` functions with DTO structures like [tRPC](https://trpc.io/)
|
|
37
|
+
> - Mockup simulator means embedded backend simulator in the SDK
|
|
38
|
+
> - similar with [msw](https://mswjs.io/), but fully automated
|
|
39
|
+
|
|
40
|
+

|
|
41
|
+
|
|
42
|
+
> Left is NestJS server code, and right is client (frontend) code utilizing SDK
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## Sponsors and Backers
|
|
48
|
+
Thanks for your support.
|
|
49
|
+
|
|
50
|
+
Your donation would encourage `nestia` development.
|
|
51
|
+
|
|
52
|
+
[](https://opencollective.com/nestia)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
## Guide Documents
|
|
58
|
+
Check out the document in the [website](https://nestia.io/docs/):
|
|
59
|
+
|
|
60
|
+
### 🏠 Home
|
|
61
|
+
- [Introduction](https://nestia.io/docs/)
|
|
62
|
+
- [Setup](https://nestia.io/docs/setup/)
|
|
63
|
+
- [Pure TypeScript](https://nestia.io/docs/pure)
|
|
64
|
+
|
|
65
|
+
### 📖 Features
|
|
66
|
+
- Core Library
|
|
67
|
+
- [`@WebSocketRoute`](https://nestia.io/docs/core/WebSocketRoute)
|
|
68
|
+
- [`@TypedRoute`](https://nestia.io/docs/core/TypedRoute/)
|
|
69
|
+
- [**`@TypedBody`**](https://nestia.io/docs/core/TypedBody/)
|
|
70
|
+
- [`@TypedParam`](https://nestia.io/docs/core/TypedParam/)
|
|
71
|
+
- [`@TypedQuery`](https://nestia.io/docs/core/TypedQuery/)
|
|
72
|
+
- [`@TypedFormData`](https://nestia.io/docs/core/TypedFormData/)
|
|
73
|
+
- [`@TypedHeaders`](https://nestia.io/docs/core/TypedHeaders/)
|
|
74
|
+
- [`@TypedException`](https://nestia.io/docs/core/TypedException/)
|
|
75
|
+
- Software Development Kit
|
|
76
|
+
- [SDK Builder](https://nestia.io/docs/sdk/)
|
|
77
|
+
- [Mockup Simulator](https://nestia.io/docs/sdk/simulate/)
|
|
78
|
+
- [E2E Test Functions](https://nestia.io/docs/sdk/e2e/)
|
|
79
|
+
- [Distribution](https://nestia.io/docs/sdk/distribute/)
|
|
80
|
+
- Swagger Document
|
|
81
|
+
- [Swagger Builder](https://nestia.io/docs/swagger/)
|
|
82
|
+
- [**AI Chatbot Development**](https://nestia.io/docs/swagger/chat/)
|
|
83
|
+
- [Cloud Swagger Editor](https://nestia.io/docs/swagger/editor/)
|
|
84
|
+
- [Documentation Strategy](https://nestia.io/docs/swagger/strategy/)
|
|
85
|
+
- E2E Testing
|
|
86
|
+
- [Why E2E Test?](https://nestia.io/docs/e2e/why/)
|
|
87
|
+
- [Test Program Development](https://nestia.io/docs/e2e/development/)
|
|
88
|
+
- [Performance Benchmark](https://nestia.io/docs/e2e/benchmark/)
|
|
89
|
+
|
|
90
|
+
### 🔗 Appendix
|
|
91
|
+
- [API Documents](https://nestia.io/api)
|
|
92
|
+
- [⇲ Benchmark Result](https://github.com/samchon/nestia/tree/master/benchmark/results/11th%20Gen%20Intel(R)%20Core(TM)%20i5-1135G7%20%40%202.40GHz)
|
|
93
|
+
- [⇲ `dev.to` Articles](https://dev.to/samchon/series/22751)
|
package/lib/AesPkcs5.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.AesPkcs5 = void 0;
|
|
7
|
-
|
|
7
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
8
8
|
/**
|
|
9
9
|
* Utility class for the AES-128/256 encryption.
|
|
10
10
|
*
|
|
@@ -26,8 +26,8 @@ var AesPkcs5;
|
|
|
26
26
|
* @returns Encrypted data
|
|
27
27
|
*/
|
|
28
28
|
function encrypt(data, key, iv) {
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
const bytes = key.length * 8;
|
|
30
|
+
const cipher = crypto_1.default.createCipheriv(`AES-${bytes}-CBC`, key, iv);
|
|
31
31
|
return cipher.update(data, "utf8", "base64") + cipher.final("base64");
|
|
32
32
|
}
|
|
33
33
|
AesPkcs5.encrypt = encrypt;
|
|
@@ -40,8 +40,8 @@ var AesPkcs5;
|
|
|
40
40
|
* @returns Decrypted data.
|
|
41
41
|
*/
|
|
42
42
|
function decrypt(data, key, iv) {
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
const bytes = key.length * 8;
|
|
44
|
+
const decipher = crypto_1.default.createDecipheriv(`AES-${bytes}-CBC`, key, iv);
|
|
45
45
|
return decipher.update(data, "base64", "utf8") + decipher.final("utf8");
|
|
46
46
|
}
|
|
47
47
|
AesPkcs5.decrypt = decrypt;
|
package/lib/AesPkcs5.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AesPkcs5.js","sourceRoot":"","sources":["../src/AesPkcs5.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"AesPkcs5.js","sourceRoot":"","sources":["../src/AesPkcs5.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAE5B;;;;;;;;;GASG;AACH,IAAiB,QAAQ,CA4BxB;AA5BD,WAAiB,QAAQ;IACvB;;;;;;;OAOG;IACH,SAAgB,OAAO,CAAC,IAAY,EAAE,GAAW,EAAE,EAAU;QAC3D,MAAM,KAAK,GAAW,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;QACrC,MAAM,MAAM,GAAG,gBAAM,CAAC,cAAc,CAAC,OAAO,KAAK,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;QAClE,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACxE,CAAC;IAJe,gBAAO,UAItB,CAAA;IAED;;;;;;;OAOG;IACH,SAAgB,OAAO,CAAC,IAAY,EAAE,GAAW,EAAE,EAAU;QAC3D,MAAM,KAAK,GAAW,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;QACrC,MAAM,QAAQ,GAAG,gBAAM,CAAC,gBAAgB,CAAC,OAAO,KAAK,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;QACtE,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1E,CAAC;IAJe,gBAAO,UAItB,CAAA;AACH,CAAC,EA5BgB,QAAQ,wBAAR,QAAQ,QA4BxB"}
|
package/lib/EncryptedFetcher.js
CHANGED
|
@@ -8,37 +8,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
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;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
12
|
exports.EncryptedFetcher = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
13
|
+
const AesPkcs5_1 = require("./AesPkcs5");
|
|
14
|
+
const FetcherBase_1 = require("./internal/FetcherBase");
|
|
42
15
|
/**
|
|
43
16
|
* Utility class for `fetch` functions used in `@nestia/sdk` with encryption.
|
|
44
17
|
*
|
|
@@ -58,80 +31,66 @@ var FetcherBase_1 = require("./internal/FetcherBase");
|
|
|
58
31
|
var EncryptedFetcher;
|
|
59
32
|
(function (EncryptedFetcher) {
|
|
60
33
|
function fetch(connection, route, input, stringify) {
|
|
61
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
62
|
-
var closure;
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
35
|
var _a, _b, _c, _d;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
36
|
+
if ((((_a = route.request) === null || _a === void 0 ? void 0 : _a.encrypted) === true || ((_b = route.response) === null || _b === void 0 ? void 0 : _b.encrypted)) &&
|
|
37
|
+
connection.encryption === undefined)
|
|
38
|
+
throw new Error("Error on EncryptedFetcher.fetch(): the encryption password has not been configured.");
|
|
39
|
+
const closure = typeof connection.encryption === "function"
|
|
40
|
+
? (direction) => (headers, body) => connection.encryption({
|
|
41
|
+
headers,
|
|
42
|
+
body,
|
|
43
|
+
direction,
|
|
44
|
+
})
|
|
45
|
+
: () => () => connection.encryption;
|
|
46
|
+
return FetcherBase_1.FetcherBase.request({
|
|
47
|
+
className: "EncryptedFetcher",
|
|
48
|
+
encode: ((_c = route.request) === null || _c === void 0 ? void 0 : _c.encrypted) === true
|
|
49
|
+
? (input, headers) => {
|
|
50
|
+
const p = closure("encode")(headers, input);
|
|
51
|
+
return AesPkcs5_1.AesPkcs5.encrypt((stringify !== null && stringify !== void 0 ? stringify : JSON.stringify)(input), p.key, p.iv);
|
|
77
52
|
}
|
|
78
|
-
:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
decode: ((_d = route.response) === null || _d === void 0 ? void 0 : _d.encrypted) === true
|
|
88
|
-
? function (input, headers) {
|
|
89
|
-
var p = closure("decode")(headers, input);
|
|
90
|
-
var s = AesPkcs5_1.AesPkcs5.decrypt(input, p.key, p.iv);
|
|
91
|
-
return s.length ? JSON.parse(s) : s;
|
|
92
|
-
}
|
|
93
|
-
: function (input) { return input; },
|
|
94
|
-
})(connection, route, input, stringify)];
|
|
95
|
-
});
|
|
53
|
+
: (input) => input,
|
|
54
|
+
decode: ((_d = route.response) === null || _d === void 0 ? void 0 : _d.encrypted) === true
|
|
55
|
+
? (input, headers) => {
|
|
56
|
+
const p = closure("decode")(headers, input);
|
|
57
|
+
const s = AesPkcs5_1.AesPkcs5.decrypt(input, p.key, p.iv);
|
|
58
|
+
return s.length ? JSON.parse(s) : s;
|
|
59
|
+
}
|
|
60
|
+
: (input) => input,
|
|
61
|
+
})(connection, route, input, stringify);
|
|
96
62
|
});
|
|
97
63
|
}
|
|
98
64
|
EncryptedFetcher.fetch = fetch;
|
|
99
65
|
function propagate(connection, route, input, stringify) {
|
|
100
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
101
|
-
var closure;
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
102
67
|
var _a, _b, _c, _d;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
68
|
+
if ((((_a = route.request) === null || _a === void 0 ? void 0 : _a.encrypted) === true || ((_b = route.response) === null || _b === void 0 ? void 0 : _b.encrypted)) &&
|
|
69
|
+
connection.encryption === undefined)
|
|
70
|
+
throw new Error("Error on EncryptedFetcher.propagate(): the encryption password has not been configured.");
|
|
71
|
+
const closure = typeof connection.encryption === "function"
|
|
72
|
+
? (direction) => (headers, body) => connection.encryption({
|
|
73
|
+
headers,
|
|
74
|
+
body,
|
|
75
|
+
direction,
|
|
76
|
+
})
|
|
77
|
+
: () => () => connection.encryption;
|
|
78
|
+
return FetcherBase_1.FetcherBase.propagate({
|
|
79
|
+
className: "EncryptedFetcher",
|
|
80
|
+
encode: ((_c = route.request) === null || _c === void 0 ? void 0 : _c.encrypted) === true
|
|
81
|
+
? (input, headers) => {
|
|
82
|
+
const p = closure("encode")(headers, input);
|
|
83
|
+
return AesPkcs5_1.AesPkcs5.encrypt((stringify !== null && stringify !== void 0 ? stringify : JSON.stringify)(input), p.key, p.iv);
|
|
84
|
+
}
|
|
85
|
+
: (input) => input,
|
|
86
|
+
decode: ((_d = route.response) === null || _d === void 0 ? void 0 : _d.encrypted) === true
|
|
87
|
+
? (input, headers) => {
|
|
88
|
+
const p = closure("decode")(headers, input);
|
|
89
|
+
const s = AesPkcs5_1.AesPkcs5.decrypt(input, p.key, p.iv);
|
|
90
|
+
return s.length ? JSON.parse(s) : s;
|
|
116
91
|
}
|
|
117
|
-
:
|
|
118
|
-
|
|
119
|
-
className: "EncryptedFetcher",
|
|
120
|
-
encode: ((_c = route.request) === null || _c === void 0 ? void 0 : _c.encrypted) === true
|
|
121
|
-
? function (input, headers) {
|
|
122
|
-
var p = closure("encode")(headers, input);
|
|
123
|
-
return AesPkcs5_1.AesPkcs5.encrypt((stringify !== null && stringify !== void 0 ? stringify : JSON.stringify)(input), p.key, p.iv);
|
|
124
|
-
}
|
|
125
|
-
: function (input) { return input; },
|
|
126
|
-
decode: ((_d = route.response) === null || _d === void 0 ? void 0 : _d.encrypted) === true
|
|
127
|
-
? function (input, headers) {
|
|
128
|
-
var p = closure("decode")(headers, input);
|
|
129
|
-
var s = AesPkcs5_1.AesPkcs5.decrypt(input, p.key, p.iv);
|
|
130
|
-
return s.length ? JSON.parse(s) : s;
|
|
131
|
-
}
|
|
132
|
-
: function (input) { return input; },
|
|
133
|
-
})(connection, route, input, stringify)];
|
|
134
|
-
});
|
|
92
|
+
: (input) => input,
|
|
93
|
+
})(connection, route, input, stringify);
|
|
135
94
|
});
|
|
136
95
|
}
|
|
137
96
|
EncryptedFetcher.propagate = propagate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EncryptedFetcher.js","sourceRoot":"","sources":["../src/EncryptedFetcher.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EncryptedFetcher.js","sourceRoot":"","sources":["../src/EncryptedFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAsC;AAKtC,wDAAqD;AAErD;;;;;;;;;;;;;;;GAeG;AACH,IAAiB,gBAAgB,CAwJhC;AAxJD,WAAiB,gBAAgB;IAuC/B,SAAsB,KAAK,CACzB,UAAuB,EACvB,KAAwE,EACxE,KAAa,EACb,SAAoC;;;YAEpC,IACE,CAAC,CAAA,MAAA,KAAK,CAAC,OAAO,0CAAE,SAAS,MAAK,IAAI,KAAI,MAAA,KAAK,CAAC,QAAQ,0CAAE,SAAS,CAAA,CAAC;gBAChE,UAAU,CAAC,UAAU,KAAK,SAAS;gBAE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SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,EACpC,CAAC,CAAC,GAAG,EACL,CAAC,CAAC,EAAE,CACL,CAAC;oBACJ,CAAC;oBACH,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;gBACtB,MAAM,EACJ,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,SAAS,MAAK,IAAI;oBAChC,CAAC,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;wBACjB,MAAM,CAAC,GAAwB,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;wBACjE,MAAM,CAAC,GAAW,mBAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;wBACvD,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBACtC,CAAC;oBACH,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;aACvB,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,CAAoB,CAAC;QAC7D,CAAC;KAAA;IAjDqB,0BAAS,YAiD9B,CAAA;AACH,CAAC,EAxJgB,gBAAgB,gCAAhB,gBAAgB,QAwJhC"}
|
package/lib/HttpError.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { HttpError } from "@
|
|
1
|
+
export { HttpError } from "@typia/utils";
|
package/lib/HttpError.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HttpError = void 0;
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "HttpError", { enumerable: true, get: function () { return
|
|
4
|
+
var utils_1 = require("@typia/utils");
|
|
5
|
+
Object.defineProperty(exports, "HttpError", { enumerable: true, get: function () { return utils_1.HttpError; } });
|
|
6
6
|
//# sourceMappingURL=HttpError.js.map
|
package/lib/HttpError.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpError.js","sourceRoot":"","sources":["../src/HttpError.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"HttpError.js","sourceRoot":"","sources":["../src/HttpError.ts"],"names":[],"mappings":";;;AAAA,sCAAyC;AAAhC,kGAAA,SAAS,OAAA"}
|
package/lib/NestiaSimulator.js
CHANGED
|
@@ -1,62 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NestiaSimulator = void 0;
|
|
4
|
-
|
|
4
|
+
const HttpError_1 = require("./HttpError");
|
|
5
5
|
var NestiaSimulator;
|
|
6
6
|
(function (NestiaSimulator) {
|
|
7
|
-
NestiaSimulator.assert =
|
|
7
|
+
NestiaSimulator.assert = (props) => {
|
|
8
8
|
return {
|
|
9
9
|
param: param(props),
|
|
10
10
|
query: query(props),
|
|
11
11
|
body: body(props),
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return function (task) {
|
|
17
|
-
validate(function (exp) { return "URL parameter \"".concat(name, "\" is not ").concat(exp.expected, " type."); })(props)(task);
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
var query = function (props) {
|
|
22
|
-
return function (task) {
|
|
23
|
-
return validate(function () { return "Request query parameters are not following the promised type."; })(props)(task);
|
|
24
|
-
};
|
|
14
|
+
const param = (props) => (name) => (task) => {
|
|
15
|
+
validate((exp) => `URL parameter "${name}" is not ${exp.expected} type.`)(props)(task);
|
|
25
16
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
value: exp.value,
|
|
46
|
-
message: message(exp),
|
|
47
|
-
}));
|
|
48
|
-
throw exp;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
};
|
|
17
|
+
const query = (props) => (task) => validate(() => "Request query parameters are not following the promised type.")(props)(task);
|
|
18
|
+
const body = (props) => (task) => validate(() => "Request body is not following the promised type.")(props)(task);
|
|
19
|
+
const validate = (message, path) => (props) => (task) => {
|
|
20
|
+
try {
|
|
21
|
+
task();
|
|
22
|
+
}
|
|
23
|
+
catch (exp) {
|
|
24
|
+
if (isTypeGuardError(exp))
|
|
25
|
+
throw new HttpError_1.HttpError(props.method, props.host + props.path, 400, {
|
|
26
|
+
"Content-Type": props.contentType,
|
|
27
|
+
}, JSON.stringify({
|
|
28
|
+
method: exp.method,
|
|
29
|
+
path: path !== null && path !== void 0 ? path : exp.path,
|
|
30
|
+
expected: exp.expected,
|
|
31
|
+
value: exp.value,
|
|
32
|
+
message: message(exp),
|
|
33
|
+
}));
|
|
34
|
+
throw exp;
|
|
35
|
+
}
|
|
52
36
|
};
|
|
53
37
|
})(NestiaSimulator || (exports.NestiaSimulator = NestiaSimulator = {}));
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
(undefined === input.stack || "string" === typeof input.stack);
|
|
61
|
-
};
|
|
38
|
+
const isTypeGuardError = (input) => "string" === typeof input.method &&
|
|
39
|
+
(undefined === input.path || "string" === typeof input.path) &&
|
|
40
|
+
"string" === typeof input.expected &&
|
|
41
|
+
"string" === typeof input.name &&
|
|
42
|
+
"string" === typeof input.message &&
|
|
43
|
+
(undefined === input.stack || "string" === typeof input.stack);
|
|
62
44
|
//# sourceMappingURL=NestiaSimulator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaSimulator.js","sourceRoot":"","sources":["../src/NestiaSimulator.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"NestiaSimulator.js","sourceRoot":"","sources":["../src/NestiaSimulator.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AAExC,IAAiB,eAAe,CAgE/B;AAhED,WAAiB,eAAe;IAQjB,sBAAM,GAAG,CAAC,KAAa,EAAE,EAAE;QACtC,OAAO;YACL,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC;YACnB,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC;YACnB,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC;SAClB,CAAC;IACJ,CAAC,CAAC;IACF,MAAM,KAAK,GACT,CAAC,KAAa,EAAE,EAAE,CAClB,CAAC,IAAY,EAAE,EAAE,CACjB,CAAI,IAAa,EAAQ,EAAE;QACzB,QAAQ,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,kBAAkB,IAAI,YAAY,GAAG,CAAC,QAAQ,QAAQ,CAAC,CACvE,KAAK,CACN,CAAC,IAAI,CAAC,CAAC;IACV,CAAC,CAAC;IAEJ,MAAM,KAAK,GACT,CAAC,KAAa,EAAE,EAAE,CAClB,CAAI,IAAa,EAAQ,EAAE,CACzB,QAAQ,CACN,GAAG,EAAE,CAAC,+DAA+D,CACtE,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;IAEnB,MAAM,IAAI,GACR,CAAC,KAAa,EAAE,EAAE,CAClB,CAAI,IAAa,EAAQ,EAAE,CACzB,QAAQ,CAAC,GAAG,EAAE,CAAC,kDAAkD,CAAC,CAAC,KAAK,CAAC,CACvE,IAAI,CACL,CAAC;IAEN,MAAM,QAAQ,GACZ,CAAC,OAAwC,EAAE,IAAa,EAAE,EAAE,CAC5D,CAAC,KAAa,EAAE,EAAE,CAClB,CAAI,IAAa,EAAQ,EAAE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