urllib 3.12.0 → 3.13.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "urllib",
3
- "version": "3.12.0",
3
+ "version": "3.13.0",
4
4
  "publishConfig": {
5
5
  "tag": "latest"
6
6
  },
@@ -41,7 +41,7 @@
41
41
  "url": "git://github.com/node-modules/urllib.git"
42
42
  },
43
43
  "scripts": {
44
- "lint": "eslint src --ext .ts",
44
+ "lint": "eslint src test --ext .ts",
45
45
  "build": "npm run build:dist",
46
46
  "build:cjs": "tsc -p ./tsconfig.build.cjs.json",
47
47
  "build:esm": "tsc -p ./tsconfig.build.esm.json && node ./scripts/esm_import_fix.js",
@@ -74,7 +74,7 @@
74
74
  "@types/pump": "^1.1.1",
75
75
  "@types/selfsigned": "^2.0.1",
76
76
  "@types/tar-stream": "^2.2.2",
77
- "@vitest/coverage-c8": "^0.23.4",
77
+ "@vitest/coverage-c8": "^0.29.7",
78
78
  "busboy": "^1.6.0",
79
79
  "eslint": "^8.25.0",
80
80
  "eslint-config-egg": "^12.1.0",
@@ -84,10 +84,10 @@
84
84
  "selfsigned": "^2.0.1",
85
85
  "tar-stream": "^2.2.0",
86
86
  "typescript": "^4.8.3",
87
- "vitest": "^0.28.5"
87
+ "vitest": "^0.29.7"
88
88
  },
89
89
  "engines": {
90
- "node": ">= 14.17.0"
90
+ "node": ">= 14.19.3"
91
91
  },
92
92
  "license": "MIT"
93
93
  }
package/src/HttpAgent.ts CHANGED
@@ -1,5 +1,5 @@
1
- import dns from 'dns';
2
- import { LookupFunction, isIP } from 'net';
1
+ import dns from 'node:dns';
2
+ import { LookupFunction, isIP } from 'node:net';
3
3
  import {
4
4
  Agent,
5
5
  } from 'undici';
package/src/HttpClient.ts CHANGED
@@ -1,20 +1,21 @@
1
- import { EventEmitter } from 'events';
2
- import { LookupFunction } from 'net';
3
- import { STATUS_CODES } from 'http';
4
- import { debuglog } from 'util';
1
+ import { EventEmitter } from 'node:events';
2
+ import { LookupFunction } from 'node:net';
3
+ import { STATUS_CODES } from 'node:http';
4
+ import type { IncomingHttpHeaders } from 'node:http';
5
+ import { debuglog } from 'node:util';
5
6
  import {
6
7
  createGunzip,
7
8
  createBrotliDecompress,
8
9
  gunzipSync,
9
10
  brotliDecompressSync,
10
- } from 'zlib';
11
- import { Blob } from 'buffer';
12
- import { Readable, pipeline } from 'stream';
13
- import stream from 'stream';
14
- import { basename } from 'path';
15
- import { createReadStream } from 'fs';
16
- import { format as urlFormat } from 'url';
17
- import { performance } from 'perf_hooks';
11
+ } from 'node:zlib';
12
+ import { Blob } from 'node:buffer';
13
+ import { Readable, pipeline } from 'node:stream';
14
+ import stream from 'node:stream';
15
+ import { basename } from 'node:path';
16
+ import { createReadStream } from 'node:fs';
17
+ import { format as urlFormat } from 'node:url';
18
+ import { performance } from 'node:perf_hooks';
18
19
  import {
19
20
  FormData as FormDataNative,
20
21
  request as undiciRequest,
@@ -33,7 +34,6 @@ import { RawResponseWithMeta, HttpClientResponse, SocketInfo } from './Response'
33
34
  import { parseJSON, sleep, digestAuthHeader, globalId, performanceTime, isReadable } from './utils';
34
35
  import symbols from './symbols';
35
36
  import { initDiagnosticsChannel } from './diagnosticsChannel';
36
- import type { IncomingHttpHeaders } from 'http';
37
37
 
38
38
  type Exists<T> = T extends undefined ? never : T;
39
39
  type UndiciRequestOption = Exists<Parameters<typeof undiciRequest>[1]>;
package/src/Request.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Readable, Writable } from 'stream';
2
- import type { IncomingHttpHeaders } from 'http';
1
+ import { Readable, Writable } from 'node:stream';
2
+ import type { IncomingHttpHeaders } from 'node:http';
3
3
  import type Dispatcher from 'undici/types/dispatcher';
4
4
  import type {
5
5
  HttpClientResponse,
package/src/Response.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Readable } from 'stream';
2
- import { IncomingHttpHeaders } from 'http';
1
+ import { Readable } from 'node:stream';
2
+ import { IncomingHttpHeaders } from 'node:http';
3
3
 
