define consts earlier

This commit is contained in:
Alistair Smith
2025-05-16 17:18:14 -07:00
parent 372b0c3141
commit 38686f4265

View File

@@ -12,6 +12,22 @@ const getDefaultMaxTLSVersionFromCLIFlag = $newZigFunction(
0,
) as () => number | null;
const TLS_VERSION_MAP = {
"TLSv1": 0x0301,
"TLSv1.1": 0x0302,
"TLSv1.2": 0x0303,
"TLSv1.3": 0x0304,
} as const satisfies Record<import("node:tls").SecureVersion, number>;
const TLS_VERSION_REVERSE_MAP: {
[Key in keyof typeof TLS_VERSION_MAP as (typeof TLS_VERSION_MAP)[Key]]: Key;
} = {
0x0301: "TLSv1",
0x0302: "TLSv1.1",
0x0303: "TLSv1.2",
0x0304: "TLSv1.3",
};
function isPemObject(obj: unknown): obj is { pem: unknown } {
return $isObject(obj) && "pem" in obj;
}
@@ -78,22 +94,6 @@ const DEFAULT_MAX_VERSION: import("node:tls").SecureVersion = getTlsVersionOrDef
"TLSv1.3",
);
const TLS_VERSION_MAP = {
"TLSv1": 0x0301,
"TLSv1.1": 0x0302,
"TLSv1.2": 0x0303,
"TLSv1.3": 0x0304,
} as const satisfies Record<import("node:tls").SecureVersion, number>;
const TLS_VERSION_REVERSE_MAP: {
[Key in keyof typeof TLS_VERSION_MAP as (typeof TLS_VERSION_MAP)[Key]]: Key;
} = {
0x0301: "TLSv1",
0x0302: "TLSv1.1",
0x0303: "TLSv1.2",
0x0304: "TLSv1.3",
};
// const forbiddenProtocols = ["SSLv23_method", "TLSv1_1_method", "TLSv1_method"];
function resolveTLSVersions(options: import("node:tls").TLSSocketOptions): [min: number, max: number] {