@evobug_com/safe-ts-feature-node 0.2.0 → 0.3.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 +2 -2
- package/node-api.json +48 -85
- package/package.json +162 -3
- package/safe/buffer.d.ts +155 -0
- package/safe/buffer.js +582 -0
- package/safe/child_process.d.ts +32 -0
- package/safe/child_process.js +21 -0
- package/safe/core.d.ts +36 -0
- package/safe/core.js +25 -0
- package/safe/crypto.d.ts +105 -0
- package/safe/crypto.js +205 -0
- package/safe/dgram.d.ts +26 -0
- package/safe/dgram.js +76 -0
- package/safe/dns/promises.d.ts +136 -0
- package/safe/dns/promises.js +262 -0
- package/safe/errors.d.ts +155 -0
- package/safe/errors.js +32 -0
- package/safe/events.d.ts +11 -0
- package/safe/events.js +14 -0
- package/safe/ffi.d.ts +23 -0
- package/safe/ffi.js +57 -0
- package/safe/fs/promises.d.ts +168 -0
- package/safe/fs/promises.js +366 -0
- package/safe/fs.d.ts +201 -0
- package/safe/fs.js +422 -0
- package/safe/globals.d.ts +87 -0
- package/safe/globals.js +232 -0
- package/safe/http.d.ts +34 -0
- package/safe/http.js +85 -0
- package/safe/http2.d.ts +26 -0
- package/safe/http2.js +61 -0
- package/safe/https.d.ts +21 -0
- package/safe/https.js +29 -0
- package/safe/inspector/promises.d.ts +200 -0
- package/safe/inspector/promises.js +13 -0
- package/safe/inspector.d.ts +8 -0
- package/safe/inspector.js +13 -0
- package/safe/module.d.ts +21 -0
- package/safe/module.js +45 -0
- package/safe/net.d.ts +11 -0
- package/safe/net.js +17 -0
- package/safe/os.d.ts +20 -0
- package/safe/os.js +29 -0
- package/safe/perf_hooks.d.ts +11 -0
- package/safe/perf_hooks.js +12 -0
- package/safe/process.d.ts +31 -0
- package/safe/process.js +97 -0
- package/safe/punycode.d.ts +10 -0
- package/safe/punycode.js +21 -0
- package/safe/querystring.d.ts +11 -0
- package/safe/querystring.js +21 -0
- package/safe/readline/promises.d.ts +12 -0
- package/safe/readline/promises.js +13 -0
- package/safe/runtime.d.ts +10 -0
- package/safe/runtime.js +16 -0
- package/safe/sqlite.d.ts +54 -0
- package/safe/sqlite.js +118 -0
- package/safe/stream/consumers.d.ts +19 -0
- package/safe/stream/consumers.js +54 -0
- package/safe/stream/promises.d.ts +26 -0
- package/safe/stream/promises.js +22 -0
- package/safe/stream/web.d.ts +18 -0
- package/safe/stream/web.js +37 -0
- package/safe/stream.d.ts +29 -0
- package/safe/stream.js +62 -0
- package/safe/tls.d.ts +27 -0
- package/safe/tls.js +65 -0
- package/safe/url.d.ts +28 -0
- package/safe/url.js +57 -0
- package/safe/util.d.ts +13 -0
- package/safe/util.js +25 -0
- package/safe/v8.d.ts +28 -0
- package/safe/v8.js +85 -0
- package/safe/vm.d.ts +23 -0
- package/safe/vm.js +69 -0
- package/safe/wasi.d.ts +10 -0
- package/safe/wasi.js +20 -0
- package/safe/worker_threads.d.ts +31 -0
- package/safe/worker_threads.js +62 -0
- package/safe/zlib.d.ts +61 -0
- package/safe/zlib.js +214 -0
- package/safe-ts.json +1722 -490
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// Generated from node-api.json and @types/node by `npm run generate:safe` (packages/pack-kit/generate.ts): do not edit.
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import type { Option, Result } from "@evobug_com/safe-ts-std/result";
|
|
4
|
+
import type { DOMError, PlainError } from "./errors.js";
|
|
5
|
+
import type * as $buffer from "node:buffer";
|
|
6
|
+
import type * as $crypto from "node:crypto";
|
|
7
|
+
import type * as $url from "node:url";
|
|
8
|
+
import type * as $worker_threads from "node:worker_threads";
|
|
9
|
+
|
|
10
|
+
/** `Headers#append()`, with what it throws returned as an `Err`: `TypeError`. */
|
|
11
|
+
export declare function append(headers: Headers, name: string, value: string): Result<void, PlainError<"TypeError">>;
|
|
12
|
+
/** `Request#arrayBuffer()`, with what it rejects with returned as an `Err`: `TypeError`. */
|
|
13
|
+
export declare function arrayBuffer(request: Request): Promise<Result<ArrayBuffer, PlainError<"TypeError">>>;
|
|
14
|
+
/** `Response#arrayBuffer()`, with what it rejects with returned as an `Err`: `TypeError`. */
|
|
15
|
+
export declare function arrayBuffer(response: Response): Promise<Result<ArrayBuffer, PlainError<"TypeError">>>;
|
|
16
|
+
/** `Request#blob()`, with what it rejects with returned as an `Err`: `TypeError`. */
|
|
17
|
+
export declare function blob(request: Request): Promise<Result<$buffer.Blob, PlainError<"TypeError">>>;
|
|
18
|
+
/** `Response#blob()`, with what it rejects with returned as an `Err`: `TypeError`. */
|
|
19
|
+
export declare function blob(response: Response): Promise<Result<$buffer.Blob, PlainError<"TypeError">>>;
|
|
20
|
+
/** `Request#bytes()`, with what it rejects with returned as an `Err`: `TypeError`. */
|
|
21
|
+
export declare function bytes(request: Request): Promise<Result<Uint8Array, PlainError<"TypeError">>>;
|
|
22
|
+
/** `Response#bytes()`, with what it rejects with returned as an `Err`: `TypeError`. */
|
|
23
|
+
export declare function bytes(response: Response): Promise<Result<Uint8Array, PlainError<"TypeError">>>;
|
|
24
|
+
/** `Request#clone()`, with what it throws returned as an `Err`: `TypeError`. */
|
|
25
|
+
export declare function clone(request: Request): Result<Request, PlainError<"TypeError">>;
|
|
26
|
+
/** `Response#clone()`, with what it throws returned as an `Err`: `TypeError`. */
|
|
27
|
+
export declare function clone(response: Response): Result<Response, PlainError<"TypeError">>;
|
|
28
|
+
/** `SubtleCrypto#decapsulateBits()`, with what it rejects with returned as an `Err`: `DOMException [InvalidAccessError | OperationError] {cause?}`. */
|
|
29
|
+
export declare function decapsulateBits(subtleCrypto: SubtleCrypto, decapsulationAlgorithm: $crypto.webcrypto.AlgorithmIdentifier, decapsulationKey: $crypto.webcrypto.CryptoKey, ciphertext: NodeJS.BufferSource): Promise<Result<ArrayBuffer, DOMError<"InvalidAccessError" | "OperationError">>>;
|
|
30
|
+
/** `SubtleCrypto#decapsulateKey()`, with what it rejects with returned as an `Err`: `DOMException [InvalidAccessError | OperationError] {cause?}`. */
|
|
31
|
+
export declare function decapsulateKey(subtleCrypto: SubtleCrypto, decapsulationAlgorithm: $crypto.webcrypto.AlgorithmIdentifier, decapsulationKey: $crypto.webcrypto.CryptoKey, ciphertext: NodeJS.BufferSource, sharedKeyAlgorithm: $crypto.webcrypto.AlgorithmIdentifier | $crypto.webcrypto.HmacImportParams | $crypto.webcrypto.AesDerivedKeyParams | $crypto.webcrypto.KmacImportParams, extractable: boolean, keyUsages: $crypto.webcrypto.KeyUsage[]): Promise<Result<$crypto.webcrypto.CryptoKey, DOMError<"InvalidAccessError" | "OperationError">>>;
|
|
32
|
+
/** `SubtleCrypto#decrypt()`, with what it rejects with returned as an `Err`: `DOMException [OperationError] {cause?}`. */
|
|
33
|
+
export declare function decrypt(subtleCrypto: SubtleCrypto, algorithm: $crypto.webcrypto.AlgorithmIdentifier | $crypto.webcrypto.RsaOaepParams | $crypto.webcrypto.AesCtrParams | $crypto.webcrypto.AesCbcParams | $crypto.webcrypto.AeadParams, key: $crypto.webcrypto.CryptoKey, data: NodeJS.BufferSource): Promise<Result<ArrayBuffer, DOMError<"OperationError">>>;
|
|
34
|
+
/** `SubtleCrypto#deriveBits()`, with what it rejects with returned as an `Err`: `DOMException [InvalidAccessError | OperationError] {cause?}`. */
|
|
35
|
+
export declare function deriveBits(subtleCrypto: SubtleCrypto, algorithm: $crypto.webcrypto.AlgorithmIdentifier | $crypto.webcrypto.EcdhKeyDeriveParams | $crypto.webcrypto.HkdfParams | $crypto.webcrypto.Pbkdf2Params | $crypto.webcrypto.Argon2Params, baseKey: $crypto.webcrypto.CryptoKey, length?: number): Promise<Result<ArrayBuffer, DOMError<"InvalidAccessError" | "OperationError">>>;
|
|
36
|
+
/** `SubtleCrypto#deriveKey()`, with what it rejects with returned as an `Err`: `DOMException [InvalidAccessError | OperationError] {cause?}`. */
|
|
37
|
+
export declare function deriveKey(subtleCrypto: SubtleCrypto, algorithm: $crypto.webcrypto.AlgorithmIdentifier | $crypto.webcrypto.EcdhKeyDeriveParams | $crypto.webcrypto.HkdfParams | $crypto.webcrypto.Pbkdf2Params | $crypto.webcrypto.Argon2Params, baseKey: $crypto.webcrypto.CryptoKey, derivedKeyType: $crypto.webcrypto.AlgorithmIdentifier | $crypto.webcrypto.AesDerivedKeyParams | $crypto.webcrypto.HmacImportParams | $crypto.webcrypto.KmacImportParams, extractable: boolean, keyUsages: readonly $crypto.webcrypto.KeyUsage[]): Promise<Result<$crypto.webcrypto.CryptoKey, DOMError<"InvalidAccessError" | "OperationError">>>;
|
|
38
|
+
/** `SubtleCrypto#encapsulateBits()`, with what it rejects with returned as an `Err`: `DOMException [InvalidAccessError | OperationError] {cause?}`. */
|
|
39
|
+
export declare function encapsulateBits(subtleCrypto: SubtleCrypto, encapsulationAlgorithm: $crypto.webcrypto.AlgorithmIdentifier, encapsulationKey: $crypto.webcrypto.CryptoKey): Promise<Result<$crypto.webcrypto.EncapsulatedBits, DOMError<"InvalidAccessError" | "OperationError">>>;
|
|
40
|
+
/** `SubtleCrypto#encapsulateKey()`, with what it rejects with returned as an `Err`: `DOMException [InvalidAccessError | OperationError] {cause?}`. */
|
|
41
|
+
export declare function encapsulateKey(subtleCrypto: SubtleCrypto, encapsulationAlgorithm: $crypto.webcrypto.AlgorithmIdentifier, encapsulationKey: $crypto.webcrypto.CryptoKey, sharedKeyAlgorithm: $crypto.webcrypto.AlgorithmIdentifier | $crypto.webcrypto.AesDerivedKeyParams | $crypto.webcrypto.HmacImportParams | $crypto.webcrypto.KmacImportParams, extractable: boolean, keyUsages: $crypto.webcrypto.KeyUsage[]): Promise<Result<$crypto.webcrypto.EncapsulatedKey, DOMError<"InvalidAccessError" | "OperationError">>>;
|
|
42
|
+
/** `SubtleCrypto#encrypt()`, with what it rejects with returned as an `Err`: `DOMException [OperationError] {cause?}`. */
|
|
43
|
+
export declare function encrypt(subtleCrypto: SubtleCrypto, algorithm: $crypto.webcrypto.AlgorithmIdentifier | $crypto.webcrypto.RsaOaepParams | $crypto.webcrypto.AesCtrParams | $crypto.webcrypto.AesCbcParams | $crypto.webcrypto.AeadParams, key: $crypto.webcrypto.CryptoKey, data: NodeJS.BufferSource): Promise<Result<ArrayBuffer, DOMError<"OperationError">>>;
|
|
44
|
+
/** `fetch()`, with what it rejects with returned as an `Err`: `TypeError {cause} | DOMException [AbortError | TimeoutError] | (the signal's reason)`. */
|
|
45
|
+
export declare function fetch(input: string | URL | Request, init?: RequestInit): Promise<Result<Response, unknown>>;
|
|
46
|
+
/** `Request#formData()`, with what it rejects with returned as an `Err`: `TypeError`. */
|
|
47
|
+
export declare function formData(request: Request): Promise<Result<FormData, PlainError<"TypeError">>>;
|
|
48
|
+
/** `Response#formData()`, with what it rejects with returned as an `Err`: `TypeError`. */
|
|
49
|
+
export declare function formData(response: Response): Promise<Result<FormData, PlainError<"TypeError">>>;
|
|
50
|
+
/** `FormData#get()`, with `null` returned as `undefined`. */
|
|
51
|
+
export declare function get(formData: FormData, name: string): Option<(string | $buffer.File)>;
|
|
52
|
+
/** `Headers#get()`, with `null` returned as `undefined`. */
|
|
53
|
+
export declare function get(headers: Headers, name: string): Option<string>;
|
|
54
|
+
/** `Storage#getItem()`, with `null` returned as `undefined`. */
|
|
55
|
+
export declare function getItem(storage: Storage, key: string): Option<string>;
|
|
56
|
+
/** `SubtleCrypto#importKey()`, with what it rejects with returned as an `Err`: `DOMException [DataError | NotSupportedError]`. */
|
|
57
|
+
export declare function importKey(subtleCrypto: SubtleCrypto, format: "jwk", keyData: $crypto.webcrypto.JsonWebKey, algorithm: $crypto.webcrypto.AlgorithmIdentifier | $crypto.webcrypto.RsaHashedImportParams | $crypto.webcrypto.EcKeyImportParams | $crypto.webcrypto.HmacImportParams | $crypto.webcrypto.AesKeyAlgorithm | $crypto.webcrypto.KmacImportParams, extractable: boolean, keyUsages: $crypto.webcrypto.KeyUsage[]): Promise<Result<$crypto.webcrypto.CryptoKey, DOMError<"DataError" | "NotSupportedError">>>;
|
|
58
|
+
/** `SubtleCrypto#importKey()`, with what it rejects with returned as an `Err`: `DOMException [DataError | NotSupportedError]`. */
|
|
59
|
+
export declare function importKey(subtleCrypto: SubtleCrypto, format: Exclude<$crypto.webcrypto.KeyFormat, "jwk">, keyData: NodeJS.BufferSource, algorithm: $crypto.webcrypto.AlgorithmIdentifier | $crypto.webcrypto.RsaHashedImportParams | $crypto.webcrypto.EcKeyImportParams | $crypto.webcrypto.HmacImportParams | $crypto.webcrypto.AesKeyAlgorithm | $crypto.webcrypto.KmacImportParams, extractable: boolean, keyUsages: $crypto.webcrypto.KeyUsage[]): Promise<Result<$crypto.webcrypto.CryptoKey, DOMError<"DataError" | "NotSupportedError">>>;
|
|
60
|
+
/** `Request#json()`, with what it rejects with returned as an `Err`: `SyntaxError | TypeError`. */
|
|
61
|
+
export declare function json(request: Request): Promise<Result<unknown, PlainError<"SyntaxError"> | PlainError<"TypeError">>>;
|
|
62
|
+
/** `Response#json()`, with what it rejects with returned as an `Err`: `SyntaxError | TypeError`. */
|
|
63
|
+
export declare function json(response: Response): Promise<Result<unknown, PlainError<"SyntaxError"> | PlainError<"TypeError">>>;
|
|
64
|
+
/** `Storage#key()`, with `null` returned as `undefined`. */
|
|
65
|
+
export declare function key(storage: Storage, index: number): Option<string>;
|
|
66
|
+
/** `new Request()`, with what it throws returned as an `Err`: `TypeError {cause?}`. */
|
|
67
|
+
export declare function newRequest(input: (string | $url.URL | Request), init?: RequestInit): Result<Request, PlainError<"TypeError", { cause?: unknown }>>;
|
|
68
|
+
/** `new Response()`, with what it throws returned as an `Err`: `RangeError | TypeError`. */
|
|
69
|
+
export declare function newResponse(body?: (ArrayBuffer | AsyncIterable<Uint8Array> | $buffer.Blob | FormData | Iterable<Uint8Array> | NodeJS.ArrayBufferView | $url.URLSearchParams | null | string), init?: ResponseInit): Result<Response, PlainError<"RangeError"> | PlainError<"TypeError">>;
|
|
70
|
+
/** `Response.json()`, with what it throws returned as an `Err`: `TypeError | (what toJSON throws)`. */
|
|
71
|
+
export declare function responseJson(data: any, init?: ResponseInit): Result<Response, unknown>;
|
|
72
|
+
/** `Headers#set()`, with what it throws returned as an `Err`: `TypeError`. */
|
|
73
|
+
export declare function set(headers: Headers, name: string, value: string): Result<void, PlainError<"TypeError">>;
|
|
74
|
+
/** `Storage#setItem()`, with what it throws returned as an `Err`: `DOMException [QuotaExceededError]`. */
|
|
75
|
+
export declare function setItem(storage: Storage, key: string, value: string): Result<void, DOMError<"QuotaExceededError">>;
|
|
76
|
+
/** `structuredClone()`, with what it throws returned as an `Err`: `DOMException [DataCloneError]`. */
|
|
77
|
+
export declare function structuredClone<T = any>(value: T, options?: $worker_threads.StructuredSerializeOptions): Result<T, DOMError<"DataCloneError">>;
|
|
78
|
+
/** `Request#text()`, with what it rejects with returned as an `Err`: `TypeError`. */
|
|
79
|
+
export declare function text(request: Request): Promise<Result<string, PlainError<"TypeError">>>;
|
|
80
|
+
/** `Response#text()`, with what it rejects with returned as an `Err`: `TypeError`. */
|
|
81
|
+
export declare function text(response: Response): Promise<Result<string, PlainError<"TypeError">>>;
|
|
82
|
+
/** `AbortSignal#throwIfAborted()`, with what it throws returned as an `Err`: `DOMException [AbortError | TimeoutError] | (the signal's reason)`. */
|
|
83
|
+
export declare function throwIfAborted(abortSignal: AbortSignal): Result<void, unknown>;
|
|
84
|
+
/** `SubtleCrypto#unwrapKey()`, with what it rejects with returned as an `Err`: `DOMException [InvalidAccessError | OperationError | DataError] {cause?}`. */
|
|
85
|
+
export declare function unwrapKey(subtleCrypto: SubtleCrypto, format: $crypto.webcrypto.KeyFormat, wrappedKey: NodeJS.BufferSource, unwrappingKey: $crypto.webcrypto.CryptoKey, unwrapAlgorithm: $crypto.webcrypto.AlgorithmIdentifier | $crypto.webcrypto.RsaOaepParams | $crypto.webcrypto.AesCtrParams | $crypto.webcrypto.AesCbcParams | $crypto.webcrypto.AeadParams, unwrappedKeyAlgorithm: $crypto.webcrypto.AlgorithmIdentifier | $crypto.webcrypto.RsaHashedImportParams | $crypto.webcrypto.EcKeyImportParams | $crypto.webcrypto.HmacImportParams | $crypto.webcrypto.AesKeyAlgorithm | $crypto.webcrypto.KmacImportParams, extractable: boolean, keyUsages: $crypto.webcrypto.KeyUsage[]): Promise<Result<$crypto.webcrypto.CryptoKey, DOMError<"InvalidAccessError" | "OperationError" | "DataError">>>;
|
|
86
|
+
/** `SubtleCrypto#wrapKey()`, with what it rejects with returned as an `Err`: `DOMException [InvalidAccessError | OperationError] {cause?}`. */
|
|
87
|
+
export declare function wrapKey(subtleCrypto: SubtleCrypto, format: $crypto.webcrypto.KeyFormat, key: $crypto.webcrypto.CryptoKey, wrappingKey: $crypto.webcrypto.CryptoKey, wrapAlgorithm: $crypto.webcrypto.AlgorithmIdentifier | $crypto.webcrypto.RsaOaepParams | $crypto.webcrypto.AesCtrParams | $crypto.webcrypto.AesCbcParams | $crypto.webcrypto.AeadParams): Promise<Result<ArrayBuffer, DOMError<"InvalidAccessError" | "OperationError">>>;
|
package/safe/globals.js
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
// @safe-ts std
|
|
2
|
+
// Generated from node-api.json and @types/node by `npm run generate:safe` (packages/pack-kit/generate.ts): do not edit.
|
|
3
|
+
import { Err } from "@evobug_com/safe-ts-std/result";
|
|
4
|
+
import { failed, ok } from "./runtime.js";
|
|
5
|
+
|
|
6
|
+
export function append(self, ...args) {
|
|
7
|
+
try {
|
|
8
|
+
return self.append(...args);
|
|
9
|
+
} catch (error) {
|
|
10
|
+
return new Err(error);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function arrayBuffer(self, ...args) {
|
|
15
|
+
try {
|
|
16
|
+
return Promise.resolve(self.arrayBuffer(...args)).then(ok, failed);
|
|
17
|
+
} catch (error) {
|
|
18
|
+
return Promise.resolve(new Err(error));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function blob(self, ...args) {
|
|
23
|
+
try {
|
|
24
|
+
return Promise.resolve(self.blob(...args)).then(ok, failed);
|
|
25
|
+
} catch (error) {
|
|
26
|
+
return Promise.resolve(new Err(error));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function bytes(self, ...args) {
|
|
31
|
+
try {
|
|
32
|
+
return Promise.resolve(self.bytes(...args)).then(ok, failed);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
return Promise.resolve(new Err(error));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function clone(self, ...args) {
|
|
39
|
+
try {
|
|
40
|
+
return self.clone(...args);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
return new Err(error);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function decapsulateBits(self, ...args) {
|
|
47
|
+
try {
|
|
48
|
+
return Promise.resolve(self.decapsulateBits(...args)).then(ok, failed);
|
|
49
|
+
} catch (error) {
|
|
50
|
+
return Promise.resolve(new Err(error));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function decapsulateKey(self, ...args) {
|
|
55
|
+
try {
|
|
56
|
+
return Promise.resolve(self.decapsulateKey(...args)).then(ok, failed);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
return Promise.resolve(new Err(error));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function decrypt(self, ...args) {
|
|
63
|
+
try {
|
|
64
|
+
return Promise.resolve(self.decrypt(...args)).then(ok, failed);
|
|
65
|
+
} catch (error) {
|
|
66
|
+
return Promise.resolve(new Err(error));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function deriveBits(self, ...args) {
|
|
71
|
+
try {
|
|
72
|
+
return Promise.resolve(self.deriveBits(...args)).then(ok, failed);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
return Promise.resolve(new Err(error));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function deriveKey(self, ...args) {
|
|
79
|
+
try {
|
|
80
|
+
return Promise.resolve(self.deriveKey(...args)).then(ok, failed);
|
|
81
|
+
} catch (error) {
|
|
82
|
+
return Promise.resolve(new Err(error));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function encapsulateBits(self, ...args) {
|
|
87
|
+
try {
|
|
88
|
+
return Promise.resolve(self.encapsulateBits(...args)).then(ok, failed);
|
|
89
|
+
} catch (error) {
|
|
90
|
+
return Promise.resolve(new Err(error));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function encapsulateKey(self, ...args) {
|
|
95
|
+
try {
|
|
96
|
+
return Promise.resolve(self.encapsulateKey(...args)).then(ok, failed);
|
|
97
|
+
} catch (error) {
|
|
98
|
+
return Promise.resolve(new Err(error));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function encrypt(self, ...args) {
|
|
103
|
+
try {
|
|
104
|
+
return Promise.resolve(self.encrypt(...args)).then(ok, failed);
|
|
105
|
+
} catch (error) {
|
|
106
|
+
return Promise.resolve(new Err(error));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function fetch(...args) {
|
|
111
|
+
try {
|
|
112
|
+
return Promise.resolve(globalThis.fetch(...args)).then(ok, failed);
|
|
113
|
+
} catch (error) {
|
|
114
|
+
return Promise.resolve(new Err(error));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function formData(self, ...args) {
|
|
119
|
+
try {
|
|
120
|
+
return Promise.resolve(self.formData(...args)).then(ok, failed);
|
|
121
|
+
} catch (error) {
|
|
122
|
+
return Promise.resolve(new Err(error));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function get(self, ...args) {
|
|
127
|
+
return self.get(...args) ?? undefined;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function getItem(self, ...args) {
|
|
131
|
+
return self.getItem(...args) ?? undefined;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export function importKey(self, ...args) {
|
|
135
|
+
try {
|
|
136
|
+
return Promise.resolve(self.importKey(...args)).then(ok, failed);
|
|
137
|
+
} catch (error) {
|
|
138
|
+
return Promise.resolve(new Err(error));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function json(self, ...args) {
|
|
143
|
+
try {
|
|
144
|
+
return Promise.resolve(self.json(...args)).then(ok, failed);
|
|
145
|
+
} catch (error) {
|
|
146
|
+
return Promise.resolve(new Err(error));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export function key(self, ...args) {
|
|
151
|
+
return self.key(...args) ?? undefined;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export function newRequest(...args) {
|
|
155
|
+
try {
|
|
156
|
+
return new globalThis.Request(...args);
|
|
157
|
+
} catch (error) {
|
|
158
|
+
return new Err(error);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export function newResponse(...args) {
|
|
163
|
+
try {
|
|
164
|
+
return new globalThis.Response(...args);
|
|
165
|
+
} catch (error) {
|
|
166
|
+
return new Err(error);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export function responseJson(...args) {
|
|
171
|
+
try {
|
|
172
|
+
return globalThis.Response.json(...args);
|
|
173
|
+
} catch (error) {
|
|
174
|
+
return new Err(error);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export function set(self, ...args) {
|
|
179
|
+
try {
|
|
180
|
+
return self.set(...args);
|
|
181
|
+
} catch (error) {
|
|
182
|
+
return new Err(error);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export function setItem(self, ...args) {
|
|
187
|
+
try {
|
|
188
|
+
return self.setItem(...args);
|
|
189
|
+
} catch (error) {
|
|
190
|
+
return new Err(error);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export function structuredClone(...args) {
|
|
195
|
+
try {
|
|
196
|
+
return globalThis.structuredClone(...args);
|
|
197
|
+
} catch (error) {
|
|
198
|
+
return new Err(error);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export function text(self, ...args) {
|
|
203
|
+
try {
|
|
204
|
+
return Promise.resolve(self.text(...args)).then(ok, failed);
|
|
205
|
+
} catch (error) {
|
|
206
|
+
return Promise.resolve(new Err(error));
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export function throwIfAborted(self, ...args) {
|
|
211
|
+
try {
|
|
212
|
+
return self.throwIfAborted(...args);
|
|
213
|
+
} catch (error) {
|
|
214
|
+
return new Err(error);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export function unwrapKey(self, ...args) {
|
|
219
|
+
try {
|
|
220
|
+
return Promise.resolve(self.unwrapKey(...args)).then(ok, failed);
|
|
221
|
+
} catch (error) {
|
|
222
|
+
return Promise.resolve(new Err(error));
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export function wrapKey(self, ...args) {
|
|
227
|
+
try {
|
|
228
|
+
return Promise.resolve(self.wrapKey(...args)).then(ok, failed);
|
|
229
|
+
} catch (error) {
|
|
230
|
+
return Promise.resolve(new Err(error));
|
|
231
|
+
}
|
|
232
|
+
}
|
package/safe/http.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Generated from node-api.json and @types/node by `npm run generate:safe` (packages/pack-kit/generate.ts): do not edit.
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import type { Result } from "@evobug_com/safe-ts-std/result";
|
|
4
|
+
import type { DOMError, NodeError } from "./errors.js";
|
|
5
|
+
import type * as $http from "node:http";
|
|
6
|
+
import type * as $url from "node:url";
|
|
7
|
+
export * from "node:http";
|
|
8
|
+
|
|
9
|
+
/** `OutgoingMessage#addTrailers()` (node:http), with what it throws returned as an `Err`: `TypeError [ERR_INVALID_HTTP_TOKEN | ERR_INVALID_CHAR]`. */
|
|
10
|
+
export declare function addTrailers<Request extends $http.IncomingMessage = $http.IncomingMessage>(outgoingMessage: $http.OutgoingMessage<Request>, headers: $http.OutgoingHttpHeaders | ReadonlyArray<[string, string]>): Result<void, NodeError<"ERR_INVALID_HTTP_TOKEN" | "ERR_INVALID_CHAR", "TypeError">>;
|
|
11
|
+
/** `OutgoingMessage#appendHeader()` (node:http), with what it throws returned as an `Err`: `TypeError [ERR_INVALID_HTTP_TOKEN | ERR_HTTP_INVALID_HEADER_VALUE | ERR_INVALID_CHAR]`. */
|
|
12
|
+
export declare function appendHeader<Request extends $http.IncomingMessage = $http.IncomingMessage>(outgoingMessage: $http.OutgoingMessage<Request>, name: string, value: string | readonly string[]): Result<$http.OutgoingMessage<Request>, NodeError<"ERR_INVALID_HTTP_TOKEN" | "ERR_HTTP_INVALID_HEADER_VALUE" | "ERR_INVALID_CHAR", "TypeError">>;
|
|
13
|
+
/** `get()` (node:http), with what it throws returned as an `Err`: `TypeError [ERR_INVALID_URL] {input} | TypeError [ERR_UNESCAPED_CHARACTERS | ERR_INVALID_PROTOCOL]`. */
|
|
14
|
+
export declare function get(options: $http.RequestOptions | string | $url.URL, callback?: (res: $http.IncomingMessage) => void): Result<$http.ClientRequest, NodeError<"ERR_INVALID_URL", "TypeError", { input: string }> | NodeError<"ERR_UNESCAPED_CHARACTERS" | "ERR_INVALID_PROTOCOL", "TypeError">>;
|
|
15
|
+
/** `get()` (node:http), with what it throws returned as an `Err`: `TypeError [ERR_INVALID_URL] {input} | TypeError [ERR_UNESCAPED_CHARACTERS | ERR_INVALID_PROTOCOL]`. */
|
|
16
|
+
export declare function get(url: string | $url.URL, options: $http.RequestOptions, callback?: (res: $http.IncomingMessage) => void): Result<$http.ClientRequest, NodeError<"ERR_INVALID_URL", "TypeError", { input: string }> | NodeError<"ERR_UNESCAPED_CHARACTERS" | "ERR_INVALID_PROTOCOL", "TypeError">>;
|
|
17
|
+
/** `new WebSocket()` (node:http), with what it throws returned as an `Err`: `DOMException [SyntaxError]`. */
|
|
18
|
+
export declare function newWebSocket(url: string | URL, protocols?: string | string[] | WebSocketInit): Result<WebSocket, DOMError<"SyntaxError">>;
|
|
19
|
+
/** `request()` (node:http), with what it throws returned as an `Err`: `TypeError [ERR_INVALID_URL] {input} | TypeError [ERR_UNESCAPED_CHARACTERS | ERR_INVALID_PROTOCOL]`. */
|
|
20
|
+
export declare function request(options: $http.RequestOptions | string | $url.URL, callback?: (res: $http.IncomingMessage) => void): Result<$http.ClientRequest, NodeError<"ERR_INVALID_URL", "TypeError", { input: string }> | NodeError<"ERR_UNESCAPED_CHARACTERS" | "ERR_INVALID_PROTOCOL", "TypeError">>;
|
|
21
|
+
/** `request()` (node:http), with what it throws returned as an `Err`: `TypeError [ERR_INVALID_URL] {input} | TypeError [ERR_UNESCAPED_CHARACTERS | ERR_INVALID_PROTOCOL]`. */
|
|
22
|
+
export declare function request(url: string | $url.URL, options: $http.RequestOptions, callback?: (res: $http.IncomingMessage) => void): Result<$http.ClientRequest, NodeError<"ERR_INVALID_URL", "TypeError", { input: string }> | NodeError<"ERR_UNESCAPED_CHARACTERS" | "ERR_INVALID_PROTOCOL", "TypeError">>;
|
|
23
|
+
/** `OutgoingMessage#setHeader()` (node:http), with what it throws returned as an `Err`: `TypeError [ERR_INVALID_HTTP_TOKEN | ERR_HTTP_INVALID_HEADER_VALUE | ERR_INVALID_CHAR]`. */
|
|
24
|
+
export declare function setHeader<Request extends $http.IncomingMessage = $http.IncomingMessage>(outgoingMessage: $http.OutgoingMessage<Request>, name: string, value: number | string | readonly string[]): Result<$http.OutgoingMessage<Request>, NodeError<"ERR_INVALID_HTTP_TOKEN" | "ERR_HTTP_INVALID_HEADER_VALUE" | "ERR_INVALID_CHAR", "TypeError">>;
|
|
25
|
+
/** `OutgoingMessage#setHeaders()` (node:http), with what it throws returned as an `Err`: `TypeError [ERR_INVALID_HTTP_TOKEN | ERR_HTTP_INVALID_HEADER_VALUE | ERR_INVALID_CHAR]`. */
|
|
26
|
+
export declare function setHeaders<Request extends $http.IncomingMessage = $http.IncomingMessage>(outgoingMessage: $http.OutgoingMessage<Request>, headers: Headers | Map<string, number | string | readonly string[]>): Result<$http.OutgoingMessage<Request>, NodeError<"ERR_INVALID_HTTP_TOKEN" | "ERR_HTTP_INVALID_HEADER_VALUE" | "ERR_INVALID_CHAR", "TypeError">>;
|
|
27
|
+
/** `validateHeaderName()` (node:http), with what it throws returned as an `Err`: `TypeError [ERR_INVALID_HTTP_TOKEN]`. */
|
|
28
|
+
export declare function validateHeaderName(name: string): Result<void, NodeError<"ERR_INVALID_HTTP_TOKEN", "TypeError">>;
|
|
29
|
+
/** `validateHeaderValue()` (node:http), with what it throws returned as an `Err`: `TypeError [ERR_HTTP_INVALID_HEADER_VALUE | ERR_INVALID_CHAR]`. */
|
|
30
|
+
export declare function validateHeaderValue(name: string, value: string): Result<void, NodeError<"ERR_HTTP_INVALID_HEADER_VALUE" | "ERR_INVALID_CHAR", "TypeError">>;
|
|
31
|
+
/** `ServerResponse#writeHead()` (node:http), with what it throws returned as an `Err`: `RangeError [ERR_HTTP_INVALID_STATUS_CODE] | TypeError [ERR_INVALID_HTTP_TOKEN | ERR_HTTP_INVALID_HEADER_VALUE | ERR_INVALID_CHAR]`. */
|
|
32
|
+
export declare function writeHead<Request extends $http.IncomingMessage = $http.IncomingMessage>(serverResponse: $http.ServerResponse<Request>, statusCode: number, statusMessage?: string, headers?: $http.OutgoingHttpHeaders | $http.OutgoingHttpHeader[]): Result<$http.ServerResponse<Request>, NodeError<"ERR_HTTP_INVALID_STATUS_CODE", "RangeError"> | NodeError<"ERR_INVALID_HTTP_TOKEN" | "ERR_HTTP_INVALID_HEADER_VALUE" | "ERR_INVALID_CHAR", "TypeError">>;
|
|
33
|
+
/** `ServerResponse#writeHead()` (node:http), with what it throws returned as an `Err`: `RangeError [ERR_HTTP_INVALID_STATUS_CODE] | TypeError [ERR_INVALID_HTTP_TOKEN | ERR_HTTP_INVALID_HEADER_VALUE | ERR_INVALID_CHAR]`. */
|
|
34
|
+
export declare function writeHead<Request extends $http.IncomingMessage = $http.IncomingMessage>(serverResponse: $http.ServerResponse<Request>, statusCode: number, headers?: $http.OutgoingHttpHeaders | $http.OutgoingHttpHeader[]): Result<$http.ServerResponse<Request>, NodeError<"ERR_HTTP_INVALID_STATUS_CODE", "RangeError"> | NodeError<"ERR_INVALID_HTTP_TOKEN" | "ERR_HTTP_INVALID_HEADER_VALUE" | "ERR_INVALID_CHAR", "TypeError">>;
|
package/safe/http.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// @safe-ts std
|
|
2
|
+
// Generated from node-api.json and @types/node by `npm run generate:safe` (packages/pack-kit/generate.ts): do not edit.
|
|
3
|
+
import * as $module from "node:http";
|
|
4
|
+
import { Err } from "@evobug_com/safe-ts-std/result";
|
|
5
|
+
export * from "node:http";
|
|
6
|
+
|
|
7
|
+
export function addTrailers(self, ...args) {
|
|
8
|
+
try {
|
|
9
|
+
return self.addTrailers(...args);
|
|
10
|
+
} catch (error) {
|
|
11
|
+
return new Err(error);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function appendHeader(self, ...args) {
|
|
16
|
+
try {
|
|
17
|
+
return self.appendHeader(...args);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
return new Err(error);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function get(...args) {
|
|
24
|
+
try {
|
|
25
|
+
return $module.get(...args);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
return new Err(error);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function newWebSocket(...args) {
|
|
32
|
+
try {
|
|
33
|
+
return new $module.WebSocket(...args);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
return new Err(error);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function request(...args) {
|
|
40
|
+
try {
|
|
41
|
+
return $module.request(...args);
|
|
42
|
+
} catch (error) {
|
|
43
|
+
return new Err(error);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function setHeader(self, ...args) {
|
|
48
|
+
try {
|
|
49
|
+
return self.setHeader(...args);
|
|
50
|
+
} catch (error) {
|
|
51
|
+
return new Err(error);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function setHeaders(self, ...args) {
|
|
56
|
+
try {
|
|
57
|
+
return self.setHeaders(...args);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
return new Err(error);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function validateHeaderName(...args) {
|
|
64
|
+
try {
|
|
65
|
+
return $module.validateHeaderName(...args);
|
|
66
|
+
} catch (error) {
|
|
67
|
+
return new Err(error);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function validateHeaderValue(...args) {
|
|
72
|
+
try {
|
|
73
|
+
return $module.validateHeaderValue(...args);
|
|
74
|
+
} catch (error) {
|
|
75
|
+
return new Err(error);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function writeHead(self, ...args) {
|
|
80
|
+
try {
|
|
81
|
+
return self.writeHead(...args);
|
|
82
|
+
} catch (error) {
|
|
83
|
+
return new Err(error);
|
|
84
|
+
}
|
|
85
|
+
}
|
package/safe/http2.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Generated from node-api.json and @types/node by `npm run generate:safe` (packages/pack-kit/generate.ts): do not edit.
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import type { Result } from "@evobug_com/safe-ts-std/result";
|
|
4
|
+
import type { NodeError, OpenSSLError } from "./errors.js";
|
|
5
|
+
import type * as $http from "node:http";
|
|
6
|
+
import type * as $http2 from "node:http2";
|
|
7
|
+
export * from "node:http2";
|
|
8
|
+
|
|
9
|
+
/** `Http2ServerResponse#addTrailers()` (node:http2), with what it throws returned as an `Err`: `TypeError [ERR_INVALID_HTTP_TOKEN | ERR_HTTP2_INVALID_HEADER_VALUE | ERR_HTTP2_PSEUDOHEADER_NOT_ALLOWED]`. */
|
|
10
|
+
export declare function addTrailers<Request extends $http2.Http2ServerRequest = $http2.Http2ServerRequest>(http2ServerResponse: $http2.Http2ServerResponse<Request>, trailers: $http.OutgoingHttpHeaders): Result<void, NodeError<"ERR_INVALID_HTTP_TOKEN" | "ERR_HTTP2_INVALID_HEADER_VALUE" | "ERR_HTTP2_PSEUDOHEADER_NOT_ALLOWED", "TypeError">>;
|
|
11
|
+
/** `Http2ServerResponse#appendHeader()` (node:http2), with what it throws returned as an `Err`: `TypeError [ERR_INVALID_HTTP_TOKEN | ERR_HTTP2_INVALID_HEADER_VALUE | ERR_HTTP2_PSEUDOHEADER_NOT_ALLOWED]`. */
|
|
12
|
+
export declare function appendHeader<Request extends $http2.Http2ServerRequest = $http2.Http2ServerRequest>(http2ServerResponse: $http2.Http2ServerResponse<Request>, name: string, value: string | string[]): Result<void, NodeError<"ERR_INVALID_HTTP_TOKEN" | "ERR_HTTP2_INVALID_HEADER_VALUE" | "ERR_HTTP2_PSEUDOHEADER_NOT_ALLOWED", "TypeError">>;
|
|
13
|
+
/** `createSecureServer()` (node:http2), with what it throws returned as an `Err`: `Error [ERR_OSSL_*] {library, reason, opensslErrorStack?}`. */
|
|
14
|
+
export declare function createSecureServer(onRequestHandler?: (request: $http2.Http2ServerRequest, response: $http2.Http2ServerResponse) => void): Result<$http2.Http2SecureServer, OpenSSLError>;
|
|
15
|
+
/** `createSecureServer()` (node:http2), with what it throws returned as an `Err`: `Error [ERR_OSSL_*] {library, reason, opensslErrorStack?}`. */
|
|
16
|
+
export declare function createSecureServer<Http1Request extends typeof $http.IncomingMessage = typeof $http.IncomingMessage, Http1Response extends typeof $http.ServerResponse<InstanceType<Http1Request>> = typeof $http.ServerResponse, Http2Request extends typeof $http2.Http2ServerRequest = typeof $http2.Http2ServerRequest, Http2Response extends typeof $http2.Http2ServerResponse<InstanceType<Http2Request>> = typeof $http2.Http2ServerResponse>(options: $http2.SecureServerOptions<Http1Request, Http1Response, Http2Request, Http2Response>, onRequestHandler?: (request: InstanceType<Http2Request>, response: InstanceType<Http2Response>) => void): Result<$http2.Http2SecureServer<Http1Request, Http1Response, Http2Request, Http2Response>, OpenSSLError>;
|
|
17
|
+
/** `getUnpackedSettings()` (node:http2), with what it throws returned as an `Err`: `RangeError [ERR_HTTP2_INVALID_PACKED_SETTINGS_LENGTH]`. */
|
|
18
|
+
export declare function getUnpackedSettings(buf: Uint8Array): Result<$http2.Settings, NodeError<"ERR_HTTP2_INVALID_PACKED_SETTINGS_LENGTH", "RangeError">>;
|
|
19
|
+
/** `ClientHttp2Session#request()` (node:http2), with what it throws returned as an `Err`: `TypeError [ERR_INVALID_HTTP_TOKEN | ERR_HTTP2_INVALID_PSEUDOHEADER | ERR_HTTP2_HEADER_SINGLE_VALUE | ERR_HTTP2_INVALID_CONNECTION_HEADERS]`. */
|
|
20
|
+
export declare function request(clientHttp2Session: $http2.ClientHttp2Session, headers?: $http.OutgoingHttpHeaders | readonly string[], options?: $http2.ClientSessionRequestOptions): Result<$http2.ClientHttp2Stream, NodeError<"ERR_INVALID_HTTP_TOKEN" | "ERR_HTTP2_INVALID_PSEUDOHEADER" | "ERR_HTTP2_HEADER_SINGLE_VALUE" | "ERR_HTTP2_INVALID_CONNECTION_HEADERS", "TypeError">>;
|
|
21
|
+
/** `Http2ServerResponse#setHeader()` (node:http2), with what it throws returned as an `Err`: `TypeError [ERR_INVALID_HTTP_TOKEN | ERR_HTTP2_INVALID_HEADER_VALUE | ERR_HTTP2_PSEUDOHEADER_NOT_ALLOWED]`. */
|
|
22
|
+
export declare function setHeader<Request extends $http2.Http2ServerRequest = $http2.Http2ServerRequest>(http2ServerResponse: $http2.Http2ServerResponse<Request>, name: string, value: number | string | readonly string[]): Result<void, NodeError<"ERR_INVALID_HTTP_TOKEN" | "ERR_HTTP2_INVALID_HEADER_VALUE" | "ERR_HTTP2_PSEUDOHEADER_NOT_ALLOWED", "TypeError">>;
|
|
23
|
+
/** `Http2ServerResponse#writeHead()` (node:http2), with what it throws returned as an `Err`: `TypeError [ERR_INVALID_HTTP_TOKEN | ERR_HTTP2_INVALID_HEADER_VALUE | ERR_HTTP2_PSEUDOHEADER_NOT_ALLOWED] | RangeError [ERR_HTTP2_STATUS_INVALID]`. */
|
|
24
|
+
export declare function writeHead<Request extends $http2.Http2ServerRequest = $http2.Http2ServerRequest>(http2ServerResponse: $http2.Http2ServerResponse<Request>, statusCode: number, headers?: $http.OutgoingHttpHeaders | readonly string[]): Result<$http2.Http2ServerResponse<Request>, NodeError<"ERR_INVALID_HTTP_TOKEN" | "ERR_HTTP2_INVALID_HEADER_VALUE" | "ERR_HTTP2_PSEUDOHEADER_NOT_ALLOWED", "TypeError"> | NodeError<"ERR_HTTP2_STATUS_INVALID", "RangeError">>;
|
|
25
|
+
/** `Http2ServerResponse#writeHead()` (node:http2), with what it throws returned as an `Err`: `TypeError [ERR_INVALID_HTTP_TOKEN | ERR_HTTP2_INVALID_HEADER_VALUE | ERR_HTTP2_PSEUDOHEADER_NOT_ALLOWED] | RangeError [ERR_HTTP2_STATUS_INVALID]`. */
|
|
26
|
+
export declare function writeHead<Request extends $http2.Http2ServerRequest = $http2.Http2ServerRequest>(http2ServerResponse: $http2.Http2ServerResponse<Request>, statusCode: number, statusMessage: string, headers?: $http.OutgoingHttpHeaders | readonly string[]): Result<$http2.Http2ServerResponse<Request>, NodeError<"ERR_INVALID_HTTP_TOKEN" | "ERR_HTTP2_INVALID_HEADER_VALUE" | "ERR_HTTP2_PSEUDOHEADER_NOT_ALLOWED", "TypeError"> | NodeError<"ERR_HTTP2_STATUS_INVALID", "RangeError">>;
|
package/safe/http2.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// @safe-ts std
|
|
2
|
+
// Generated from node-api.json and @types/node by `npm run generate:safe` (packages/pack-kit/generate.ts): do not edit.
|
|
3
|
+
import * as $module from "node:http2";
|
|
4
|
+
import { Err } from "@evobug_com/safe-ts-std/result";
|
|
5
|
+
export * from "node:http2";
|
|
6
|
+
|
|
7
|
+
export function addTrailers(self, ...args) {
|
|
8
|
+
try {
|
|
9
|
+
return self.addTrailers(...args);
|
|
10
|
+
} catch (error) {
|
|
11
|
+
return new Err(error);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function appendHeader(self, ...args) {
|
|
16
|
+
try {
|
|
17
|
+
return self.appendHeader(...args);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
return new Err(error);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function createSecureServer(...args) {
|
|
24
|
+
try {
|
|
25
|
+
return $module.createSecureServer(...args);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
return new Err(error);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function getUnpackedSettings(...args) {
|
|
32
|
+
try {
|
|
33
|
+
return $module.getUnpackedSettings(...args);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
return new Err(error);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function request(self, ...args) {
|
|
40
|
+
try {
|
|
41
|
+
return self.request(...args);
|
|
42
|
+
} catch (error) {
|
|
43
|
+
return new Err(error);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function setHeader(self, ...args) {
|
|
48
|
+
try {
|
|
49
|
+
return self.setHeader(...args);
|
|
50
|
+
} catch (error) {
|
|
51
|
+
return new Err(error);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function writeHead(self, ...args) {
|
|
56
|
+
try {
|
|
57
|
+
return self.writeHead(...args);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
return new Err(error);
|
|
60
|
+
}
|
|
61
|
+
}
|
package/safe/https.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Generated from node-api.json and @types/node by `npm run generate:safe` (packages/pack-kit/generate.ts): do not edit.
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import type { Result } from "@evobug_com/safe-ts-std/result";
|
|
4
|
+
import type { NodeError, OpenSSLError } from "./errors.js";
|
|
5
|
+
import type * as $http from "node:http";
|
|
6
|
+
import type * as $https from "node:https";
|
|
7
|
+
import type * as $url from "node:url";
|
|
8
|
+
export * from "node:https";
|
|
9
|
+
|
|
10
|
+
/** `createServer()` (node:https), with what it throws returned as an `Err`: `Error [ERR_OSSL_*] {library, reason, opensslErrorStack?}`. */
|
|
11
|
+
export declare function createServer<Request extends typeof $http.IncomingMessage = typeof $http.IncomingMessage, Response extends typeof $http.ServerResponse<InstanceType<Request>> = typeof $http.ServerResponse>(requestListener?: $http.RequestListener<Request, Response>): Result<$https.Server<Request, Response>, OpenSSLError>;
|
|
12
|
+
/** `createServer()` (node:https), with what it throws returned as an `Err`: `Error [ERR_OSSL_*] {library, reason, opensslErrorStack?}`. */
|
|
13
|
+
export declare function createServer<Request extends typeof $http.IncomingMessage = typeof $http.IncomingMessage, Response extends typeof $http.ServerResponse<InstanceType<Request>> = typeof $http.ServerResponse>(options: $https.ServerOptions<Request, Response>, requestListener?: $http.RequestListener<Request, Response>): Result<$https.Server<Request, Response>, OpenSSLError>;
|
|
14
|
+
/** `get()` (node:https), with what it throws returned as an `Err`: `TypeError [ERR_INVALID_URL] {input} | TypeError [ERR_UNESCAPED_CHARACTERS | ERR_INVALID_PROTOCOL]`. */
|
|
15
|
+
export declare function get(options: $https.RequestOptions | string | $url.URL, callback?: (res: $http.IncomingMessage) => void): Result<$http.ClientRequest, NodeError<"ERR_INVALID_URL", "TypeError", { input: string }> | NodeError<"ERR_UNESCAPED_CHARACTERS" | "ERR_INVALID_PROTOCOL", "TypeError">>;
|
|
16
|
+
/** `get()` (node:https), with what it throws returned as an `Err`: `TypeError [ERR_INVALID_URL] {input} | TypeError [ERR_UNESCAPED_CHARACTERS | ERR_INVALID_PROTOCOL]`. */
|
|
17
|
+
export declare function get(url: string | $url.URL, options: $https.RequestOptions, callback?: (res: $http.IncomingMessage) => void): Result<$http.ClientRequest, NodeError<"ERR_INVALID_URL", "TypeError", { input: string }> | NodeError<"ERR_UNESCAPED_CHARACTERS" | "ERR_INVALID_PROTOCOL", "TypeError">>;
|
|
18
|
+
/** `request()` (node:https), with what it throws returned as an `Err`: `TypeError [ERR_INVALID_URL] {input} | TypeError [ERR_UNESCAPED_CHARACTERS | ERR_INVALID_PROTOCOL]`. */
|
|
19
|
+
export declare function request(options: $https.RequestOptions | string | $url.URL, callback?: (res: $http.IncomingMessage) => void): Result<$http.ClientRequest, NodeError<"ERR_INVALID_URL", "TypeError", { input: string }> | NodeError<"ERR_UNESCAPED_CHARACTERS" | "ERR_INVALID_PROTOCOL", "TypeError">>;
|
|
20
|
+
/** `request()` (node:https), with what it throws returned as an `Err`: `TypeError [ERR_INVALID_URL] {input} | TypeError [ERR_UNESCAPED_CHARACTERS | ERR_INVALID_PROTOCOL]`. */
|
|
21
|
+
export declare function request(url: string | $url.URL, options: $https.RequestOptions, callback?: (res: $http.IncomingMessage) => void): Result<$http.ClientRequest, NodeError<"ERR_INVALID_URL", "TypeError", { input: string }> | NodeError<"ERR_UNESCAPED_CHARACTERS" | "ERR_INVALID_PROTOCOL", "TypeError">>;
|
package/safe/https.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// @safe-ts std
|
|
2
|
+
// Generated from node-api.json and @types/node by `npm run generate:safe` (packages/pack-kit/generate.ts): do not edit.
|
|
3
|
+
import * as $module from "node:https";
|
|
4
|
+
import { Err } from "@evobug_com/safe-ts-std/result";
|
|
5
|
+
export * from "node:https";
|
|
6
|
+
|
|
7
|
+
export function createServer(...args) {
|
|
8
|
+
try {
|
|
9
|
+
return $module.createServer(...args);
|
|
10
|
+
} catch (error) {
|
|
11
|
+
return new Err(error);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function get(...args) {
|
|
16
|
+
try {
|
|
17
|
+
return $module.get(...args);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
return new Err(error);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function request(...args) {
|
|
24
|
+
try {
|
|
25
|
+
return $module.request(...args);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
return new Err(error);
|
|
28
|
+
}
|
|
29
|
+
}
|