@nestia/fetcher 7.0.3 → 7.1.1-dev.20250714
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/README.md +93 -93
- package/lib/AesPkcs5.d.ts +6 -6
- package/lib/AesPkcs5.js +6 -6
- package/lib/AesPkcs5.js.map +1 -1
- package/lib/IConnection.d.ts +58 -71
- package/package.json +2 -7
- package/src/AesPkcs5.ts +49 -50
- package/src/EncryptedFetcher.ts +174 -174
- package/src/FormDataInput.ts +87 -87
- package/src/HttpError.ts +1 -1
- package/src/IConnection.ts +241 -255
- package/src/IEncryptionPassword.ts +50 -50
- package/src/IFetchEvent.ts +31 -31
- package/src/IFetchRoute.ts +69 -69
- package/src/IPropagation.ts +100 -100
- package/src/MigrateFetcher.ts +118 -118
- package/src/NestiaSimulator.ts +82 -82
- package/src/PlainFetcher.ts +105 -105
- package/src/index.ts +7 -7
- package/src/internal/FetcherBase.ts +245 -245
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://github.com/samchon/nestia/actions?query=workflow%3Abuild)
|
|
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)
|
|
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%3Abuild)
|
|
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.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Utility class for the AES-128/256 encryption.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* - AES-128/256
|
|
5
|
+
* - CBC mode
|
|
6
|
+
* - PKCS#5 Padding
|
|
7
|
+
* - Base64 Encoding
|
|
8
8
|
*
|
|
9
9
|
* @author Jeongho Nam - https://github.com/samchon
|
|
10
10
|
*/
|
|
@@ -15,7 +15,7 @@ export declare namespace AesPkcs5 {
|
|
|
15
15
|
* @param data Target data
|
|
16
16
|
* @param key Key value of the encryption.
|
|
17
17
|
* @param iv Initializer Vector for the encryption
|
|
18
|
-
* @
|
|
18
|
+
* @returns Encrypted data
|
|
19
19
|
*/
|
|
20
20
|
function encrypt(data: string, key: string, iv: string): string;
|
|
21
21
|
/**
|
|
@@ -24,7 +24,7 @@ export declare namespace AesPkcs5 {
|
|
|
24
24
|
* @param data Target data
|
|
25
25
|
* @param key Key value of the decryption.
|
|
26
26
|
* @param iv Initializer Vector for the decryption
|
|
27
|
-
* @
|
|
27
|
+
* @returns Decrypted data.
|
|
28
28
|
*/
|
|
29
29
|
function decrypt(data: string, key: string, iv: string): string;
|
|
30
30
|
}
|
package/lib/AesPkcs5.js
CHANGED
|
@@ -8,10 +8,10 @@ var crypto_1 = __importDefault(require("crypto"));
|
|
|
8
8
|
/**
|
|
9
9
|
* Utility class for the AES-128/256 encryption.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* - AES-128/256
|
|
12
|
+
* - CBC mode
|
|
13
|
+
* - PKCS#5 Padding
|
|
14
|
+
* - Base64 Encoding
|
|
15
15
|
*
|
|
16
16
|
* @author Jeongho Nam - https://github.com/samchon
|
|
17
17
|
*/
|
|
@@ -23,7 +23,7 @@ var AesPkcs5;
|
|
|
23
23
|
* @param data Target data
|
|
24
24
|
* @param key Key value of the encryption.
|
|
25
25
|
* @param iv Initializer Vector for the encryption
|
|
26
|
-
* @
|
|
26
|
+
* @returns Encrypted data
|
|
27
27
|
*/
|
|
28
28
|
function encrypt(data, key, iv) {
|
|
29
29
|
var bytes = key.length * 8;
|
|
@@ -37,7 +37,7 @@ var AesPkcs5;
|
|
|
37
37
|
* @param data Target data
|
|
38
38
|
* @param key Key value of the decryption.
|
|
39
39
|
* @param iv Initializer Vector for the decryption
|
|
40
|
-
* @
|
|
40
|
+
* @returns Decrypted data.
|
|
41
41
|
*/
|
|
42
42
|
function decrypt(data, key, iv) {
|
|
43
43
|
var bytes = key.length * 8;
|
package/lib/AesPkcs5.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AesPkcs5.js","sourceRoot":"","sources":["../src/AesPkcs5.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA4B;AAE5B;;;;;;;;;GASG;AACH,IAAiB,QAAQ,
|
|
1
|
+
{"version":3,"file":"AesPkcs5.js","sourceRoot":"","sources":["../src/AesPkcs5.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA4B;AAE5B;;;;;;;;;GASG;AACH,IAAiB,QAAQ,CAoCxB;AApCD,WAAiB,QAAQ;IACvB;;;;;;;OAOG;IACH,SAAgB,OAAO,CAAC,IAAY,EAAE,GAAW,EAAE,EAAU;QAC3D,IAAM,KAAK,GAAW,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;QACrC,IAAM,MAAM,GAAkB,gBAAM,CAAC,cAAc,CACjD,cAAO,KAAK,SAAM,EAClB,GAAG,EACH,EAAE,CACH,CAAC;QACF,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACxE,CAAC;IARe,gBAAO,UAQtB,CAAA;IAED;;;;;;;OAOG;IACH,SAAgB,OAAO,CAAC,IAAY,EAAE,GAAW,EAAE,EAAU;QAC3D,IAAM,KAAK,GAAW,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;QACrC,IAAM,QAAQ,GAAoB,gBAAM,CAAC,gBAAgB,CACvD,cAAO,KAAK,SAAM,EAClB,GAAG,EACH,EAAE,CACH,CAAC;QACF,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1E,CAAC;IARe,gBAAO,UAQtB,CAAA;AACH,CAAC,EApCgB,QAAQ,wBAAR,QAAQ,QAoCxB"}
|
package/lib/IConnection.d.ts
CHANGED
|
@@ -1,46 +1,41 @@
|
|
|
1
|
-
import { IRandomGenerator } from "typia";
|
|
2
1
|
import { IEncryptionPassword } from "./IEncryptionPassword";
|
|
3
2
|
import { IFetchEvent } from "./IFetchEvent";
|
|
4
3
|
/**
|
|
5
4
|
* Connection information.
|
|
6
5
|
*
|
|
7
|
-
* `IConnection` is an interface ttype who represents connection information of
|
|
8
|
-
* remote HTTP server. You can target the remote HTTP server by wring the
|
|
9
|
-
* {@link IConnection.host} variable down. Also, you can configure special header
|
|
10
|
-
* by specializing the {@link IConnection.headers} variable.
|
|
6
|
+
* `IConnection` is an interface ttype who represents connection information of
|
|
7
|
+
* the remote HTTP server. You can target the remote HTTP server by wring the
|
|
8
|
+
* {@link IConnection.host} variable down. Also, you can configure special header
|
|
9
|
+
* values by specializing the {@link IConnection.headers} variable.
|
|
11
10
|
*
|
|
12
|
-
* If the remote HTTP server encrypts or decrypts its body data through the
|
|
13
|
-
* algorithm, specify the {@link IConnection.encryption} with
|
|
14
|
-
* or {@link IEncryptionPassword.Closure} variable.
|
|
11
|
+
* If the remote HTTP server encrypts or decrypts its body data through the
|
|
12
|
+
* AES-128/256 algorithm, specify the {@link IConnection.encryption} with
|
|
13
|
+
* {@link IEncryptionPassword} or {@link IEncryptionPassword.Closure} variable.
|
|
15
14
|
*
|
|
16
15
|
* @author Jenogho Nam - https://github.com/samchon
|
|
17
16
|
* @author Seungjun We - https://github.com/SeungjunWe
|
|
18
17
|
*/
|
|
19
18
|
export interface IConnection<Headers extends object | undefined = object | undefined> {
|
|
20
|
-
/**
|
|
21
|
-
* Host address of the remote HTTP server.
|
|
22
|
-
*/
|
|
19
|
+
/** Host address of the remote HTTP server. */
|
|
23
20
|
host: string;
|
|
24
|
-
/**
|
|
25
|
-
* Header values delivered to the remote HTTP server.
|
|
26
|
-
*/
|
|
21
|
+
/** Header values delivered to the remote HTTP server. */
|
|
27
22
|
headers?: Record<string, IConnection.HeaderValue> & IConnection.Headerify<Headers>;
|
|
28
23
|
/**
|
|
29
24
|
* Use simulation mode.
|
|
30
25
|
*
|
|
31
|
-
* If you configure this property to be `true
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* request data validation.
|
|
26
|
+
* If you configure this property to be `true`, your SDK library does not send
|
|
27
|
+
* any request to remote backend server, but just returns random data
|
|
28
|
+
* generated by `typia.random<T>()` function with request data validation.
|
|
35
29
|
*
|
|
36
|
-
* By the way, to utilize this simulation mode, SDK library must be generated
|
|
37
|
-
* {@link INestiaConfig.simulate} option, too. Open `nestia.config.ts`
|
|
38
|
-
* configure {@link INestiaConfig.simulate} property to be `true`.
|
|
39
|
-
* generated SDK library would have a built-in mock-up data
|
|
30
|
+
* By the way, to utilize this simulation mode, SDK library must be generated
|
|
31
|
+
* with {@link INestiaConfig.simulate} option, too. Open `nestia.config.ts`
|
|
32
|
+
* file, and configure {@link INestiaConfig.simulate} property to be `true`.
|
|
33
|
+
* Them, newly generated SDK library would have a built-in mock-up data
|
|
34
|
+
* generator.
|
|
40
35
|
*
|
|
41
36
|
* @default false
|
|
42
37
|
*/
|
|
43
|
-
simulate?: boolean
|
|
38
|
+
simulate?: boolean;
|
|
44
39
|
/**
|
|
45
40
|
* Logger function.
|
|
46
41
|
*
|
|
@@ -57,20 +52,17 @@ export interface IConnection<Headers extends object | undefined = object | undef
|
|
|
57
52
|
* security reason.
|
|
58
53
|
*/
|
|
59
54
|
encryption?: IEncryptionPassword | IEncryptionPassword.Closure;
|
|
60
|
-
/**
|
|
61
|
-
* Additional options for the `fetch` function.
|
|
62
|
-
*/
|
|
55
|
+
/** Additional options for the `fetch` function. */
|
|
63
56
|
options?: IConnection.IOptions;
|
|
64
57
|
/**
|
|
65
58
|
* Custom fetch function.
|
|
66
59
|
*
|
|
67
|
-
* If you want to use custom `fetch` function instead of built-in,
|
|
68
|
-
*
|
|
60
|
+
* If you want to use custom `fetch` function instead of built-in, assign your
|
|
61
|
+
* custom `fetch` function into this property.
|
|
69
62
|
*
|
|
70
|
-
* For reference, the `fetch` function has started to be supported
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* into this property.
|
|
63
|
+
* For reference, the `fetch` function has started to be supported since
|
|
64
|
+
* version 20 of NodeJS. Therefore, if you are using NodeJS version 19 or
|
|
65
|
+
* lower, you have to assign the `node-fetch` module into this property.
|
|
74
66
|
*/
|
|
75
67
|
fetch?: typeof fetch;
|
|
76
68
|
}
|
|
@@ -78,12 +70,12 @@ export declare namespace IConnection {
|
|
|
78
70
|
/**
|
|
79
71
|
* Additional options for the `fetch` function.
|
|
80
72
|
*
|
|
81
|
-
* Almost same with {@link RequestInit} type of the {@link fetch} function,
|
|
82
|
-
*
|
|
73
|
+
* Almost same with {@link RequestInit} type of the {@link fetch} function, but
|
|
74
|
+
* `body`, `headers` and `method` properties are omitted.
|
|
83
75
|
*
|
|
84
|
-
* The reason why defining duplicated definition of {@link RequestInit}
|
|
85
|
-
*
|
|
86
|
-
*
|
|
76
|
+
* The reason why defining duplicated definition of {@link RequestInit} is for
|
|
77
|
+
* legacy NodeJS environments, which does not have the {@link fetch} function
|
|
78
|
+
* type.
|
|
87
79
|
*/
|
|
88
80
|
interface IOptions {
|
|
89
81
|
/**
|
|
@@ -103,9 +95,7 @@ export declare namespace IConnection {
|
|
|
103
95
|
* Sets request's integrity.
|
|
104
96
|
*/
|
|
105
97
|
integrity?: string;
|
|
106
|
-
/**
|
|
107
|
-
* A boolean to set request's keepalive.
|
|
108
|
-
*/
|
|
98
|
+
/** A boolean to set request's keepalive. */
|
|
109
99
|
keepalive?: boolean;
|
|
110
100
|
/**
|
|
111
101
|
* A string to indicate whether the request will use CORS, or will be
|
|
@@ -115,25 +105,21 @@ export declare namespace IConnection {
|
|
|
115
105
|
*/
|
|
116
106
|
mode?: "cors" | "navigate" | "no-cors" | "same-origin";
|
|
117
107
|
/**
|
|
118
|
-
* A string indicating whether request follows redirects, results in
|
|
119
|
-
*
|
|
120
|
-
*
|
|
108
|
+
* A string indicating whether request follows redirects, results in an
|
|
109
|
+
* error upon encountering a redirect, or returns the redirect (in an opaque
|
|
110
|
+
* fashion).
|
|
121
111
|
*
|
|
122
112
|
* Sets request's redirect.
|
|
123
113
|
*/
|
|
124
114
|
redirect?: "error" | "follow" | "manual";
|
|
125
115
|
/**
|
|
126
|
-
* A string whose value is a same-origin URL, "about:client", or the
|
|
127
|
-
*
|
|
116
|
+
* A string whose value is a same-origin URL, "about:client", or the empty
|
|
117
|
+
* string, to set request's referrer.
|
|
128
118
|
*/
|
|
129
119
|
referrer?: string;
|
|
130
|
-
/**
|
|
131
|
-
* A referrer policy to set request's referrerPolicy.
|
|
132
|
-
*/
|
|
120
|
+
/** A referrer policy to set request's referrerPolicy. */
|
|
133
121
|
referrerPolicy?: "" | "no-referrer" | "no-referrer-when-downgrade" | "origin" | "origin-when-cross-origin" | "same-origin" | "strict-origin" | "strict-origin-when-cross-origin" | "unsafe-url";
|
|
134
|
-
/**
|
|
135
|
-
* An AbortSignal to set request's signal.
|
|
136
|
-
*/
|
|
122
|
+
/** An AbortSignal to set request's signal. */
|
|
137
123
|
signal?: AbortSignal | null;
|
|
138
124
|
}
|
|
139
125
|
/**
|
|
@@ -145,32 +131,33 @@ export declare namespace IConnection {
|
|
|
145
131
|
/**
|
|
146
132
|
* Type of headers
|
|
147
133
|
*
|
|
148
|
-
* `Headerify` removes every properties that are not allowed in the
|
|
149
|
-
*
|
|
134
|
+
* `Headerify` removes every properties that are not allowed in the HTTP
|
|
135
|
+
* headers type.
|
|
150
136
|
*
|
|
151
137
|
* Below are list of prohibited in HTTP headers.
|
|
152
138
|
*
|
|
153
139
|
* 1. Value type one of {@link HeaderValue}
|
|
154
140
|
* 2. Key is "set-cookie", but value is not an Array type
|
|
155
141
|
* 3. Key is one of them, but value is Array type
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
142
|
+
*
|
|
143
|
+
* - "age"
|
|
144
|
+
* - "authorization"
|
|
145
|
+
* - "content-length"
|
|
146
|
+
* - "content-type"
|
|
147
|
+
* - "etag"
|
|
148
|
+
* - "expires"
|
|
149
|
+
* - "from"
|
|
150
|
+
* - "host"
|
|
151
|
+
* - "if-modified-since"
|
|
152
|
+
* - "if-unmodified-since"
|
|
153
|
+
* - "last-modified"
|
|
154
|
+
* - "location"
|
|
155
|
+
* - "max-forwards"
|
|
156
|
+
* - "proxy-authorization"
|
|
157
|
+
* - "referer"
|
|
158
|
+
* - "retry-after"
|
|
159
|
+
* - "server"
|
|
160
|
+
* - "user-agent"
|
|
174
161
|
*/
|
|
175
162
|
type Headerify<T extends object | undefined> = {
|
|
176
163
|
[P in keyof T]?: T[P] extends HeaderValue | undefined ? P extends string ? Lowercase<P> extends "set-cookie" ? T[P] extends Array<HeaderValue> ? T[P] | undefined : never : Lowercase<P> extends "age" | "authorization" | "content-length" | "content-type" | "etag" | "expires" | "from" | "host" | "if-modified-since" | "if-unmodified-since" | "last-modified" | "location" | "max-forwards" | "proxy-authorization" | "referer" | "retry-after" | "server" | "user-agent" ? T[P] extends Array<HeaderValue> ? never : T[P] | undefined : T[P] | undefined : never : never;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestia/fetcher",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.1.1-dev.20250714",
|
|
4
4
|
"description": "Fetcher library of Nestia SDK",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -26,12 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://nestia.io",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@samchon/openapi": "^4.
|
|
30
|
-
"typia": "^9.3.1"
|
|
31
|
-
},
|
|
32
|
-
"peerDependencies": {
|
|
33
|
-
"@samchon/openapi": ">=4.3.3 <5.0.0",
|
|
34
|
-
"typia": ">=9.3.1 <10.0.0"
|
|
29
|
+
"@samchon/openapi": "^4.5.0"
|
|
35
30
|
},
|
|
36
31
|
"devDependencies": {
|
|
37
32
|
"@types/node": "^18.11.14",
|
package/src/AesPkcs5.ts
CHANGED
|
@@ -1,50 +1,49 @@
|
|
|
1
|
-
import crypto from "crypto";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Utility class for the AES-128/256 encryption.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
12
|
-
*/
|
|
13
|
-
export namespace AesPkcs5 {
|
|
14
|
-
/**
|
|
15
|
-
* Encrypt data
|
|
16
|
-
*
|
|
17
|
-
* @param data Target data
|
|
18
|
-
* @param key Key value of the encryption.
|
|
19
|
-
* @param iv Initializer Vector for the encryption
|
|
20
|
-
* @
|
|
21
|
-
*/
|
|
22
|
-
export function encrypt(data: string, key: string, iv: string): string {
|
|
23
|
-
const bytes: number = key.length * 8;
|
|
24
|
-
const cipher: crypto.Cipher = crypto.createCipheriv(
|
|
25
|
-
`AES-${bytes}-CBC`,
|
|
26
|
-
key,
|
|
27
|
-
iv,
|
|
28
|
-
);
|
|
29
|
-
return cipher.update(data, "utf8", "base64") + cipher.final("base64");
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Decrypt data.
|
|
34
|
-
*
|
|
35
|
-
* @param data Target data
|
|
36
|
-
* @param key Key value of the decryption.
|
|
37
|
-
* @param iv Initializer Vector for the decryption
|
|
38
|
-
* @
|
|
39
|
-
*/
|
|
40
|
-
export function decrypt(data: string, key: string, iv: string): string {
|
|
41
|
-
const bytes: number = key.length * 8;
|
|
42
|
-
const decipher: crypto.Decipher = crypto.createDecipheriv(
|
|
43
|
-
`AES-${bytes}-CBC`,
|
|
44
|
-
key,
|
|
45
|
-
iv,
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
1
|
+
import crypto from "crypto";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Utility class for the AES-128/256 encryption.
|
|
5
|
+
*
|
|
6
|
+
* - AES-128/256
|
|
7
|
+
* - CBC mode
|
|
8
|
+
* - PKCS#5 Padding
|
|
9
|
+
* - Base64 Encoding
|
|
10
|
+
*
|
|
11
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
12
|
+
*/
|
|
13
|
+
export namespace AesPkcs5 {
|
|
14
|
+
/**
|
|
15
|
+
* Encrypt data
|
|
16
|
+
*
|
|
17
|
+
* @param data Target data
|
|
18
|
+
* @param key Key value of the encryption.
|
|
19
|
+
* @param iv Initializer Vector for the encryption
|
|
20
|
+
* @returns Encrypted data
|
|
21
|
+
*/
|
|
22
|
+
export function encrypt(data: string, key: string, iv: string): string {
|
|
23
|
+
const bytes: number = key.length * 8;
|
|
24
|
+
const cipher: crypto.Cipher = crypto.createCipheriv(
|
|
25
|
+
`AES-${bytes}-CBC`,
|
|
26
|
+
key,
|
|
27
|
+
iv,
|
|
28
|
+
);
|
|
29
|
+
return cipher.update(data, "utf8", "base64") + cipher.final("base64");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Decrypt data.
|
|
34
|
+
*
|
|
35
|
+
* @param data Target data
|
|
36
|
+
* @param key Key value of the decryption.
|
|
37
|
+
* @param iv Initializer Vector for the decryption
|
|
38
|
+
* @returns Decrypted data.
|
|
39
|
+
*/
|
|
40
|
+
export function decrypt(data: string, key: string, iv: string): string {
|
|
41
|
+
const bytes: number = key.length * 8;
|
|
42
|
+
const decipher: crypto.Decipher = crypto.createDecipheriv(
|
|
43
|
+
`AES-${bytes}-CBC`,
|
|
44
|
+
key,
|
|
45
|
+
iv,
|
|
46
|
+
);
|
|
47
|
+
return decipher.update(data, "base64", "utf8") + decipher.final("utf8");
|
|
48
|
+
}
|
|
49
|
+
}
|