tunnelfetch 1.0.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.
Files changed (96) hide show
  1. package/LICENSE +28 -0
  2. package/README.md +617 -0
  3. package/README.zh-CN.md +470 -0
  4. package/package.json +74 -0
  5. package/src/client/cookies.js +429 -0
  6. package/src/client/decode.js +346 -0
  7. package/src/client/redirect.js +249 -0
  8. package/src/client.js +704 -0
  9. package/src/errors.js +181 -0
  10. package/src/http1/chunked.js +289 -0
  11. package/src/http1/index.js +10 -0
  12. package/src/http1/request.js +143 -0
  13. package/src/http1/response.js +493 -0
  14. package/src/http2/connection.js +1170 -0
  15. package/src/http2/constants.js +129 -0
  16. package/src/http2/frames.js +291 -0
  17. package/src/http2/hpack.js +420 -0
  18. package/src/http2/huffman.js +203 -0
  19. package/src/http2/index.js +21 -0
  20. package/src/index.js +46 -0
  21. package/src/pool.js +256 -0
  22. package/src/proxy/direct.js +62 -0
  23. package/src/proxy/http-connect.js +206 -0
  24. package/src/proxy/index.js +197 -0
  25. package/src/proxy/socks5.js +344 -0
  26. package/src/tls/aead.js +263 -0
  27. package/src/tls/connect.js +407 -0
  28. package/src/tls/constants.js +334 -0
  29. package/src/tls/extensions.js +376 -0
  30. package/src/tls/handshake-messages.js +901 -0
  31. package/src/tls/handshake.js +568 -0
  32. package/src/tls/handshake12.js +507 -0
  33. package/src/tls/index.js +44 -0
  34. package/src/tls/keyschedule.js +473 -0
  35. package/src/tls/record.js +872 -0
  36. package/src/tls/tickets.js +145 -0
  37. package/src/tls/transcript.js +101 -0
  38. package/src/tls/wire.js +224 -0
  39. package/src/transport.js +296 -0
  40. package/src/trust/der.js +551 -0
  41. package/src/trust/index.js +375 -0
  42. package/src/trust/name.js +235 -0
  43. package/src/trust/ocsp.js +759 -0
  44. package/src/trust/path.js +595 -0
  45. package/src/trust/roots.js +454 -0
  46. package/src/trust/x509.js +902 -0
  47. package/src/util/bytes.js +470 -0
  48. package/src/util/deadline.js +266 -0
  49. package/src/warmup-fixture.js +85 -0
  50. package/src/warmup.js +243 -0
  51. package/types/client/cookies.d.ts +159 -0
  52. package/types/client/decode.d.ts +54 -0
  53. package/types/client/redirect.d.ts +96 -0
  54. package/types/client.d.ts +323 -0
  55. package/types/errors.d.ts +141 -0
  56. package/types/http1/chunked.d.ts +48 -0
  57. package/types/http1/index.d.ts +3 -0
  58. package/types/http1/request.d.ts +44 -0
  59. package/types/http1/response.d.ts +183 -0
  60. package/types/http2/connection.d.ts +282 -0
  61. package/types/http2/constants.d.ts +95 -0
  62. package/types/http2/frames.d.ts +116 -0
  63. package/types/http2/hpack.d.ts +99 -0
  64. package/types/http2/huffman.d.ts +21 -0
  65. package/types/http2/index.d.ts +5 -0
  66. package/types/index.d.ts +17 -0
  67. package/types/pool.d.ts +135 -0
  68. package/types/proxy/direct.d.ts +26 -0
  69. package/types/proxy/http-connect.d.ts +37 -0
  70. package/types/proxy/index.d.ts +62 -0
  71. package/types/proxy/socks5.d.ts +47 -0
  72. package/types/tls/aead.d.ts +67 -0
  73. package/types/tls/connect.d.ts +280 -0
  74. package/types/tls/constants.d.ts +275 -0
  75. package/types/tls/extensions.d.ts +195 -0
  76. package/types/tls/handshake-messages.d.ts +430 -0
  77. package/types/tls/handshake.d.ts +90 -0
  78. package/types/tls/handshake12.d.ts +35 -0
  79. package/types/tls/index.d.ts +9 -0
  80. package/types/tls/keyschedule.d.ts +272 -0
  81. package/types/tls/record.d.ts +361 -0
  82. package/types/tls/tickets.d.ts +66 -0
  83. package/types/tls/transcript.d.ts +52 -0
  84. package/types/tls/wire.d.ts +106 -0
  85. package/types/transport.d.ts +222 -0
  86. package/types/trust/der.d.ts +239 -0
  87. package/types/trust/index.d.ts +194 -0
  88. package/types/trust/name.d.ts +33 -0
  89. package/types/trust/ocsp.d.ts +138 -0
  90. package/types/trust/path.d.ts +139 -0
  91. package/types/trust/roots.d.ts +36 -0
  92. package/types/trust/x509.d.ts +401 -0
  93. package/types/util/bytes.d.ts +183 -0
  94. package/types/util/deadline.d.ts +133 -0
  95. package/types/warmup-fixture.d.ts +11 -0
  96. package/types/warmup.d.ts +45 -0
