From 38686f4265b23310f4e9c4ab70cd55f6bcb02ea7 Mon Sep 17 00:00:00 2001 From: Alistair Smith Date: Fri, 16 May 2025 17:18:14 -0700 Subject: [PATCH] define consts earlier --- src/js/internal/tls.ts | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/js/internal/tls.ts b/src/js/internal/tls.ts index 264bf21ab5..08f375279c 100644 --- a/src/js/internal/tls.ts +++ b/src/js/internal/tls.ts @@ -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; + +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; - -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] {