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