@nestia/fetcher 4.6.1-dev.20250117 → 4.6.2
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 +92 -87
- package/lib/FormDataInput.d.ts +1 -1
- package/lib/IConnection.d.ts +1 -1
- package/package.json +1 -1
- package/src/AesPkcs5.ts +50 -50
- package/src/EncryptedFetcher.ts +174 -174
- package/src/FormDataInput.ts +87 -87
- package/src/HttpError.ts +1 -1
- package/src/IConnection.ts +255 -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/src/IConnection.ts
CHANGED
|
@@ -1,255 +1,255 @@
|
|
|
1
|
-
/// <reference lib="dom" />
|
|
2
|
-
import { IRandomGenerator } from "typia";
|
|
3
|
-
|
|
4
|
-
import { IEncryptionPassword } from "./IEncryptionPassword";
|
|
5
|
-
import { IFetchEvent } from "./IFetchEvent";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Connection information.
|
|
9
|
-
*
|
|
10
|
-
* `IConnection` is an interface ttype who represents connection information of the
|
|
11
|
-
* remote HTTP server. You can target the remote HTTP server by wring the
|
|
12
|
-
* {@link IConnection.host} variable down. Also, you can configure special header values
|
|
13
|
-
* by specializing the {@link IConnection.headers} variable.
|
|
14
|
-
*
|
|
15
|
-
* If the remote HTTP server encrypts or decrypts its body data through the AES-128/256
|
|
16
|
-
* algorithm, specify the {@link IConnection.encryption} with {@link IEncryptionPassword}
|
|
17
|
-
* or {@link IEncryptionPassword.Closure} variable.
|
|
18
|
-
*
|
|
19
|
-
* @author Jenogho Nam - https://github.com/samchon
|
|
20
|
-
* @author Seungjun We - https://github.com/SeungjunWe
|
|
21
|
-
*/
|
|
22
|
-
export interface IConnection<
|
|
23
|
-
Headers extends object | undefined = object | undefined,
|
|
24
|
-
> {
|
|
25
|
-
/**
|
|
26
|
-
* Host address of the remote HTTP server.
|
|
27
|
-
*/
|
|
28
|
-
host: string;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Header values delivered to the remote HTTP server.
|
|
32
|
-
*/
|
|
33
|
-
headers?: Record<string, IConnection.HeaderValue> &
|
|
34
|
-
IConnection.Headerify<Headers>;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Use simulation mode.
|
|
38
|
-
*
|
|
39
|
-
* If you configure this property to be `true` or assign an {@link IRandomGenerator}
|
|
40
|
-
* instance, your SDK library does not send any request to remote backend server,
|
|
41
|
-
* but just returns random data generated by `typia.random<T>()` function with
|
|
42
|
-
* request data validation.
|
|
43
|
-
*
|
|
44
|
-
* By the way, to utilize this simulation mode, SDK library must be generated with
|
|
45
|
-
* {@link INestiaConfig.simulate} option, too. Open `nestia.config.ts` file, and
|
|
46
|
-
* configure {@link INestiaConfig.simulate} property to be `true`. Them, newly
|
|
47
|
-
* generated SDK library would have a built-in mock-up data generator.
|
|
48
|
-
*
|
|
49
|
-
* @default false
|
|
50
|
-
*/
|
|
51
|
-
simulate?: boolean | Partial<IRandomGenerator>;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Logger function.
|
|
55
|
-
*
|
|
56
|
-
* This function is called when the fetch event is completed.
|
|
57
|
-
*
|
|
58
|
-
* @param event Event information of the fetch event.
|
|
59
|
-
*/
|
|
60
|
-
logger?: (event: IFetchEvent) => Promise<void>;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Encryption password of its closure function.
|
|
64
|
-
*
|
|
65
|
-
* Define it only when target backend server is encrypting body data through
|
|
66
|
-
* `@EncryptedRoute` or `@EncryptedBody` decorators of `@nestia/core` for
|
|
67
|
-
* security reason.
|
|
68
|
-
*/
|
|
69
|
-
encryption?: IEncryptionPassword | IEncryptionPassword.Closure;
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Additional options for the `fetch` function.
|
|
73
|
-
*/
|
|
74
|
-
options?: IConnection.IOptions;
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Custom fetch function.
|
|
78
|
-
*
|
|
79
|
-
* If you want to use custom `fetch` function instead of built-in,
|
|
80
|
-
* assign your custom `fetch` function into this property.
|
|
81
|
-
*
|
|
82
|
-
* For reference, the `fetch` function has started to be supported
|
|
83
|
-
* since version 20 of NodeJS. Therefore, if you are using NodeJS
|
|
84
|
-
* version 19 or lower, you have to assign the `node-fetch` module
|
|
85
|
-
* into this property.
|
|
86
|
-
*/
|
|
87
|
-
fetch?: typeof fetch;
|
|
88
|
-
}
|
|
89
|
-
export namespace IConnection {
|
|
90
|
-
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
* Almost same with {@link RequestInit} type of the {@link fetch} function,
|
|
94
|
-
* but `body`, `headers` and `method` properties are omitted.
|
|
95
|
-
*
|
|
96
|
-
* The reason why defining duplicated definition of {@link RequestInit}
|
|
97
|
-
* is for legacy NodeJS environments, which does not have the {@link fetch}
|
|
98
|
-
* function type.
|
|
99
|
-
*/
|
|
100
|
-
export interface IOptions {
|
|
101
|
-
/**
|
|
102
|
-
* A string indicating how the request will interact with the browser's
|
|
103
|
-
* cache to set request's cache.
|
|
104
|
-
*/
|
|
105
|
-
cache?:
|
|
106
|
-
| "default"
|
|
107
|
-
| "force-cache"
|
|
108
|
-
| "no-cache"
|
|
109
|
-
| "no-store"
|
|
110
|
-
| "only-if-cached"
|
|
111
|
-
| "reload";
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* A string indicating whether credentials will be sent with the request
|
|
115
|
-
* always, never, or only when sent to a same-origin URL. Sets request's
|
|
116
|
-
* credentials.
|
|
117
|
-
*/
|
|
118
|
-
credentials?: "omit" | "same-origin" | "include";
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* A cryptographic hash of the resource to be fetched by request.
|
|
122
|
-
*
|
|
123
|
-
* Sets request's integrity.
|
|
124
|
-
*/
|
|
125
|
-
integrity?: string;
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* A boolean to set request's keepalive.
|
|
129
|
-
*/
|
|
130
|
-
keepalive?: boolean;
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* A string to indicate whether the request will use CORS, or will be
|
|
134
|
-
* restricted to same-origin URLs.
|
|
135
|
-
*
|
|
136
|
-
* Sets request's mode.
|
|
137
|
-
*/
|
|
138
|
-
mode?: "cors" | "navigate" | "no-cors" | "same-origin";
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* A string indicating whether request follows redirects, results in
|
|
142
|
-
* an error upon encountering a redirect, or returns the redirect
|
|
143
|
-
* (in an opaque fashion).
|
|
144
|
-
*
|
|
145
|
-
* Sets request's redirect.
|
|
146
|
-
*/
|
|
147
|
-
redirect?: "error" | "follow" | "manual";
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* A string whose value is a same-origin URL, "about:client", or the
|
|
151
|
-
* empty string, to set request's referrer.
|
|
152
|
-
*/
|
|
153
|
-
referrer?: string;
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* A referrer policy to set request's referrerPolicy.
|
|
157
|
-
*/
|
|
158
|
-
referrerPolicy?:
|
|
159
|
-
| ""
|
|
160
|
-
| "no-referrer"
|
|
161
|
-
| "no-referrer-when-downgrade"
|
|
162
|
-
| "origin"
|
|
163
|
-
| "origin-when-cross-origin"
|
|
164
|
-
| "same-origin"
|
|
165
|
-
| "strict-origin"
|
|
166
|
-
| "strict-origin-when-cross-origin"
|
|
167
|
-
| "unsafe-url";
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* An AbortSignal to set request's signal.
|
|
171
|
-
*/
|
|
172
|
-
signal?: AbortSignal | null;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Type of allowed header values.
|
|
177
|
-
*
|
|
178
|
-
* Only atomic or array of atomic values are allowed.
|
|
179
|
-
*/
|
|
180
|
-
export type HeaderValue =
|
|
181
|
-
| string
|
|
182
|
-
| boolean
|
|
183
|
-
| number
|
|
184
|
-
| bigint
|
|
185
|
-
| string
|
|
186
|
-
| Array<boolean>
|
|
187
|
-
| Array<number>
|
|
188
|
-
| Array<bigint>
|
|
189
|
-
| Array<number>
|
|
190
|
-
| Array<string>;
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Type of headers
|
|
194
|
-
*
|
|
195
|
-
* `Headerify` removes every properties that are not allowed in the
|
|
196
|
-
* HTTP headers type.
|
|
197
|
-
*
|
|
198
|
-
* Below are list of prohibited in HTTP headers.
|
|
199
|
-
*
|
|
200
|
-
* 1. Value type one of {@link HeaderValue}
|
|
201
|
-
* 2. Key is "set-cookie", but value is not an Array type
|
|
202
|
-
* 3. Key is one of them, but value is Array type
|
|
203
|
-
* - "age"
|
|
204
|
-
* - "authorization"
|
|
205
|
-
* - "content-length"
|
|
206
|
-
* - "content-type"
|
|
207
|
-
* - "etag"
|
|
208
|
-
* - "expires"
|
|
209
|
-
* - "from"
|
|
210
|
-
* - "host"
|
|
211
|
-
* - "if-modified-since"
|
|
212
|
-
* - "if-unmodified-since"
|
|
213
|
-
* - "last-modified"
|
|
214
|
-
* - "location"
|
|
215
|
-
* - "max-forwards"
|
|
216
|
-
* - "proxy-authorization"
|
|
217
|
-
* - "referer"
|
|
218
|
-
* - "retry-after"
|
|
219
|
-
* - "server"
|
|
220
|
-
* - "user-agent"
|
|
221
|
-
*/
|
|
222
|
-
export type Headerify<T extends object | undefined> = {
|
|
223
|
-
[P in keyof T]?: T[P] extends HeaderValue | undefined
|
|
224
|
-
? P extends string
|
|
225
|
-
? Lowercase<P> extends "set-cookie"
|
|
226
|
-
? T[P] extends Array<HeaderValue>
|
|
227
|
-
? T[P] | undefined
|
|
228
|
-
: never
|
|
229
|
-
: Lowercase<P> extends
|
|
230
|
-
| "age"
|
|
231
|
-
| "authorization"
|
|
232
|
-
| "content-length"
|
|
233
|
-
| "content-type"
|
|
234
|
-
| "etag"
|
|
235
|
-
| "expires"
|
|
236
|
-
| "from"
|
|
237
|
-
| "host"
|
|
238
|
-
| "if-modified-since"
|
|
239
|
-
| "if-unmodified-since"
|
|
240
|
-
| "last-modified"
|
|
241
|
-
| "location"
|
|
242
|
-
| "max-forwards"
|
|
243
|
-
| "proxy-authorization"
|
|
244
|
-
| "referer"
|
|
245
|
-
| "retry-after"
|
|
246
|
-
| "server"
|
|
247
|
-
| "user-agent"
|
|
248
|
-
? T[P] extends Array<HeaderValue>
|
|
249
|
-
? never
|
|
250
|
-
: T[P] | undefined
|
|
251
|
-
: T[P] | undefined
|
|
252
|
-
: never
|
|
253
|
-
: never;
|
|
254
|
-
};
|
|
255
|
-
}
|
|
1
|
+
/// <reference lib="dom" />
|
|
2
|
+
import { IRandomGenerator } from "typia";
|
|
3
|
+
|
|
4
|
+
import { IEncryptionPassword } from "./IEncryptionPassword";
|
|
5
|
+
import { IFetchEvent } from "./IFetchEvent";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Connection information.
|
|
9
|
+
*
|
|
10
|
+
* `IConnection` is an interface ttype who represents connection information of the
|
|
11
|
+
* remote HTTP server. You can target the remote HTTP server by wring the
|
|
12
|
+
* {@link IConnection.host} variable down. Also, you can configure special header values
|
|
13
|
+
* by specializing the {@link IConnection.headers} variable.
|
|
14
|
+
*
|
|
15
|
+
* If the remote HTTP server encrypts or decrypts its body data through the AES-128/256
|
|
16
|
+
* algorithm, specify the {@link IConnection.encryption} with {@link IEncryptionPassword}
|
|
17
|
+
* or {@link IEncryptionPassword.Closure} variable.
|
|
18
|
+
*
|
|
19
|
+
* @author Jenogho Nam - https://github.com/samchon
|
|
20
|
+
* @author Seungjun We - https://github.com/SeungjunWe
|
|
21
|
+
*/
|
|
22
|
+
export interface IConnection<
|
|
23
|
+
Headers extends object | undefined = object | undefined,
|
|
24
|
+
> {
|
|
25
|
+
/**
|
|
26
|
+
* Host address of the remote HTTP server.
|
|
27
|
+
*/
|
|
28
|
+
host: string;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Header values delivered to the remote HTTP server.
|
|
32
|
+
*/
|
|
33
|
+
headers?: Record<string, IConnection.HeaderValue> &
|
|
34
|
+
IConnection.Headerify<Headers>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Use simulation mode.
|
|
38
|
+
*
|
|
39
|
+
* If you configure this property to be `true` or assign an {@link IRandomGenerator}
|
|
40
|
+
* instance, your SDK library does not send any request to remote backend server,
|
|
41
|
+
* but just returns random data generated by `typia.random<T>()` function with
|
|
42
|
+
* request data validation.
|
|
43
|
+
*
|
|
44
|
+
* By the way, to utilize this simulation mode, SDK library must be generated with
|
|
45
|
+
* {@link INestiaConfig.simulate} option, too. Open `nestia.config.ts` file, and
|
|
46
|
+
* configure {@link INestiaConfig.simulate} property to be `true`. Them, newly
|
|
47
|
+
* generated SDK library would have a built-in mock-up data generator.
|
|
48
|
+
*
|
|
49
|
+
* @default false
|
|
50
|
+
*/
|
|
51
|
+
simulate?: boolean | Partial<IRandomGenerator>;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Logger function.
|
|
55
|
+
*
|
|
56
|
+
* This function is called when the fetch event is completed.
|
|
57
|
+
*
|
|
58
|
+
* @param event Event information of the fetch event.
|
|
59
|
+
*/
|
|
60
|
+
logger?: (event: IFetchEvent) => Promise<void>;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Encryption password of its closure function.
|
|
64
|
+
*
|
|
65
|
+
* Define it only when target backend server is encrypting body data through
|
|
66
|
+
* `@EncryptedRoute` or `@EncryptedBody` decorators of `@nestia/core` for
|
|
67
|
+
* security reason.
|
|
68
|
+
*/
|
|
69
|
+
encryption?: IEncryptionPassword | IEncryptionPassword.Closure;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Additional options for the `fetch` function.
|
|
73
|
+
*/
|
|
74
|
+
options?: IConnection.IOptions;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Custom fetch function.
|
|
78
|
+
*
|
|
79
|
+
* If you want to use custom `fetch` function instead of built-in,
|
|
80
|
+
* assign your custom `fetch` function into this property.
|
|
81
|
+
*
|
|
82
|
+
* For reference, the `fetch` function has started to be supported
|
|
83
|
+
* since version 20 of NodeJS. Therefore, if you are using NodeJS
|
|
84
|
+
* version 19 or lower, you have to assign the `node-fetch` module
|
|
85
|
+
* into this property.
|
|
86
|
+
*/
|
|
87
|
+
fetch?: typeof fetch;
|
|
88
|
+
}
|
|
89
|
+
export namespace IConnection {
|
|
90
|
+
/**
|
|
91
|
+
* Additional options for the `fetch` function.
|
|
92
|
+
*
|
|
93
|
+
* Almost same with {@link RequestInit} type of the {@link fetch} function,
|
|
94
|
+
* but `body`, `headers` and `method` properties are omitted.
|
|
95
|
+
*
|
|
96
|
+
* The reason why defining duplicated definition of {@link RequestInit}
|
|
97
|
+
* is for legacy NodeJS environments, which does not have the {@link fetch}
|
|
98
|
+
* function type.
|
|
99
|
+
*/
|
|
100
|
+
export interface IOptions {
|
|
101
|
+
/**
|
|
102
|
+
* A string indicating how the request will interact with the browser's
|
|
103
|
+
* cache to set request's cache.
|
|
104
|
+
*/
|
|
105
|
+
cache?:
|
|
106
|
+
| "default"
|
|
107
|
+
| "force-cache"
|
|
108
|
+
| "no-cache"
|
|
109
|
+
| "no-store"
|
|
110
|
+
| "only-if-cached"
|
|
111
|
+
| "reload";
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* A string indicating whether credentials will be sent with the request
|
|
115
|
+
* always, never, or only when sent to a same-origin URL. Sets request's
|
|
116
|
+
* credentials.
|
|
117
|
+
*/
|
|
118
|
+
credentials?: "omit" | "same-origin" | "include";
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* A cryptographic hash of the resource to be fetched by request.
|
|
122
|
+
*
|
|
123
|
+
* Sets request's integrity.
|
|
124
|
+
*/
|
|
125
|
+
integrity?: string;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* A boolean to set request's keepalive.
|
|
129
|
+
*/
|
|
130
|
+
keepalive?: boolean;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* A string to indicate whether the request will use CORS, or will be
|
|
134
|
+
* restricted to same-origin URLs.
|
|
135
|
+
*
|
|
136
|
+
* Sets request's mode.
|
|
137
|
+
*/
|
|
138
|
+
mode?: "cors" | "navigate" | "no-cors" | "same-origin";
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* A string indicating whether request follows redirects, results in
|
|
142
|
+
* an error upon encountering a redirect, or returns the redirect
|
|
143
|
+
* (in an opaque fashion).
|
|
144
|
+
*
|
|
145
|
+
* Sets request's redirect.
|
|
146
|
+
*/
|
|
147
|
+
redirect?: "error" | "follow" | "manual";
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* A string whose value is a same-origin URL, "about:client", or the
|
|
151
|
+
* empty string, to set request's referrer.
|
|
152
|
+
*/
|
|
153
|
+
referrer?: string;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* A referrer policy to set request's referrerPolicy.
|
|
157
|
+
*/
|
|
158
|
+
referrerPolicy?:
|
|
159
|
+
| ""
|
|
160
|
+
| "no-referrer"
|
|
161
|
+
| "no-referrer-when-downgrade"
|
|
162
|
+
| "origin"
|
|
163
|
+
| "origin-when-cross-origin"
|
|
164
|
+
| "same-origin"
|
|
165
|
+
| "strict-origin"
|
|
166
|
+
| "strict-origin-when-cross-origin"
|
|
167
|
+
| "unsafe-url";
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* An AbortSignal to set request's signal.
|
|
171
|
+
*/
|
|
172
|
+
signal?: AbortSignal | null;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Type of allowed header values.
|
|
177
|
+
*
|
|
178
|
+
* Only atomic or array of atomic values are allowed.
|
|
179
|
+
*/
|
|
180
|
+
export type HeaderValue =
|
|
181
|
+
| string
|
|
182
|
+
| boolean
|
|
183
|
+
| number
|
|
184
|
+
| bigint
|
|
185
|
+
| string
|
|
186
|
+
| Array<boolean>
|
|
187
|
+
| Array<number>
|
|
188
|
+
| Array<bigint>
|
|
189
|
+
| Array<number>
|
|
190
|
+
| Array<string>;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Type of headers
|
|
194
|
+
*
|
|
195
|
+
* `Headerify` removes every properties that are not allowed in the
|
|
196
|
+
* HTTP headers type.
|
|
197
|
+
*
|
|
198
|
+
* Below are list of prohibited in HTTP headers.
|
|
199
|
+
*
|
|
200
|
+
* 1. Value type one of {@link HeaderValue}
|
|
201
|
+
* 2. Key is "set-cookie", but value is not an Array type
|
|
202
|
+
* 3. Key is one of them, but value is Array type
|
|
203
|
+
* - "age"
|
|
204
|
+
* - "authorization"
|
|
205
|
+
* - "content-length"
|
|
206
|
+
* - "content-type"
|
|
207
|
+
* - "etag"
|
|
208
|
+
* - "expires"
|
|
209
|
+
* - "from"
|
|
210
|
+
* - "host"
|
|
211
|
+
* - "if-modified-since"
|
|
212
|
+
* - "if-unmodified-since"
|
|
213
|
+
* - "last-modified"
|
|
214
|
+
* - "location"
|
|
215
|
+
* - "max-forwards"
|
|
216
|
+
* - "proxy-authorization"
|
|
217
|
+
* - "referer"
|
|
218
|
+
* - "retry-after"
|
|
219
|
+
* - "server"
|
|
220
|
+
* - "user-agent"
|
|
221
|
+
*/
|
|
222
|
+
export type Headerify<T extends object | undefined> = {
|
|
223
|
+
[P in keyof T]?: T[P] extends HeaderValue | undefined
|
|
224
|
+
? P extends string
|
|
225
|
+
? Lowercase<P> extends "set-cookie"
|
|
226
|
+
? T[P] extends Array<HeaderValue>
|
|
227
|
+
? T[P] | undefined
|
|
228
|
+
: never
|
|
229
|
+
: Lowercase<P> extends
|
|
230
|
+
| "age"
|
|
231
|
+
| "authorization"
|
|
232
|
+
| "content-length"
|
|
233
|
+
| "content-type"
|
|
234
|
+
| "etag"
|
|
235
|
+
| "expires"
|
|
236
|
+
| "from"
|
|
237
|
+
| "host"
|
|
238
|
+
| "if-modified-since"
|
|
239
|
+
| "if-unmodified-since"
|
|
240
|
+
| "last-modified"
|
|
241
|
+
| "location"
|
|
242
|
+
| "max-forwards"
|
|
243
|
+
| "proxy-authorization"
|
|
244
|
+
| "referer"
|
|
245
|
+
| "retry-after"
|
|
246
|
+
| "server"
|
|
247
|
+
| "user-agent"
|
|
248
|
+
? T[P] extends Array<HeaderValue>
|
|
249
|
+
? never
|
|
250
|
+
: T[P] | undefined
|
|
251
|
+
: T[P] | undefined
|
|
252
|
+
: never
|
|
253
|
+
: never;
|
|
254
|
+
};
|
|
255
|
+
}
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { IConnection } from "./IConnection";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Encryption password.
|
|
5
|
-
*
|
|
6
|
-
* `IEncryptionPassword` is a type of interface who represents encryption password used by
|
|
7
|
-
* the {@link Fetcher} with AES-128/256 algorithm. If your encryption password is not fixed
|
|
8
|
-
* but changes according to the input content, you can utilize the
|
|
9
|
-
* {@link IEncryptionPassword.Closure} function type.
|
|
10
|
-
*
|
|
11
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
12
|
-
*/
|
|
13
|
-
export interface IEncryptionPassword {
|
|
14
|
-
/**
|
|
15
|
-
* Secret key.
|
|
16
|
-
*/
|
|
17
|
-
key: string;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Initialization Vector.
|
|
21
|
-
*/
|
|
22
|
-
iv: string;
|
|
23
|
-
}
|
|
24
|
-
export namespace IEncryptionPassword {
|
|
25
|
-
/**
|
|
26
|
-
* Type of a closure function returning the {@link IEncryptionPassword} object.
|
|
27
|
-
*
|
|
28
|
-
* `IEncryptionPassword.Closure` is a type of closure function who are returning the
|
|
29
|
-
* {@link IEncryptionPassword} object. It would be used when your encryption password
|
|
30
|
-
* be changed according to the input content.
|
|
31
|
-
*/
|
|
32
|
-
export interface Closure {
|
|
33
|
-
/**
|
|
34
|
-
* Encryption password getter.
|
|
35
|
-
*
|
|
36
|
-
* @param props Properties for predication
|
|
37
|
-
* @returns Encryption password
|
|
38
|
-
*/
|
|
39
|
-
(props: IProps): IEncryptionPassword;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Properties for the closure.
|
|
44
|
-
*/
|
|
45
|
-
export interface IProps {
|
|
46
|
-
headers: Record<string, IConnection.HeaderValue | undefined>;
|
|
47
|
-
body: string;
|
|
48
|
-
direction: "encode" | "decode";
|
|
49
|
-
}
|
|
50
|
-
}
|
|
1
|
+
import { IConnection } from "./IConnection";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Encryption password.
|
|
5
|
+
*
|
|
6
|
+
* `IEncryptionPassword` is a type of interface who represents encryption password used by
|
|
7
|
+
* the {@link Fetcher} with AES-128/256 algorithm. If your encryption password is not fixed
|
|
8
|
+
* but changes according to the input content, you can utilize the
|
|
9
|
+
* {@link IEncryptionPassword.Closure} function type.
|
|
10
|
+
*
|
|
11
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
12
|
+
*/
|
|
13
|
+
export interface IEncryptionPassword {
|
|
14
|
+
/**
|
|
15
|
+
* Secret key.
|
|
16
|
+
*/
|
|
17
|
+
key: string;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Initialization Vector.
|
|
21
|
+
*/
|
|
22
|
+
iv: string;
|
|
23
|
+
}
|
|
24
|
+
export namespace IEncryptionPassword {
|
|
25
|
+
/**
|
|
26
|
+
* Type of a closure function returning the {@link IEncryptionPassword} object.
|
|
27
|
+
*
|
|
28
|
+
* `IEncryptionPassword.Closure` is a type of closure function who are returning the
|
|
29
|
+
* {@link IEncryptionPassword} object. It would be used when your encryption password
|
|
30
|
+
* be changed according to the input content.
|
|
31
|
+
*/
|
|
32
|
+
export interface Closure {
|
|
33
|
+
/**
|
|
34
|
+
* Encryption password getter.
|
|
35
|
+
*
|
|
36
|
+
* @param props Properties for predication
|
|
37
|
+
* @returns Encryption password
|
|
38
|
+
*/
|
|
39
|
+
(props: IProps): IEncryptionPassword;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Properties for the closure.
|
|
44
|
+
*/
|
|
45
|
+
export interface IProps {
|
|
46
|
+
headers: Record<string, IConnection.HeaderValue | undefined>;
|
|
47
|
+
body: string;
|
|
48
|
+
direction: "encode" | "decode";
|
|
49
|
+
}
|
|
50
|
+
}
|
package/src/IFetchEvent.ts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
// import { IConnection } from "./IConnection";
|
|
2
|
-
import { IFetchRoute } from "./IFetchRoute";
|
|
3
|
-
|
|
4
|
-
export interface IFetchEvent {
|
|
5
|
-
route: IFetchRoute<"DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT">;
|
|
6
|
-
path: string;
|
|
7
|
-
status: number | null;
|
|
8
|
-
input: any;
|
|
9
|
-
output: any;
|
|
10
|
-
started_at: Date;
|
|
11
|
-
respond_at: Date | null;
|
|
12
|
-
completed_at: Date;
|
|
13
|
-
}
|
|
14
|
-
// export namespace IFetchEvent {
|
|
15
|
-
// export interface IFunction {
|
|
16
|
-
// (connection: IConnection, ...args: any[]): Promise<any>;
|
|
17
|
-
// METADATA: {
|
|
18
|
-
// method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS";
|
|
19
|
-
// path: string;
|
|
20
|
-
// request: null | {
|
|
21
|
-
// type: string;
|
|
22
|
-
// encrypted: boolean;
|
|
23
|
-
// };
|
|
24
|
-
// response: null | {
|
|
25
|
-
// type: string;
|
|
26
|
-
// encrypted: boolean;
|
|
27
|
-
// };
|
|
28
|
-
// };
|
|
29
|
-
// status: null | number;
|
|
30
|
-
// }
|
|
31
|
-
// }
|
|
1
|
+
// import { IConnection } from "./IConnection";
|
|
2
|
+
import { IFetchRoute } from "./IFetchRoute";
|
|
3
|
+
|
|
4
|
+
export interface IFetchEvent {
|
|
5
|
+
route: IFetchRoute<"DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT">;
|
|
6
|
+
path: string;
|
|
7
|
+
status: number | null;
|
|
8
|
+
input: any;
|
|
9
|
+
output: any;
|
|
10
|
+
started_at: Date;
|
|
11
|
+
respond_at: Date | null;
|
|
12
|
+
completed_at: Date;
|
|
13
|
+
}
|
|
14
|
+
// export namespace IFetchEvent {
|
|
15
|
+
// export interface IFunction {
|
|
16
|
+
// (connection: IConnection, ...args: any[]): Promise<any>;
|
|
17
|
+
// METADATA: {
|
|
18
|
+
// method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS";
|
|
19
|
+
// path: string;
|
|
20
|
+
// request: null | {
|
|
21
|
+
// type: string;
|
|
22
|
+
// encrypted: boolean;
|
|
23
|
+
// };
|
|
24
|
+
// response: null | {
|
|
25
|
+
// type: string;
|
|
26
|
+
// encrypted: boolean;
|
|
27
|
+
// };
|
|
28
|
+
// };
|
|
29
|
+
// status: null | number;
|
|
30
|
+
// }
|
|
31
|
+
// }
|