@pnpm/error 1100.1.2 → 1100.1.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @pnpm/error
2
2
 
3
+ ## 1100.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Added `fetchWarnTimeoutMs` and `fetchMinSpeedKiBps` to the Rust pnpm CLI and its N-API bindings. Slow registry metadata requests and tarball downloads now emit pnpm-compatible warnings without exposing URL credentials, query parameters, fragments, or control characters [pnpm/pnpm#12042](https://github.com/pnpm/pnpm/issues/12042).
8
+
9
+ - Updated dependencies:
10
+ - @pnpm/constants@1102.0.0
11
+
3
12
  ## 1100.1.2
4
13
 
5
14
  ### Patch Changes
package/lib/index.d.ts CHANGED
@@ -49,6 +49,13 @@ export declare function redactUrlCredentials(text: string): string;
49
49
  * or inject terminal output via raw escapes / `\r` / `\n`.
50
50
  */
51
51
  export declare function redactAndSanitize(text: string): string;
52
+ /**
53
+ * Make a URL safe for user-visible output without exposing credentials,
54
+ * query parameters, fragments, or terminal control characters. Malformed
55
+ * URLs are replaced entirely because their authority cannot be redacted
56
+ * reliably.
57
+ */
58
+ export declare function redactUrlForDisplay(url: string): string;
52
59
  /**
53
60
  * {@link redactAndSanitize} for text whose line breaks are worth keeping, such
54
61
  * as a subprocess's multi-line stderr.
package/lib/index.js CHANGED
@@ -94,14 +94,27 @@ export function redactAndSanitize(text) {
94
94
  // userinfo (`user:pass\r@host`) would otherwise split the authority across
95
95
  // the redaction scan, and removing it afterwards would rejoin the
96
96
  // credentials into the output.
97
- let sanitized = '';
98
- for (const char of text) {
99
- const code = char.codePointAt(0);
100
- if (code <= 0x1f || (code >= 0x7f && code <= 0x9f))
101
- continue;
102
- sanitized += char;
97
+ return redactUrlCredentials(sanitizeControlCharacters(text));
98
+ }
99
+ /**
100
+ * Make a URL safe for user-visible output without exposing credentials,
101
+ * query parameters, fragments, or terminal control characters. Malformed
102
+ * URLs are replaced entirely because their authority cannot be redacted
103
+ * reliably.
104
+ */
105
+ export function redactUrlForDisplay(url) {
106
+ let display;
107
+ try {
108
+ display = new URL(sanitizeControlCharacters(url));
103
109
  }
104
- return redactUrlCredentials(sanitized);
110
+ catch {
111
+ return '[hidden]';
112
+ }
113
+ display.username = '';
114
+ display.password = '';
115
+ display.search = '';
116
+ display.hash = '';
117
+ return display.href;
105
118
  }
106
119
  /**
107
120
  * {@link redactAndSanitize} for text whose line breaks are worth keeping, such
@@ -124,6 +137,16 @@ function isSchemeTailChar(code) {
124
137
  function isAsciiWhitespace(code) {
125
138
  return code === 0x20 || code === 0x09 || code === 0x0a || code === 0x0b || code === 0x0c || code === 0x0d;
126
139
  }
140
+ function sanitizeControlCharacters(text) {
141
+ let sanitized = '';
142
+ for (const char of text) {
143
+ const code = char.codePointAt(0);
144
+ if (code <= 0x1f || (code >= 0x7f && code <= 0x9f))
145
+ continue;
146
+ sanitized += char;
147
+ }
148
+ return sanitized;
149
+ }
127
150
  function hideAuthInformation(authHeaderValue) {
128
151
  const [authType, token] = authHeaderValue.split(' ');
129
152
  if (token == null)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/error",
3
- "version": "1100.1.2",
3
+ "version": "1100.1.3",
4
4
  "description": "An error class for pnpm errors",
5
5
  "keywords": [
6
6
  "pnpm",
@@ -28,11 +28,11 @@
28
28
  "!*.map"
29
29
  ],
30
30
  "dependencies": {
31
- "@pnpm/constants": "1101.0.0"
31
+ "@pnpm/constants": "1102.0.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@jest/globals": "30.4.1",
35
- "@pnpm/error": "1100.1.2"
35
+ "@pnpm/error": "1100.1.3"
36
36
  },
37
37
  "engines": {
38
38
  "node": ">=22.13"