@pnpm/error 1100.1.1 → 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,20 @@
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
+
12
+ ## 1100.1.2
13
+
14
+ ### Patch Changes
15
+
16
+ - A git dependency whose clone (or shallow fetch) fails now reports which package it belongs to, under the `ERR_PNPM_GIT_FETCH_FAILED` code, with credentials in the repository URL redacted. When the lockfile records an SSH remote, the error also explains that fetching it needs an SSH key for that host, and that a lockfile entry written before pnpm v11.21 can be re-recorded over HTTPS with `pnpm update <package>` [#13743](https://github.com/pnpm/pnpm/issues/13743).
17
+
3
18
  ## 1100.1.1
4
19
 
5
20
  ### Patch Changes
package/lib/index.d.ts CHANGED
@@ -49,6 +49,24 @@ 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;
59
+ /**
60
+ * {@link redactAndSanitize} for text whose line breaks are worth keeping, such
61
+ * as a subprocess's multi-line stderr.
62
+ *
63
+ * Line breaks are kept only when doing so redacts exactly as much as
64
+ * collapsing the text would: a newline can fall inside a `user:pass@`
65
+ * authority — git echoes such a URL back verbatim, password included — and
66
+ * redacting each line separately would leave the credentials split but
67
+ * readable. Whenever the two disagree, the collapsed form wins.
68
+ */
69
+ export declare function redactAndSanitizeMultiline(text: string): string;
52
70
  export declare class LockfileMissingDependencyError extends PnpmError {
53
71
  constructor(depPath: string);
54
72
  }
package/lib/index.js CHANGED
@@ -94,14 +94,42 @@ 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;
118
+ }
119
+ /**
120
+ * {@link redactAndSanitize} for text whose line breaks are worth keeping, such
121
+ * as a subprocess's multi-line stderr.
122
+ *
123
+ * Line breaks are kept only when doing so redacts exactly as much as
124
+ * collapsing the text would: a newline can fall inside a `user:pass@`
125
+ * authority — git echoes such a URL back verbatim, password included — and
126
+ * redacting each line separately would leave the credentials split but
127
+ * readable. Whenever the two disagree, the collapsed form wins.
128
+ */
129
+ export function redactAndSanitizeMultiline(text) {
130
+ const collapsed = redactAndSanitize(text);
131
+ const perLine = text.split('\n').map(redactAndSanitize).join('\n');
132
+ return perLine.replaceAll('\n', '') === collapsed ? perLine : collapsed;
105
133
  }
106
134
  function isSchemeTailChar(code) {
107
135
  return (code >= 0x30 && code <= 0x39) || (code >= 0x41 && code <= 0x5a) || (code >= 0x61 && code <= 0x7a);
@@ -109,6 +137,16 @@ function isSchemeTailChar(code) {
109
137
  function isAsciiWhitespace(code) {
110
138
  return code === 0x20 || code === 0x09 || code === 0x0a || code === 0x0b || code === 0x0c || code === 0x0d;
111
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
+ }
112
150
  function hideAuthInformation(authHeaderValue) {
113
151
  const [authType, token] = authHeaderValue.split(' ');
114
152
  if (token == null)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/error",
3
- "version": "1100.1.1",
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.1"
35
+ "@pnpm/error": "1100.1.3"
36
36
  },
37
37
  "engines": {
38
38
  "node": ">=22.13"