7e8c26bab680274694c9570b9fbda06058ff33398092f16d8de6a065283c29a6ee50be51dc5082b2d93449846f321b3cfe8dff658889e00479c11c58500be4 24 KB

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