e2d6fb03ea149f804ef3568c5f7186de4cefbfe4ddd3a3f80b31c8cc17e25b8147c87fd154424eae916dd6d1f2d1b503994d01fd73d7f570bf7ea957417e41 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. /**
  2. * HTTPS is the HTTP protocol over TLS/SSL. In Node.js this is implemented as a
  3. * separate module.
  4. * @see [source](https://github.com/nodejs/node/blob/v22.x/lib/https.js)
  5. */
  6. declare module "https" {
  7. import { Duplex } from "node:stream";
  8. import * as tls from "node:tls";
  9. import * as http from "node:http";
  10. import { URL } from "node:url";
  11. type ServerOptions<
  12. Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
  13. Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse,
  14. > = tls.SecureContextOptions & tls.TlsOptions & http.ServerOptions<Request, Response>;
  15. type RequestOptions =
  16. & http.RequestOptions
  17. & tls.SecureContextOptions
  18. & {
  19. checkServerIdentity?:
  20. | ((hostname: string, cert: tls.DetailedPeerCertificate) => Error | undefined)
  21. | undefined;
  22. rejectUnauthorized?: boolean | undefined; // Defaults to true
  23. servername?: string | undefined; // SNI TLS Extension
  24. };
  25. interface AgentOptions extends http.AgentOptions, tls.ConnectionOptions {
  26. maxCachedSessions?: number | undefined;
  27. }
  28. /**
  29. * An `Agent` object for HTTPS similar to `http.Agent`. See {@link request} for more information.
  30. * @since v0.4.5
  31. */
  32. class Agent extends http.Agent {
  33. constructor(options?: AgentOptions);
  34. options: AgentOptions;
  35. }
  36. interface Server<
  37. Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
  38. Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse,
  39. > extends http.Server<Request, Response> {}
  40. /**
  41. * See `http.Server` for more information.
  42. * @since v0.3.4
  43. */
  44. class Server<
  45. Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
  46. Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse,
  47. > extends tls.Server {
  48. constructor(requestListener?: http.RequestListener<Request, Response>);
  49. constructor(
  50. options: ServerOptions<Request, Response>,
  51. requestListener?: http.RequestListener<Request, Response>,
  52. );
  53. /**
  54. * Closes all connections connected to this server.
  55. * @since v18.2.0
  56. */
  57. closeAllConnections(): void;
  58. /**
  59. * Closes all connections connected to this server which are not sending a request or waiting for a response.
  60. * @since v18.2.0
  61. */
  62. closeIdleConnections(): void;
  63. addListener(event: string, listener: (...args: any[]) => void): this;
  64. addListener(event: "keylog", listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
  65. addListener(
  66. event: "newSession",
  67. listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void,
  68. ): this;
  69. addListener(
  70. event: "OCSPRequest",
  71. listener: (
  72. certificate: Buffer,
  73. issuer: Buffer,
  74. callback: (err: Error | null, resp: Buffer) => void,
  75. ) => void,
  76. ): this;
  77. addListener(
  78. event: "resumeSession",
  79. listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void,
  80. ): this;
  81. addListener(event: "secureConnection", listener: (tlsSocket: tls.TLSSocket) => void): this;
  82. addListener(event: "tlsClientError", listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
  83. addListener(event: "close", listener: () => void): this;
  84. addListener(event: "connection", listener: (socket: Duplex) => void): this;
  85. addListener(event: "error", listener: (err: Error) => void): this;
  86. addListener(event: "listening", listener: () => void): this;
  87. addListener(event: "checkContinue", listener: http.RequestListener<Request, Response>): this;
  88. addListener(event: "checkExpectation", listener: http.RequestListener<Request, Response>): this;
  89. addListener(event: "clientError", listener: (err: Error, socket: Duplex) => void): this;
  90. addListener(
  91. event: "connect",
  92. listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
  93. ): this;
  94. addListener(event: "request", listener: http.RequestListener<Request, Response>): this;
  95. addListener(
  96. event: "upgrade",
  97. listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
  98. ): this;
  99. emit(event: string, ...args: any[]): boolean;
  100. emit(event: "keylog", line: Buffer, tlsSocket: tls.TLSSocket): boolean;
  101. emit(
  102. event: "newSession",
  103. sessionId: Buffer,
  104. sessionData: Buffer,
  105. callback: (err: Error, resp: Buffer) => void,
  106. ): boolean;
  107. emit(
  108. event: "OCSPRequest",
  109. certificate: Buffer,
  110. issuer: Buffer,
  111. callback: (err: Error | null, resp: Buffer) => void,
  112. ): boolean;
  113. emit(event: "resumeSession", sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void): boolean;
  114. emit(event: "secureConnection", tlsSocket: tls.TLSSocket): boolean;
  115. emit(event: "tlsClientError", err: Error, tlsSocket: tls.TLSSocket): boolean;
  116. emit(event: "close"): boolean;
  117. emit(event: "connection", socket: Duplex): boolean;
  118. emit(event: "error", err: Error): boolean;
  119. emit(event: "listening"): boolean;
  120. emit(
  121. event: "checkContinue",
  122. req: InstanceType<Request>,
  123. res: InstanceType<Response>,
  124. ): boolean;
  125. emit(
  126. event: "checkExpectation",
  127. req: InstanceType<Request>,
  128. res: InstanceType<Response>,
  129. ): boolean;
  130. emit(event: "clientError", err: Error, socket: Duplex): boolean;
  131. emit(event: "connect", req: InstanceType<Request>, socket: Duplex, head: Buffer): boolean;
  132. emit(
  133. event: "request",
  134. req: InstanceType<Request>,
  135. res: InstanceType<Response>,
  136. ): boolean;
  137. emit(event: "upgrade", req: InstanceType<Request>, socket: Duplex, head: Buffer): boolean;
  138. on(event: string, listener: (...args: any[]) => void): this;
  139. on(event: "keylog", listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
  140. on(
  141. event: "newSession",
  142. listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void,
  143. ): this;
  144. on(
  145. event: "OCSPRequest",
  146. listener: (
  147. certificate: Buffer,
  148. issuer: Buffer,
  149. callback: (err: Error | null, resp: Buffer) => void,
  150. ) => void,
  151. ): this;
  152. on(
  153. event: "resumeSession",
  154. listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void,
  155. ): this;
  156. on(event: "secureConnection", listener: (tlsSocket: tls.TLSSocket) => void): this;
  157. on(event: "tlsClientError", listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
  158. on(event: "close", listener: () => void): this;
  159. on(event: "connection", listener: (socket: Duplex) => void): this;
  160. on(event: "error", listener: (err: Error) => void): this;
  161. on(event: "listening", listener: () => void): this;
  162. on(event: "checkContinue", listener: http.RequestListener<Request, Response>): this;
  163. on(event: "checkExpectation", listener: http.RequestListener<Request, Response>): this;
  164. on(event: "clientError", listener: (err: Error, socket: Duplex) => void): this;
  165. on(event: "connect", listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void): this;
  166. on(event: "request", listener: http.RequestListener<Request, Response>): this;
  167. on(event: "upgrade", listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void): this;
  168. once(event: string, listener: (...args: any[]) => void): this;
  169. once(event: "keylog", listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
  170. once(
  171. event: "newSession",
  172. listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void,
  173. ): this;
  174. once(
  175. event: "OCSPRequest",
  176. listener: (
  177. certificate: Buffer,
  178. issuer: Buffer,
  179. callback: (err: Error | null, resp: Buffer) => void,
  180. ) => void,
  181. ): this;
  182. once(
  183. event: "resumeSession",
  184. listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void,
  185. ): this;
  186. once(event: "secureConnection", listener: (tlsSocket: tls.TLSSocket) => void): this;
  187. once(event: "tlsClientError", listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
  188. once(event: "close", listener: () => void): this;
  189. once(event: "connection", listener: (socket: Duplex) => void): this;
  190. once(event: "error", listener: (err: Error) => void): this;
  191. once(event: "listening", listener: () => void): this;
  192. once(event: "checkContinue", listener: http.RequestListener<Request, Response>): this;
  193. once(event: "checkExpectation", listener: http.RequestListener<Request, Response>): this;
  194. once(event: "clientError", listener: (err: Error, socket: Duplex) => void): this;
  195. once(event: "connect", listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void): this;
  196. once(event: "request", listener: http.RequestListener<Request, Response>): this;
  197. once(event: "upgrade", listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void): this;
  198. prependListener(event: string, listener: (...args: any[]) => void): this;
  199. prependListener(event: "keylog", listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
  200. prependListener(
  201. event: "newSession",
  202. listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void,
  203. ): this;
  204. prependListener(
  205. event: "OCSPRequest",
  206. listener: (
  207. certificate: Buffer,
  208. issuer: Buffer,
  209. callback: (err: Error | null, resp: Buffer) => void,
  210. ) => void,
  211. ): this;
  212. prependListener(
  213. event: "resumeSession",
  214. listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void,
  215. ): this;
  216. prependListener(event: "secureConnection", listener: (tlsSocket: tls.TLSSocket) => void): this;
  217. prependListener(event: "tlsClientError", listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
  218. prependListener(event: "close", listener: () => void): this;
  219. prependListener(event: "connection", listener: (socket: Duplex) => void): this;
  220. prependListener(event: "error", listener: (err: Error) => void): this;
  221. prependListener(event: "listening", listener: () => void): this;
  222. prependListener(event: "checkContinue", listener: http.RequestListener<Request, Response>): this;
  223. prependListener(event: "checkExpectation", listener: http.RequestListener<Request, Response>): this;
  224. prependListener(event: "clientError", listener: (err: Error, socket: Duplex) => void): this;
  225. prependListener(
  226. event: "connect",
  227. listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
  228. ): this;
  229. prependListener(event: "request", listener: http.RequestListener<Request, Response>): this;
  230. prependListener(
  231. event: "upgrade",
  232. listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
  233. ): this;
  234. prependOnceListener(event: string, listener: (...args: any[]) => void): this;
  235. prependOnceListener(event: "keylog", listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
  236. prependOnceListener(
  237. event: "newSession",
  238. listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void,
  239. ): this;
  240. prependOnceListener(
  241. event: "OCSPRequest",
  242. listener: (
  243. certificate: Buffer,
  244. issuer: Buffer,
  245. callback: (err: Error | null, resp: Buffer) => void,
  246. ) => void,
  247. ): this;
  248. prependOnceListener(
  249. event: "resumeSession",
  250. listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void,
  251. ): this;
  252. prependOnceListener(event: "secureConnection", listener: (tlsSocket: tls.TLSSocket) => void): this;
  253. prependOnceListener(event: "tlsClientError", listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
  254. prependOnceListener(event: "close", listener: () => void): this;
  255. prependOnceListener(event: "connection", listener: (socket: Duplex) => void): this;
  256. prependOnceListener(event: "error", listener: (err: Error) => void): this;
  257. prependOnceListener(event: "listening", listener: () => void): this;
  258. prependOnceListener(event: "checkContinue", listener: http.RequestListener<Request, Response>): this;
  259. prependOnceListener(event: "checkExpectation", listener: http.RequestListener<Request, Response>): this;
  260. prependOnceListener(event: "clientError", listener: (err: Error, socket: Duplex) => void): this;
  261. prependOnceListener(
  262. event: "connect",
  263. listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
  264. ): this;
  265. prependOnceListener(event: "request", listener: http.RequestListener<Request, Response>): this;
  266. prependOnceListener(
  267. event: "upgrade",
  268. listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
  269. ): this;
  270. }
  271. /**
  272. * ```js
  273. * // curl -k https://localhost:8000/
  274. * import https from 'node:https';
  275. * import fs from 'node:fs';
  276. *
  277. * const options = {
  278. * key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
  279. * cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'),
  280. * };
  281. *
  282. * https.createServer(options, (req, res) => {
  283. * res.writeHead(200);
  284. * res.end('hello world\n');
  285. * }).listen(8000);
  286. * ```
  287. *
  288. * Or
  289. *
  290. * ```js
  291. * import https from 'node:https';
  292. * import fs from 'node:fs';
  293. *
  294. * const options = {
  295. * pfx: fs.readFileSync('test/fixtures/test_cert.pfx'),
  296. * passphrase: 'sample',
  297. * };
  298. *
  299. * https.createServer(options, (req, res) => {
  300. * res.writeHead(200);
  301. * res.end('hello world\n');
  302. * }).listen(8000);
  303. * ```
  304. * @since v0.3.4
  305. * @param options Accepts `options` from `createServer`, `createSecureContext` and `createServer`.
  306. * @param requestListener A listener to be added to the `'request'` event.
  307. */
  308. function createServer<
  309. Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
  310. Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse,
  311. >(requestListener?: http.RequestListener<Request, Response>): Server<Request, Response>;
  312. function createServer<
  313. Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
  314. Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse,
  315. >(
  316. options: ServerOptions<Request, Response>,
  317. requestListener?: http.RequestListener<Request, Response>,
  318. ): Server<Request, Response>;
  319. /**
  320. * Makes a request to a secure web server.
  321. *
  322. * The following additional `options` from `tls.connect()` are also accepted: `ca`, `cert`, `ciphers`, `clientCertEngine`, `crl`, `dhparam`, `ecdhCurve`, `honorCipherOrder`, `key`, `passphrase`,
  323. * `pfx`, `rejectUnauthorized`, `secureOptions`, `secureProtocol`, `servername`, `sessionIdContext`, `highWaterMark`.
  324. *
  325. * `options` can be an object, a string, or a `URL` object. If `options` is a
  326. * string, it is automatically parsed with `new URL()`. If it is a `URL` object, it will be automatically converted to an ordinary `options` object.
  327. *
  328. * `https.request()` returns an instance of the `http.ClientRequest` class. The `ClientRequest` instance is a writable stream. If one needs to
  329. * upload a file with a POST request, then write to the `ClientRequest` object.
  330. *
  331. * ```js
  332. * import https from 'node:https';
  333. *
  334. * const options = {
  335. * hostname: 'encrypted.google.com',
  336. * port: 443,
  337. * path: '/',
  338. * method: 'GET',
  339. * };
  340. *
  341. * const req = https.request(options, (res) => {
  342. * console.log('statusCode:', res.statusCode);
  343. * console.log('headers:', res.headers);
  344. *
  345. * res.on('data', (d) => {
  346. * process.stdout.write(d);
  347. * });
  348. * });
  349. *
  350. * req.on('error', (e) => {
  351. * console.error(e);
  352. * });
  353. * req.end();
  354. * ```
  355. *
  356. * Example using options from `tls.connect()`:
  357. *
  358. * ```js
  359. * const options = {
  360. * hostname: 'encrypted.google.com',
  361. * port: 443,
  362. * path: '/',
  363. * method: 'GET',
  364. * key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
  365. * cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'),
  366. * };
  367. * options.agent = new https.Agent(options);
  368. *
  369. * const req = https.request(options, (res) => {
  370. * // ...
  371. * });
  372. * ```
  373. *
  374. * Alternatively, opt out of connection pooling by not using an `Agent`.
  375. *
  376. * ```js
  377. * const options = {
  378. * hostname: 'encrypted.google.com',
  379. * port: 443,
  380. * path: '/',
  381. * method: 'GET',
  382. * key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
  383. * cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'),
  384. * agent: false,
  385. * };
  386. *
  387. * const req = https.request(options, (res) => {
  388. * // ...
  389. * });
  390. * ```
  391. *
  392. * Example using a `URL` as `options`:
  393. *
  394. * ```js
  395. * const options = new URL('https://abc:xyz@example.com');
  396. *
  397. * const req = https.request(options, (res) => {
  398. * // ...
  399. * });
  400. * ```
  401. *
  402. * Example pinning on certificate fingerprint, or the public key (similar to`pin-sha256`):
  403. *
  404. * ```js
  405. * import tls from 'node:tls';
  406. * import https from 'node:https';
  407. * import crypto from 'node:crypto';
  408. *
  409. * function sha256(s) {
  410. * return crypto.createHash('sha256').update(s).digest('base64');
  411. * }
  412. * const options = {
  413. * hostname: 'github.com',
  414. * port: 443,
  415. * path: '/',
  416. * method: 'GET',
  417. * checkServerIdentity: function(host, cert) {
  418. * // Make sure the certificate is issued to the host we are connected to
  419. * const err = tls.checkServerIdentity(host, cert);
  420. * if (err) {
  421. * return err;
  422. * }
  423. *
  424. * // Pin the public key, similar to HPKP pin-sha256 pinning
  425. * const pubkey256 = 'pL1+qb9HTMRZJmuC/bB/ZI9d302BYrrqiVuRyW+DGrU=';
  426. * if (sha256(cert.pubkey) !== pubkey256) {
  427. * const msg = 'Certificate verification error: ' +
  428. * `The public key of '${cert.subject.CN}' ` +
  429. * 'does not match our pinned fingerprint';
  430. * return new Error(msg);
  431. * }
  432. *
  433. * // Pin the exact certificate, rather than the pub key
  434. * const cert256 = '25:FE:39:32:D9:63:8C:8A:FC:A1:9A:29:87:' +
  435. * 'D8:3E:4C:1D:98:DB:71:E4:1A:48:03:98:EA:22:6A:BD:8B:93:16';
  436. * if (cert.fingerprint256 !== cert256) {
  437. * const msg = 'Certificate verification error: ' +
  438. * `The certificate of '${cert.subject.CN}' ` +
  439. * 'does not match our pinned fingerprint';
  440. * return new Error(msg);
  441. * }
  442. *
  443. * // This loop is informational only.
  444. * // Print the certificate and public key fingerprints of all certs in the
  445. * // chain. Its common to pin the public key of the issuer on the public
  446. * // internet, while pinning the public key of the service in sensitive
  447. * // environments.
  448. * do {
  449. * console.log('Subject Common Name:', cert.subject.CN);
  450. * console.log(' Certificate SHA256 fingerprint:', cert.fingerprint256);
  451. *
  452. * hash = crypto.createHash('sha256');
  453. * console.log(' Public key ping-sha256:', sha256(cert.pubkey));
  454. *
  455. * lastprint256 = cert.fingerprint256;
  456. * cert = cert.issuerCertificate;
  457. * } while (cert.fingerprint256 !== lastprint256);
  458. *
  459. * },
  460. * };
  461. *
  462. * options.agent = new https.Agent(options);
  463. * const req = https.request(options, (res) => {
  464. * console.log('All OK. Server matched our pinned cert or public key');
  465. * console.log('statusCode:', res.statusCode);
  466. * // Print the HPKP values
  467. * console.log('headers:', res.headers['public-key-pins']);
  468. *
  469. * res.on('data', (d) => {});
  470. * });
  471. *
  472. * req.on('error', (e) => {
  473. * console.error(e.message);
  474. * });
  475. * req.end();
  476. * ```
  477. *
  478. * Outputs for example:
  479. *
  480. * ```text
  481. * Subject Common Name: github.com
  482. * Certificate SHA256 fingerprint: 25:FE:39:32:D9:63:8C:8A:FC:A1:9A:29:87:D8:3E:4C:1D:98:DB:71:E4:1A:48:03:98:EA:22:6A:BD:8B:93:16
  483. * Public key ping-sha256: pL1+qb9HTMRZJmuC/bB/ZI9d302BYrrqiVuRyW+DGrU=
  484. * Subject Common Name: DigiCert SHA2 Extended Validation Server CA
  485. * Certificate SHA256 fingerprint: 40:3E:06:2A:26:53:05:91:13:28:5B:AF:80:A0:D4:AE:42:2C:84:8C:9F:78:FA:D0:1F:C9:4B:C5:B8:7F:EF:1A
  486. * Public key ping-sha256: RRM1dGqnDFsCJXBTHky16vi1obOlCgFFn/yOhI/y+ho=
  487. * Subject Common Name: DigiCert High Assurance EV Root CA
  488. * Certificate SHA256 fingerprint: 74:31:E5:F4:C3:C1:CE:46:90:77:4F:0B:61:E0:54:40:88:3B:A9:A0:1E:D0:0B:A6:AB:D7:80:6E:D3:B1:18:CF
  489. * Public key ping-sha256: WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18=
  490. * All OK. Server matched our pinned cert or public key
  491. * statusCode: 200
  492. * headers: max-age=0; pin-sha256="WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18="; pin-sha256="RRM1dGqnDFsCJXBTHky16vi1obOlCgFFn/yOhI/y+ho=";
  493. * pin-sha256="k2v657xBsOVe1PQRwOsHsw3bsGT2VzIqz5K+59sNQws="; pin-sha256="K87oWBWM9UZfyddvDfoxL+8lpNyoUB2ptGtn0fv6G2Q="; pin-sha256="IQBnNBEiFuhj+8x6X8XLgh01V9Ic5/V3IRQLNFFc7v4=";
  494. * pin-sha256="iie1VXtL7HzAMF+/PVPR9xzT80kQxdZeJ+zduCB3uj0="; pin-sha256="LvRiGEjRqfzurezaWuj8Wie2gyHMrW5Q06LspMnox7A="; includeSubDomains
  495. * ```
  496. * @since v0.3.6
  497. * @param options Accepts all `options` from `request`, with some differences in default values:
  498. */
  499. function request(
  500. options: RequestOptions | string | URL,
  501. callback?: (res: http.IncomingMessage) => void,
  502. ): http.ClientRequest;
  503. function request(
  504. url: string | URL,
  505. options: RequestOptions,
  506. callback?: (res: http.IncomingMessage) => void,
  507. ): http.ClientRequest;
  508. /**
  509. * Like `http.get()` but for HTTPS.
  510. *
  511. * `options` can be an object, a string, or a `URL` object. If `options` is a
  512. * string, it is automatically parsed with `new URL()`. If it is a `URL` object, it will be automatically converted to an ordinary `options` object.
  513. *
  514. * ```js
  515. * import https from 'node:https';
  516. *
  517. * https.get('https://encrypted.google.com/', (res) => {
  518. * console.log('statusCode:', res.statusCode);
  519. * console.log('headers:', res.headers);
  520. *
  521. * res.on('data', (d) => {
  522. * process.stdout.write(d);
  523. * });
  524. *
  525. * }).on('error', (e) => {
  526. * console.error(e);
  527. * });
  528. * ```
  529. * @since v0.3.6
  530. * @param options Accepts the same `options` as {@link request}, with the `method` always set to `GET`.
  531. */
  532. function get(
  533. options: RequestOptions | string | URL,
  534. callback?: (res: http.IncomingMessage) => void,
  535. ): http.ClientRequest;
  536. function get(
  537. url: string | URL,
  538. options: RequestOptions,
  539. callback?: (res: http.IncomingMessage) => void,
  540. ): http.ClientRequest;
  541. let globalAgent: Agent;
  542. }
  543. declare module "node:https" {
  544. export * from "https";
  545. }