@pnpm/network.auth-header 1101.1.3 → 1101.1.4

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 ADDED
@@ -0,0 +1,276 @@
1
+ # @pnpm/network.auth-header
2
+
3
+ ## 1101.1.4
4
+
5
+ ### Patch Changes
6
+
7
+ - A `tokenHelper` command is now given a 60-second time limit. A helper that hangs (deadlock, stuck I/O) is killed and reported as an error instead of leaving the command waiting forever.
8
+
9
+ - Updated dependencies:
10
+ - @pnpm/types@1101.4.0
11
+
12
+ ## 1101.1.3
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [852d537]
17
+ - @pnpm/error@1100.0.1
18
+
19
+ ## 1101.1.2
20
+
21
+ ### Patch Changes
22
+
23
+ - 681b593: pnpm can now use different auth tokens for different package scopes, even when those scopes use the same registry URL.
24
+
25
+ Previously, auth was selected only by registry URL. If `@org-a` and `@org-b` both used `https://npm.pkg.github.com/`, they had to share the same token. This caused problems for registries that issue tokens per organization or per scope.
26
+
27
+ Configure a scope-specific token by adding the package scope after the registry URL in the auth key:
28
+
29
+ ```ini
30
+ @org-a:registry=https://npm.pkg.github.com/
31
+ @org-b:registry=https://npm.pkg.github.com/
32
+
33
+ //npm.pkg.github.com/:@org-a:_authToken=${ORG_A_TOKEN}
34
+ //npm.pkg.github.com/:@org-b:_authToken=${ORG_B_TOKEN}
35
+
36
+ //npm.pkg.github.com/:_authToken=${FALLBACK_TOKEN}
37
+ ```
38
+
39
+ `pnpm login --registry=https://npm.pkg.github.com --scope=@org-a` writes the token to the same scope-specific auth key.
40
+
41
+ When installing or publishing `@org-a/*`, pnpm uses `ORG_A_TOKEN`. For `@org-b/*`, pnpm uses `ORG_B_TOKEN`. Packages without a matching scope continue to use the registry-wide fallback token.
42
+
43
+ - a31faa7: Updated dependency ranges. Notably:
44
+
45
+ - `@pnpm/logger` peer dependency range moved to `^1100.0.0`.
46
+ - `msgpackr` 1.11.8 → 2.0.4 (store index files remain byte-compatible in both directions).
47
+ - `open` ^7.4.2 → ^11.0.0, `memoize` ^10 → ^11, `cli-truncate` ^5 → ^6, `pidtree` ^0.6 → ^1.
48
+ - `@yarnpkg/core` 4.5.0 → 4.8.0, `@rushstack/worker-pool` 0.7.7 → 0.7.18, `@cyclonedx/cyclonedx-library` 10.0.0 → 10.1.0, `@pnpm/config.nerf-dart` ^1 → ^2, `@pnpm/log.group` 3.0.2 → 4.0.1, `@pnpm/util.lex-comparator` ^3 → ^4.
49
+
50
+ - Updated dependencies [681b593]
51
+ - @pnpm/types@1101.3.2
52
+
53
+ ## 1101.1.1
54
+
55
+ ### Patch Changes
56
+
57
+ - Updated dependencies [bf1b731]
58
+ - @pnpm/types@1101.3.1
59
+
60
+ ## 1101.1.0
61
+
62
+ ### Minor Changes
63
+
64
+ - 5192edf: The pnpr install accelerator now forwards the caller's per-registry credentials on `POST /v1/install`, so it can resolve, verify, and fetch private dependencies from external registries as the caller. The client sends an `Authorization` header identifying itself to the pnpr server plus an `authHeaders` map of the registry tokens (built with `@pnpm/network.auth-header`), and the server threads those credentials through resolution and fetch instead of reaching the registry anonymously. Externally-resolved private content carries no pnpr access policy, so the server gates it per user against the owning registry — serving a cache hit only to a user the registry has cleared — and re-checks access (clearing it on a `401`/`403`) rather than letting the store's possession of the bytes authorize anyone. Packages the registry serves anonymously are classified public once (globally) and then served to everyone without per-user access checks, so a registry that mixes public and private packages doesn't pay the per-user cost for its public ones.
65
+
66
+ ### Patch Changes
67
+
68
+ - Updated dependencies [a017bf3]
69
+ - @pnpm/types@1101.3.0
70
+
71
+ ## 1101.0.0
72
+
73
+ ### Major Changes
74
+
75
+ - a23956e: Fix a credential disclosure issue where an unscoped `_authToken` (or `_auth`, or `username` + `_password`, or `tokenHelper`) defined in one source — `~/.npmrc`, `~/.config/pnpm/auth.ini`, a workspace `.npmrc`, CLI flags, etc. — would be sent as an `Authorization` header to whichever registry a different (potentially untrusted) source named. The same fix extends to client TLS credentials (`cert`, `key`) so they aren't presented to a registry their author didn't choose.
76
+
77
+ pnpm now rewrites each unscoped per-registry setting (`_authToken`, `_auth`, `username`, `_password`, `tokenHelper`, `cert`, `key`) to its URL-scoped form at load time, using the `registry=` value declared in the same source (or the npmjs default registry if the source declares none). A later layer overriding `registry=` therefore cannot pull an unscoped credential along, because it is already pinned to the URL its author intended. `ca`/`cafile` are intentionally not rescoped — they're trust anchors, not credentials, and corporate MITM-proxy setups rely on them applying globally.
78
+
79
+ Every rescope emits a deprecation warning telling the user where the setting was pinned and how to write it directly. npm has rejected unscoped credentials outright since `npm@9`, and pnpm intends to remove support in a future major release. To target a specific registry, write the setting URL-scoped (e.g. `//registry.example.com/:_authToken=...` or `//registry.example.com/:cert=...`).
80
+
81
+ `@pnpm/network.auth-header`: removed the `defaultRegistry` parameter from `createGetAuthHeaderByURI` and `getAuthHeadersFromCreds`. Now that credentials are URL-scoped at load time, the merged `configByUri` never contains the empty-string "default registry" placeholder slot, so re-keying it onto the merged default registry is no longer needed.
82
+
83
+ ### Patch Changes
84
+
85
+ - Updated dependencies [35d2355]
86
+ - @pnpm/types@1101.2.0
87
+
88
+ ## 1100.0.3
89
+
90
+ ### Patch Changes
91
+
92
+ - Updated dependencies [64afc92]
93
+ - @pnpm/types@1101.1.1
94
+
95
+ ## 1100.0.2
96
+
97
+ ### Patch Changes
98
+
99
+ - Updated dependencies [b61e268]
100
+ - @pnpm/types@1101.1.0
101
+
102
+ ## 1100.0.1
103
+
104
+ ### Patch Changes
105
+
106
+ - Updated dependencies [ff28085]
107
+ - @pnpm/types@1101.0.0
108
+
109
+ ## 1001.0.0
110
+
111
+ ### Major Changes
112
+
113
+ - 491a84f: This package is now pure ESM.
114
+ - 7d2fd48: Node.js v18, 19, 20, and 21 support discontinued.
115
+
116
+ ### Patch Changes
117
+
118
+ - fb8962f: Fix `_password` handling for the default registry to decode from base64 before use, consistent with scoped registry behavior.
119
+ - b1ad9c7: Prepended `Bearer` to the authorization token generated by `tokenHelper` executable if it is missing, properly aligning pnpm's handling of token helpers with npm.
120
+ - Updated dependencies [76718b3]
121
+ - Updated dependencies [a8f016c]
122
+ - Updated dependencies [cc1b8e3]
123
+ - Updated dependencies [491a84f]
124
+ - Updated dependencies [7d2fd48]
125
+ - Updated dependencies [efb48dc]
126
+ - Updated dependencies [cb367b9]
127
+ - Updated dependencies [7b1c189]
128
+ - Updated dependencies [8ffb1a7]
129
+ - Updated dependencies [05fb1ae]
130
+ - Updated dependencies [71de2b3]
131
+ - Updated dependencies [10bc391]
132
+ - Updated dependencies [831f574]
133
+ - Updated dependencies [2df8b71]
134
+ - Updated dependencies [15549a9]
135
+ - Updated dependencies [cc7c0d2]
136
+ - Updated dependencies [efb48dc]
137
+ - @pnpm/types@1001.0.0
138
+ - @pnpm/error@1001.0.0
139
+
140
+ ## 1000.0.6
141
+
142
+ ### Patch Changes
143
+
144
+ - @pnpm/error@1000.0.5
145
+
146
+ ## 1000.0.5
147
+
148
+ ### Patch Changes
149
+
150
+ - @pnpm/error@1000.0.4
151
+
152
+ ## 1000.0.4
153
+
154
+ ### Patch Changes
155
+
156
+ - @pnpm/error@1000.0.3
157
+
158
+ ## 1000.0.3
159
+
160
+ ### Patch Changes
161
+
162
+ - 51bd373: Replace nerf-dart with @pnpm/config.nerf-dart to fix warning on Node.js 24.
163
+
164
+ ## 1000.0.2
165
+
166
+ ### Patch Changes
167
+
168
+ - @pnpm/error@1000.0.2
169
+
170
+ ## 1000.0.1
171
+
172
+ ### Patch Changes
173
+
174
+ - @pnpm/error@1000.0.1
175
+
176
+ ## 3.0.3
177
+
178
+ ### Patch Changes
179
+
180
+ - @pnpm/error@6.0.3
181
+
182
+ ## 3.0.2
183
+
184
+ ### Patch Changes
185
+
186
+ - @pnpm/error@6.0.2
187
+
188
+ ## 3.0.1
189
+
190
+ ### Patch Changes
191
+
192
+ - Updated dependencies [a7aef51]
193
+ - @pnpm/error@6.0.1
194
+
195
+ ## 3.0.0
196
+
197
+ ### Major Changes
198
+
199
+ - 43cdd87: Node.js v16 support dropped. Use at least Node.js v18.12.
200
+
201
+ ### Patch Changes
202
+
203
+ - Updated dependencies [3ded840]
204
+ - Updated dependencies [43cdd87]
205
+ - @pnpm/error@6.0.0
206
+
207
+ ## 2.2.0
208
+
209
+ ### Minor Changes
210
+
211
+ - 5a5e42551: Export the loadToken function.
212
+
213
+ ## 2.1.0
214
+
215
+ ### Minor Changes
216
+
217
+ - 3ac0487b3: Add support for basic authorization header [#7371](https://github.com/pnpm/pnpm/issues/7371).
218
+
219
+ ## 2.0.6
220
+
221
+ ### Patch Changes
222
+
223
+ - 23039a6d6: Fix missing auth tokens in registries with paths specified (e.g. //npm.pkg.github.com/pnpm). #5970 #2933
224
+
225
+ ## 2.0.5
226
+
227
+ ### Patch Changes
228
+
229
+ - aa20818a0: Authorization token should be found in the configuration, when the requested URL is explicitly specified with a default port (443 on HTTPS or 80 on HTTP) [#6863](https://github.com/pnpm/pnpm/pull/6864).
230
+
231
+ ## 2.0.4
232
+
233
+ ### Patch Changes
234
+
235
+ - e44031e71: Improve the performance of searching for auth tokens.
236
+
237
+ ## 2.0.3
238
+
239
+ ### Patch Changes
240
+
241
+ - 4e7afec90: Ignore the port in the URL, while searching for authentication token in the `.npmrc` file [#6354](https://github.com/pnpm/pnpm/issues/6354).
242
+
243
+ ## 2.0.2
244
+
245
+ ### Patch Changes
246
+
247
+ - @pnpm/error@5.0.2
248
+
249
+ ## 2.0.1
250
+
251
+ ### Patch Changes
252
+
253
+ - @pnpm/error@5.0.1
254
+
255
+ ## 2.0.0
256
+
257
+ ### Major Changes
258
+
259
+ - eceaa8b8b: Node.js 14 support dropped.
260
+
261
+ ### Patch Changes
262
+
263
+ - Updated dependencies [eceaa8b8b]
264
+ - @pnpm/error@5.0.0
265
+
266
+ ## 1.0.1
267
+
268
+ ### Patch Changes
269
+
270
+ - @pnpm/error@4.0.1
271
+
272
+ ## 1.0.0
273
+
274
+ ### Major Changes
275
+
276
+ - 804de211e: Initial release.
@@ -1,4 +1,4 @@
1
- import { type RegistryConfig } from '@pnpm/types';
1
+ import { type RegistryConfig, type TokenHelper } from '@pnpm/types';
2
2
  export interface AuthHeaders {
3
3
  authHeaderValueByURI: Record<string, string>;
4
4
  scopedAuthHeaderValueByURI: Record<string, Record<string, string>>;
@@ -6,3 +6,4 @@ export interface AuthHeaders {
6
6
  export type AuthHeadersByScope = Record<string, Record<string, string>>;
7
7
  export declare function getAuthHeadersFromCreds(configByUri: Record<string, RegistryConfig>): AuthHeaders;
8
8
  export declare function getAuthHeadersByScope(authHeaders: AuthHeaders): AuthHeadersByScope;
9
+ export declare function executeTokenHelper(tokenHelper: TokenHelper, timeoutMs?: number): string;
@@ -61,11 +61,20 @@ function credsToHeader(creds) {
61
61
  }
62
62
  return undefined;
63
63
  }
64
- function executeTokenHelper(tokenHelper) {
64
+ // A token helper only prints a token, so this is a generous bound that turns a
65
+ // hung helper (deadlock, stuck I/O) into a clear error instead of a command
66
+ // that hangs forever. Matches pacquet's `TOKEN_HELPER_TIMEOUT`.
67
+ const TOKEN_HELPER_TIMEOUT = 60_000;
68
+ export function executeTokenHelper(tokenHelper, timeoutMs = TOKEN_HELPER_TIMEOUT) {
65
69
  const [cmd, ...args] = tokenHelper;
66
70
  // On Windows, .bat/.cmd files require a shell to execute.
67
71
  const shell = process.platform === 'win32' && /\.(?:bat|cmd)$/i.test(cmd);
68
- const spawnResult = spawnSync(cmd, args, { stdio: 'pipe', shell });
72
+ const spawnResult = spawnSync(cmd, args, { stdio: 'pipe', shell, timeout: timeoutMs });
73
+ // A helper that outlives the timeout is killed; spawnSync then reports the
74
+ // kill signal rather than a clean exit, so surface it as a distinct error.
75
+ if (spawnResult.error != null && spawnResult.error.code === 'ETIMEDOUT') {
76
+ throw new PnpmError('TOKEN_HELPER_TIMEOUT', `Token helper "${cmd}" timed out after ${timeoutMs} ms`);
77
+ }
69
78
  if (spawnResult.status !== 0) {
70
79
  throw new PnpmError('TOKEN_HELPER_ERROR_STATUS', `Error running "${cmd}" as a token helper. Exit code ${spawnResult.status?.toString() ?? ''}`);
71
80
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/network.auth-header",
3
- "version": "1101.1.3",
3
+ "version": "1101.1.4",
4
4
  "description": "Gets the authorization header for the given URI",
5
5
  "keywords": [
6
6
  "pnpm",
@@ -30,12 +30,12 @@
30
30
  "dependencies": {
31
31
  "@pnpm/config.nerf-dart": "^2.0.1",
32
32
  "@pnpm/error": "1100.0.1",
33
- "@pnpm/types": "1101.3.2"
33
+ "@pnpm/types": "1101.4.0"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@jest/globals": "30.4.1",
37
- "safe-buffer": "5.2.1",
38
- "@pnpm/network.auth-header": "1101.1.3"
37
+ "@pnpm/network.auth-header": "1101.1.4",
38
+ "safe-buffer": "5.2.1"
39
39
  },
40
40
  "engines": {
41
41
  "node": ">=22.13"