@@ -0,0 +1,275 @@
1
+ export namespace RECORD_TYPE {
2
+ let change_cipher_spec: number;
3
+ let alert: number;
4
+ let handshake: number;
5
+ let application_data: number;
6
+ }
7
+ export namespace HANDSHAKE_TYPE {
8
+ let client_hello: number;
9
+ let server_hello: number;
10
+ let new_session_ticket: number;
11
+ let end_of_early_data: number;
12
+ let encrypted_extensions: number;
13
+ let certificate: number;
14
+ let server_key_exchange: number;
15
+ let certificate_request: number;
16
+ let server_hello_done: number;
17
+ let certificate_verify: number;
18
+ let client_key_exchange: number;
19
+ let finished: number;
20
+ let certificate_status: number;
21
+ let key_update: number;
22
+ let message_hash: number;
23
+ }
24
+ /** Legacy record-layer version. Always 0x0303 on the wire after ClientHello (RFC 8446 s5.1). */
25
+ export const LEGACY_VERSION: 771;
26
+ export const TLS12: 771;
27
+ export const TLS13: 772;
28
+ export const VERSION_NAME: {
29
+ 768: string;
30
+ 769: string;
31
+ 770: string;
32
+ 771: string;
33
+ 772: string;
34
+ };
35
+ export namespace EXTENSION {
36
+ let server_name: number;
37
+ let status_request: number;
38
+ let supported_groups: number;
39
+ let ec_point_formats: number;
40
+ let signature_algorithms: number;
41
+ let alpn: number;
42
+ let signed_certificate_timestamp: number;
43
+ let extended_master_secret: number;
44
+ let session_ticket: number;
45
+ let pre_shared_key: number;
46
+ let early_data: number;
47
+ let supported_versions: number;
48
+ let cookie: number;
49
+ let psk_key_exchange_modes: number;
50
+ let certificate_authorities: number;
51
+ let signature_algorithms_cert: number;
52
+ let key_share: number;
53
+ let renegotiation_info: number;
54
+ }
55
+ export namespace CIPHER {
56
+ let TLS_AES_128_GCM_SHA256: number;
57
+ let TLS_AES_256_GCM_SHA384: number;
58
+ let TLS_CHACHA20_POLY1305_SHA256: number;
59
+ let TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256: number;
60
+ let TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256: number;
61
+ let TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384: number;
62
+ let TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384: number;
63
+ }
64
+ /** Reverse map for error messages. A server that picks something unlisted still gets a hex code. */
65
+ export const CIPHER_NAME: {
66
+ [k: string]: string;
67
+ };
68
+ /** Offered in ClientHello, in preference order. */
69
+ export const TLS13_CIPHERS: number[];
70
+ export const TLS12_CIPHERS: number[];
71
+ /**
72
+ * Per-suite parameters. `hash` drives the whole key schedule; `keyLen` the AEAD key size.
73
+ * @typedef {object} CipherParams
74
+ * @property {'SHA-256' | 'SHA-384'} hash the only hashes any negotiable suite selects
75
+ * @property {number} hashLen
76
+ * @property {number} keyLen
77
+ * @property {number} ivLen
78
+ * @property {number} tagLen
79
+ * @property {number} [fixedIvLen] TLS 1.2 only: the 4-byte implicit GCM salt of RFC 5288
80
+ * @property {'ecdsa' | 'rsa'} [sig] TLS 1.2 only: the authentication family the suite names
81
+ */
82
+ /** @type {{ [suite: number]: CipherParams }} */
83
+ export const CIPHER_PARAMS: {
84
+ [suite: number]: CipherParams;
85
+ };
86
+ export namespace GROUP {
87
+ let secp256r1: number;
88
+ let secp384r1: number;
89
+ let secp521r1: number;
90
+ let x25519: number;
91
+ let x448: number;
92
+ let ffdhe2048: number;
93
+ }
94
+ export const GROUP_NAME: {
95
+ [k: string]: string;
96
+ };
97
+ /**
98
+ * Offered in preference order. X25519 first because it is the modern default and the runtime's
99
+ * WebCrypto has it; secp256r1 second because RFC 8446 s9.1 makes it mandatory to implement, so
100
+ * offering both means no compliant server can fail to find a match.
101
+ */
102
+ export const SUPPORTED_GROUPS: number[];
103
+ /**
104
+ * WebCrypto parameters per group, discriminated on `kind` because X25519 sizes its shared
105
+ * secret in bytes while ECDH sizes it in bits.
106
+ * @typedef {{ kind: 'x25519', algorithm: { name: string }, publicLen: number, secretLen: number }
107
+ * | { kind: 'ec', algorithm: { name: string, namedCurve: string }, publicLen: number,
108
+ * secretBits: number }} GroupParams
109
+ */
110
+ /**
111
+ * WebCrypto parameters per group. x448 and the finite-field groups are absent by design.
112
+ * @type {{ [group: number]: GroupParams }}
113
+ */
114
+ export const GROUP_PARAMS: {
115
+ [group: number]: GroupParams;
116
+ };
117
+ export namespace SIG_SCHEME {
118
+ let rsa_pkcs1_sha256: number;
119
+ let rsa_pkcs1_sha384: number;
120
+ let rsa_pkcs1_sha512: number;
121
+ let ecdsa_secp256r1_sha256: number;
122
+ let ecdsa_secp384r1_sha384: number;
123
+ let ecdsa_secp521r1_sha512: number;
124
+ let rsa_pss_rsae_sha256: number;
125
+ let rsa_pss_rsae_sha384: number;
126
+ let rsa_pss_rsae_sha512: number;
127
+ let ed25519: number;
128
+ let ed448: number;
129
+ let rsa_pss_pss_sha256: number;
130
+ let rsa_pss_pss_sha384: number;
131
+ let rsa_pss_pss_sha512: number;
132
+ let rsa_pkcs1_sha1: number;
133
+ let ecdsa_sha1: number;
134
+ }
135
+ export const SIG_SCHEME_NAME: {
136
+ [k: string]: string;
137
+ };
138
+ /**
139
+ * Offered in signature_algorithms. SHA-1 schemes are deliberately absent: they are forbidden in
140
+ * TLS 1.3 handshake signatures and are not worth accepting in 1.2 either.
141
+ */
142
+ export const SUPPORTED_SIG_SCHEMES: number[];
143
+ /**
144
+ * How to verify one signature scheme with WebCrypto. `format: 'ecdsa-der'` marks the schemes
145
+ * whose wire signatures need the DER-to-P1363 conversion before subtle.verify will take them.
146
+ * @typedef {object} SigSchemeParams
147
+ * @property {{ name: string, namedCurve?: string, hash?: string }} import importKey algorithm
148
+ * @property {{ name: string, hash?: string, saltLength?: number }} verify verify() algorithm
149
+ * @property {'ecdsa-der'} [format]
150
+ * @property {number} [curveOrderLen] byte width of the curve order, ECDSA only
151
+ */
152
+ /**
153
+ * How to verify each scheme with WebCrypto. Absent entries are rejected with a named error.
154
+ * @type {{ [scheme: number]: SigSchemeParams }}
155
+ */
156
+ export const SIG_SCHEME_PARAMS: {
157
+ [scheme: number]: SigSchemeParams;
158
+ };
159
+ export namespace ALERT_LEVEL {
160
+ let warning: number;
161
+ let fatal: number;
162
+ }
163
+ export const ALERT_DESC: {
164
+ 0: string;
165
+ 10: string;
166
+ 20: string;
167
+ 21: string;
168
+ 22: string;
169
+ 40: string;
170
+ 41: string;
171
+ 42: string;
172
+ 43: string;
173
+ 44: string;
174
+ 45: string;
175
+ 46: string;
176
+ 47: string;
177
+ 48: string;
178
+ 49: string;
179
+ 50: string;
180
+ 51: string;
181
+ 70: string;
182
+ 71: string;
183
+ 80: string;
184
+ 86: string;
185
+ 90: string;
186
+ 109: string;
187
+ 110: string;
188
+ 112: string;
189
+ 113: string;
190
+ 115: string;
191
+ 116: string;
192
+ 120: string;
193
+ };
194
+ /** RFC 8446 s5.1: plaintext fragments are at most 2^14 bytes; ciphertext adds at most 256. */
195
+ export const MAX_PLAINTEXT: number;
196
+ export const MAX_CIPHERTEXT: number;
197
+ /** The only protocol we will negotiate. Offering h2 we cannot speak would be a footgun. */
198
+ export const ALPN_HTTP11: "http/1.1";
199
+ /**
200
+ * RFC 8446 s4.1.3: a TLS 1.2 server that is really 1.3-aware signals a downgrade attempt by
201
+ * planting these in the last 8 bytes of ServerHello.random. A 1.3-capable client that lands on
202
+ * 1.2 must abort when it sees them.
203
+ */
204
+ export const DOWNGRADE_SENTINEL_12: Uint8Array<ArrayBuffer>;
205
+ export const DOWNGRADE_SENTINEL_11: Uint8Array<ArrayBuffer>;
206
+ /** RFC 8446 s4.1.3: HelloRetryRequest is a ServerHello whose random is this fixed value. */
207
+ export const HELLO_RETRY_REQUEST_RANDOM: Uint8Array<ArrayBuffer>;
208
+ /**
209
+ * Per-suite parameters. `hash` drives the whole key schedule; `keyLen` the AEAD key size.
210
+ */
211
+ export type CipherParams = {
212
+ /**
213
+ * the only hashes any negotiable suite selects
214
+ */
215
+ hash: "SHA-256" | "SHA-384";
216
+ hashLen: number;
217
+ keyLen: number;
218
+ ivLen: number;
219
+ tagLen: number;
220
+ /**
221
+ * TLS 1.2 only: the 4-byte implicit GCM salt of RFC 5288
222
+ */
223
+ fixedIvLen?: number | undefined;
224
+ /**
225
+ * TLS 1.2 only: the authentication family the suite names
226
+ */
227
+ sig?: "ecdsa" | "rsa" | undefined;
228
+ };
229
+ /**
230
+ * WebCrypto parameters per group, discriminated on `kind` because X25519 sizes its shared
231
+ * secret in bytes while ECDH sizes it in bits.
232
+ */
233
+ export type GroupParams = {
234
+ kind: "x25519";
235
+ algorithm: {
236
+ name: string;
237
+ };
238
+ publicLen: number;
239
+ secretLen: number;
240
+ } | {
241
+ kind: "ec";
242
+ algorithm: {
243
+ name: string;
244
+ namedCurve: string;
245
+ };
246
+ publicLen: number;
247
+ secretBits: number;
248
+ };
249
+ /**
250
+ * How to verify one signature scheme with WebCrypto. `format: 'ecdsa-der'` marks the schemes
251
+ * whose wire signatures need the DER-to-P1363 conversion before subtle.verify will take them.
252
+ */
253
+ export type SigSchemeParams = {
254
+ /**
255
+ * importKey algorithm
256
+ */
257
+ import: {
258
+ name: string;
259
+ namedCurve?: string;
260
+ hash?: string;
261
+ };
262
+ /**
263
+ * verify() algorithm
264
+ */
265
+ verify: {
266
+ name: string;
267
+ hash?: string;
268
+ saltLength?: number;
269
+ };
270
+ format?: "ecdsa-der" | undefined;
271
+ /**
272
+ * byte width of the curve order, ECDSA only
273
+ */
274
+ curveOrderLen?: number | undefined;
275
+ };
@@ -0,0 +1,195 @@
1
+ /**
2
+ * server_name (RFC 6066). Only host_name (type 0) exists in practice.
3
+ * An IP literal must NOT be sent as SNI — RFC 6066 s3 forbids it, and servers that do virtual
4
+ * hosting will hand back an unrelated certificate if we do, which would look like an attack.
5
+ * @param {string} hostname
6
+ * @returns {Uint8Array | null} null for an IP literal, which sends no SNI at all
7
+ */
8
+ export function encodeServerName(hostname: string): Uint8Array | null;
9
+ /**
10
+ * status_request (RFC 6066 s8): ask the server to staple an OCSP response for its certificate.
11
+ *
12
+ * The body is a CertificateStatusRequest: status_type ocsp(1), an empty responder_id_list (we
13
+ * accept whatever responder the CA authorised — a client cannot usefully narrow that), and empty
14
+ * request_extensions (no nonce: a stapled response is produced before our hello exists, so a
15
+ * nonce could never be honoured and freshness comes from thisUpdate/nextUpdate instead).
16
+ *
17
+ * Offered in every hello, for both versions: it costs 9 bytes, and a server that ignores it
18
+ * loses nothing. How the answer arrives differs by version — TLS 1.2 echoes the extension and
19
+ * sends a separate CertificateStatus message (RFC 6066 s8), TLS 1.3 attaches it to the leaf's
20
+ * CertificateEntry (RFC 8446 s4.4.2.1) — and each driver consumes its own form.
21
+ * @returns {Uint8Array}
22
+ */
23
+ export function encodeStatusRequest(): Uint8Array;
24
+ /**
25
+ * @param {number[]} versions in preference order
26
+ * @returns {Uint8Array}
27
+ */
28
+ export function encodeSupportedVersions(versions: number[]): Uint8Array;
29
+ /**
30
+ * @param {number[]} [groups]
31
+ * @returns {Uint8Array}
32
+ */
33
+ export function encodeSupportedGroups(groups?: number[]): Uint8Array;
34
+ /**
35
+ * @param {number[]} [schemes]
36
+ * @returns {Uint8Array}
37
+ */
38
+ export function encodeSignatureAlgorithms(schemes?: number[]): Uint8Array;
39
+ /**
40
+ * key_share entries, in the same order as supported_groups.
41
+ * @param {Array<{ group: number, keyExchange: Uint8Array }>} shares the public halves only;
42
+ * private keys never reach the encoder
43
+ * @returns {Uint8Array}
44
+ */
45
+ export function encodeKeyShare(shares: Array<{
46
+ group: number;
47
+ keyExchange: Uint8Array;
48
+ }>): Uint8Array;
49
+ /**
50
+ * The HelloRetryRequest response carries a bare group id with no share.
51
+ * @param {number} group
52
+ * @returns {Uint8Array}
53
+ */
54
+ export function encodeKeyShareHrr(group: number): Uint8Array;
55
+ /**
56
+ * @param {string[]} protocols
57
+ * @returns {Uint8Array}
58
+ */
59
+ export function encodeAlpn(protocols: string[]): Uint8Array;
60
+ /**
61
+ * psk_key_exchange_modes (RFC 8446 s4.2.9), mandatory in any ClientHello that offers (or might
62
+ * later offer) pre_shared_key, and sent in every 1.3 hello regardless because some middleboxes
63
+ * reject its absence and it costs 6 bytes.
64
+ *
65
+ * Only psk_dhe_ke(1) is offered, ever. psk_ke would let a resumed connection run with no fresh
66
+ * (EC)DHE at all, so compromise of one ticket's PSK would decrypt every session resumed from it
67
+ * — the forward-secrecy property the rest of this package refuses to trade away (no RSA key
68
+ * transport for the same reason). A server honouring psk_dhe_ke must still send key_share, and
69
+ * selectServerKeyShare fails closed if it does not.
70
+ */
71
+ export function encodePskKeyExchangeModes(): Uint8Array<ArrayBufferLike>;
72
+ /**
73
+ * pre_shared_key for a ClientHello (RFC 8446 s4.2.11): one PskIdentity (the ticket plus its
74
+ * obfuscated age) and one PskBinderEntry. The binder cannot be known while the hello is being
75
+ * encoded — it is an HMAC over a transcript of the very hello it sits in, truncated just before
76
+ * the binders list — so it is emitted here as `binderLen` ZERO bytes, at the exact length the
77
+ * real binder will have, and the builder patches the real value in afterwards. RFC 8446
78
+ * s4.2.11.2 requires exactly this shape: every length field is computed as if the true binder
79
+ * were present, and only then is the binder derived and substituted.
80
+ *
81
+ * Exactly one identity is offered by design. The wire format allows a list, but this client
82
+ * only ever holds resumption PSKs and offers the newest usable ticket; a multi-PSK offer would
83
+ * multiply binder computations for a case that cannot arise here.
84
+ *
85
+ * @param {object} psk
86
+ * @param {Uint8Array} psk.identity the ticket, opaque, 1..2^16-1 bytes
87
+ * @param {number} psk.obfuscatedTicketAge uint32, already obfuscated per s4.2.11.1
88
+ * @param {number} psk.binderLen digest length of the PSK's hash
89
+ * @returns {Uint8Array}
90
+ */
91
+ export function encodePreSharedKey({ identity, obfuscatedTicketAge, binderLen }: {
92
+ identity: Uint8Array;
93
+ obfuscatedTicketAge: number;
94
+ binderLen: number;
95
+ }): Uint8Array;
96
+ /**
97
+ * The number of trailing ClientHello bytes occupied by the binders list this client emits: the
98
+ * 2-byte list length, the 1-byte entry length, and the binder itself. This is the truncation
99
+ * arithmetic of RFC 8446 s4.2.11.2 — the binder transcript covers the hello up to and including
100
+ * the identities, i.e. everything except these bytes — kept next to the encoder above so the
101
+ * two cannot drift apart. pre_shared_key being the LAST extension (enforced by the builder) is
102
+ * what makes "trailing bytes of the message" and "the binders list" the same thing.
103
+ * @param {number} binderLen
104
+ * @returns {number}
105
+ */
106
+ export function pskBinderTrailerLength(binderLen: number): number;
107
+ /**
108
+ * pre_shared_key in a ServerHello is a bare uint16 selected_identity (RFC 8446 s4.2.11).
109
+ * @param {Uint8Array} data
110
+ * @returns {number}
111
+ */
112
+ export function decodeServerPreSharedKey(data: Uint8Array): number;
113
+ /** RFC 7627. Requesting extended master secret closes the triple-handshake hole in TLS 1.2. */
114
+ export function encodeExtendedMasterSecret(): Uint8Array<ArrayBufferLike>;
115
+ /**
116
+ * RFC 5746. An empty renegotiation_info says "I support secure renegotiation and have not
117
+ * renegotiated". We never renegotiate, but omitting this makes some TLS 1.2 servers reject us.
118
+ */
119
+ export function encodeRenegotiationInfo(): Uint8Array<ArrayBufferLike>;
120
+ /** RFC 8422 s5.1.2: uncompressed only. Compressed points are not implemented anywhere modern. */
121
+ export function encodeEcPointFormats(): Uint8Array<ArrayBufferLike>;
122
+ /**
123
+ * @param {Array<Uint8Array | null>} parts nulls tolerated so conditional extensions read cleanly
124
+ * @returns {Uint8Array}
125
+ */
126
+ export function encodeExtensionBlock(parts: Array<Uint8Array | null>): Uint8Array;
127
+ /**
128
+ * Decode an extension block into a Map. Duplicates are rejected rather than folded: a repeated
129
+ * extension is never legitimate and letting the last one win is how parser-differential bugs start.
130
+ * @param {Uint8Array} bytes the block content, its outer length prefix already consumed
131
+ * @param {string} where named in errors, e.g. 'ServerHello'
132
+ * @returns {Map<number, Uint8Array>}
133
+ */
134
+ export function decodeExtensionBlock(bytes: Uint8Array, where: string): Map<number, Uint8Array>;
135
+ /**
136
+ * RFC 8446 s4.2: the server may only send extensions the client offered. Anything else means we
137
+ * and the server disagree about the negotiation, which is not a state to continue from.
138
+ * @param {Map<number, Uint8Array>} received
139
+ * @param {Set<number>} offered extension types the ClientHello carried
140
+ * @param {string} where
141
+ * @returns {void} throws TlsError on the first unoffered extension
142
+ */
143
+ export function rejectUnofferedExtensions(received: Map<number, Uint8Array>, offered: Set<number>, where: string): void;
144
+ /**
145
+ * supported_versions in a ServerHello is a single uint16, not a list.
146
+ * @param {Uint8Array} data
147
+ * @returns {number}
148
+ */
149
+ export function decodeSelectedVersion(data: Uint8Array): number;
150
+ /**
151
+ * @param {Uint8Array} data
152
+ * @param {string} where
153
+ * @returns {{ group: number, keyExchange: Uint8Array }}
154
+ */
155
+ export function decodeKeyShareEntry(data: Uint8Array, where: string): {
156
+ group: number;
157
+ keyExchange: Uint8Array;
158
+ };
159
+ /**
160
+ * HelloRetryRequest's key_share is a bare group with no key.
161
+ * @param {Uint8Array} data
162
+ * @returns {number}
163
+ */
164
+ export function decodeKeyShareHrr(data: Uint8Array): number;
165
+ /**
166
+ * @param {Uint8Array} data
167
+ * @returns {string} the single protocol the server selected (RFC 7301 s3.2)
168
+ */
169
+ export function decodeAlpn(data: Uint8Array): string;
170
+ /**
171
+ * @param {number} group
172
+ * @param {string} where
173
+ * @returns {import('./constants.js').GroupParams} throws TlsUnsupportedError when unimplemented
174
+ */
175
+ export function requireSupportedGroup(group: number, where: string): import("./constants.js").GroupParams;
176
+ /**
177
+ * @param {number} scheme
178
+ * @returns {string}
179
+ */
180
+ export function describeSigScheme(scheme: number): string;
181
+ /**
182
+ * @param {number} version
183
+ * @returns {string}
184
+ */
185
+ export function describeVersion(version: number): string;
186
+ /**
187
+ * Cheap classification, not validation: decides whether a name is legal as SNI.
188
+ * @param {string} host
189
+ * @returns {boolean}
190
+ */
191
+ export function isIpLiteral(host: string): boolean;
192
+ import { GROUP } from './constants.js';
193
+ import { TLS12 } from './constants.js';
194
+ import { TLS13 } from './constants.js';
195
+ export { GROUP, TLS12, TLS13 };