4
4
  export type SocketInfo = {
5
5
  id: number;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { LookupFunction } from 'net';
2
+ import { LookupFunction } from 'node:net';
3
3
  import { Agent } from 'undici';
4
4
  import type Dispatcher from 'undici/types/dispatcher';
5
5
  import type buildConnector from 'undici/types/connector';
@@ -1,25 +1,16 @@
1
1
  "use strict";
2
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
- if (kind === "m") throw new TypeError("Private method is not writable");
4
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
- };
8
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
- };
13
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
4
  };
16
- var _HttpAgent_checkAddress;
17
5
  Object.defineProperty(exports, "__esModule", { value: true });
18
6
  exports.HttpAgent = void 0;
19
- const dns_1 = __importDefault(require("dns"));
20
- const net_1 = require("net");
7
+ const node_dns_1 = __importDefault(require("node:dns"));
8
+ const node_net_1 = require("node:net");
21
9
  const undici_1 = require("undici");
22
10
  class IllegalAddressError extends Error {
11
+ hostname;
12
+ ip;
13
+ family;
23
14
  constructor(hostname, ip, family) {
24
15
  const message = 'illegal address';
25
16
  super(message);
@@ -31,9 +22,10 @@ class IllegalAddressError extends Error {
31
22
  }
32
23
  }
33
24
  class HttpAgent extends undici_1.Agent {
25
+ #checkAddress;
34
26
  constructor(options) {
35
27
  /* eslint node/prefer-promises/dns: off*/
36
- const _lookup = options.lookup ?? dns_1.default.lookup;
28
+ const _lookup = options.lookup ?? node_dns_1.default.lookup;
37
29
  const lookup = (hostname, dnsOptions, callback) => {
38
30
  _lookup(hostname, dnsOptions, (err, address, family) => {
39
31
  if (err)
@@ -47,21 +39,20 @@ class HttpAgent extends undici_1.Agent {
47
39
  super({
48
40
  connect: { ...options.connect, lookup },
49
41
  });
50
- _HttpAgent_checkAddress.set(this, void 0);
51
- __classPrivateFieldSet(this, _HttpAgent_checkAddress, options.checkAddress, "f");
42
+ this.#checkAddress = options.checkAddress;
52
43
  }
53
44
  dispatch(options, handler) {
54
- if (__classPrivateFieldGet(this, _HttpAgent_checkAddress, "f") && options.origin) {
45
+ if (this.#checkAddress && options.origin) {
55
46
  const originUrl = typeof options.origin === 'string' ? new URL(options.origin) : options.origin;
56
47
  let hostname = originUrl.hostname;
57
48
  // [2001:db8:2de::e13] => 2001:db8:2de::e13
58
49
  if (hostname.startsWith('[') && hostname.endsWith(']')) {
59
50
  hostname = hostname.substring(1, hostname.length - 1);
60
51
  }
61
- const family = (0, net_1.isIP)(hostname);
52
+ const family = (0, node_net_1.isIP)(hostname);
62
53
  if (family === 4 || family === 6) {
63
54
  // if request hostname is ip, custom lookup won't excute
64
- if (!__classPrivateFieldGet(this, _HttpAgent_checkAddress, "f").call(this, hostname, family)) {
55
+ if (!this.#checkAddress(hostname, family)) {
65
56
  throw new IllegalAddressError(hostname, hostname, family);
66
57
  }
67
58
  }
@@ -70,5 +61,4 @@ class HttpAgent extends undici_1.Agent {
70
61
  }
71
62
  }
72
63
  exports.HttpAgent = HttpAgent;
73
- _HttpAgent_checkAddress = new WeakMap();
74
64
  //# sourceMappingURL=HttpAgent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"HttpAgent.js","sourceRoot":"","sources":["../Htt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CAAC;YACJ,OAAO,EAAE,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE;SACxC,CAAC,CAAC;QACH,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IAC5C,CAAC;IAED,QAAQ,CAAC,OAA8B,EAAE,OAAoC;QAC3E,IAAI,IAAI,CAAC,aAAa,IAAI,OAAO,CAAC,MAAM,EAAE;YACxC,MAAM,SAAS,GAAG,OAAO,OAAO,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;YAChG,IAAI,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;YAClC,2CAA2C;YAC3C,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;gBACtD,QAAQ,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;aACvD;YACD,MAAM,MAAM,GAAG,IAAA,eAAI,EAAC,QAAQ,CAAC,CAAC;YAC9B,IAAI,MAAM,KAAK,CAAC,IAAI,MAAM,KAAK,CAAC,EAAE;gBAChC,wDAAwD;gBACxD,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE;oBACzC,MAAM,IAAI,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;iBAC3D;aACF;SACF;QACD,OAAO,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;CACF;AAvCD,8BAuCC"}
@@ -1,8 +1,8 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
3
  /// <reference types="node" />
4
- import { EventEmitter } from 'events';
5
- import { LookupFunction } from 'net';
4
+ import { EventEmitter } from 'node:events';
5
+ import { LookupFunction } from 'node:net';
6
6
  import { CheckAddressFunction } from './HttpAgent';
7
7
  import { RequestURL, RequestOptions } from './Request';
8
8
  import { HttpClientResponse } from './Response';