@typescriptprime/securereq 1.0.0 → 1.1.0
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 +57 -97
- package/dist/index.js +114 -1
- package/dist/index.js.map +2 -2
- package/dist/types/index.d.ts +14 -0
- package/dist/types/type.d.ts +1 -0
- package/package.json +1 -1
package/dist/types/index.d.ts
CHANGED
|
@@ -12,3 +12,17 @@ import type { HTTPSRequestOptions, HTTPSResponse, ExpectedAsMap, ExpectedAsKey }
|
|
|
12
12
|
* - TLS options are forwarded to the underlying Node.js HTTPS request (minVersion, maxVersion, ciphers, ecdhCurve).
|
|
13
13
|
*/
|
|
14
14
|
export declare function HTTPSRequest<E extends ExpectedAsKey = 'ArrayBuffer'>(Url: URL, Options?: HTTPSRequestOptions<E>): Promise<HTTPSResponse<ExpectedAsMap[E]>>;
|
|
15
|
+
/**
|
|
16
|
+
* Perform an HTTP request over TLS using Node's `http` and `tls` modules.
|
|
17
|
+
*
|
|
18
|
+
* @param {URL} Url - The target URL. Must be an instance of `URL`.
|
|
19
|
+
* @param {HTTPSRequestOptions<E>} [Options] - Request options including TLS settings, headers, and `ExpectedAs`. Defaults to secure TLS v1.3 and a default `User-Agent` header.
|
|
20
|
+
* @returns {Promise<HTTPSResponse<ExpectedAsMap[E]>>} Resolves with `{ StatusCode, Headers, Body }`, where `Body` is parsed according to `ExpectedAs`.
|
|
21
|
+
* @throws {TypeError} If `Url` is not an instance of `URL`.
|
|
22
|
+
* @throws {Error} When the request errors or if parsing the response body (e.g. JSON) fails.
|
|
23
|
+
*
|
|
24
|
+
* Notes:
|
|
25
|
+
* - Uses `node:http` with a custom TLS socket from `node:tls` (HTTP over TLS).
|
|
26
|
+
* - TLS options are forwarded to the underlying TLS connection (minVersion, maxVersion, ciphers, ecdhCurve).
|
|
27
|
+
*/
|
|
28
|
+
export declare function HTTPS2Request<E extends ExpectedAsKey = 'ArrayBuffer'>(Url: URL, Options?: HTTPSRequestOptions<E>): Promise<HTTPSResponse<ExpectedAsMap[E]>>;
|
package/dist/types/type.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ interface TLSOptions {
|
|
|
8
8
|
export interface HTTPSRequestOptions<E extends ExpectedAsKey = ExpectedAsKey> {
|
|
9
9
|
TLS?: TLSOptions;
|
|
10
10
|
HttpHeaders?: Record<string, string>;
|
|
11
|
+
HttpMethod?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
11
12
|
ExpectedAs?: E;
|
|
12
13
|
}
|
|
13
14
|
export interface HTTPSResponse<T extends unknown | string | ArrayBuffer> {
|
package/package.json
CHANGED