@pnpm/network.auth-header 1101.1.15 → 1101.1.16

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,12 @@
1
1
  # @pnpm/network.auth-header
2
2
 
3
+ ## 1101.1.16
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies:
8
+ - @pnpm/error@1100.2.2
9
+
3
10
  ## 1101.1.15
4
11
 
5
12
  ### Patch Changes
@@ -12,19 +12,21 @@ export function getAuthHeadersFromCreds(configByUri) {
12
12
  if (header) {
13
13
  authHeaders.authHeaderValueByURI[normalizedUri] = header;
14
14
  }
15
- for (const scope of getRegistryScopes(registryConfig)) {
16
- if (scope === DEFAULT_REGISTRY_SCOPE)
17
- continue;
18
- const scopedCreds = registryConfig[scope];
19
- const scopedHeader = credsToHeader(scopedCreds);
20
- if (scopedHeader) {
21
- authHeaders.scopedAuthHeaderValueByURI[normalizedUri] ??= {};
22
- authHeaders.scopedAuthHeaderValueByURI[normalizedUri][scope] = scopedHeader;
23
- }
24
- }
15
+ collectScopedAuthHeaders(registryConfig, normalizedUri, authHeaders.scopedAuthHeaderValueByURI);
25
16
  }
26
17
  return authHeaders;
27
18
  }
19
+ function collectScopedAuthHeaders(registryConfig, normalizedUri, target) {
20
+ for (const scope of getRegistryScopes(registryConfig)) {
21
+ if (scope === DEFAULT_REGISTRY_SCOPE)
22
+ continue;
23
+ const scopedHeader = credsToHeader(registryConfig[scope]);
24
+ if (scopedHeader) {
25
+ target[normalizedUri] ??= {};
26
+ target[normalizedUri][scope] = scopedHeader;
27
+ }
28
+ }
29
+ }
28
30
  export function getAuthHeadersByScope(authHeaders) {
29
31
  const result = {};
30
32
  for (const [registryURI, authHeader] of Object.entries(authHeaders.authHeaderValueByURI)) {
package/lib/index.js CHANGED
@@ -59,8 +59,8 @@ function getAuthHeaderByNerfedURI(authHeaders, maxParts, uri) {
59
59
  const parsedUri = new URL(uri);
60
60
  const nerfed = nerfDart(uri);
61
61
  const parts = nerfed.split('/');
62
- for (let i = Math.min(parts.length, maxParts) - 1; i >= 3; i--) {
63
- const key = `${parts.slice(0, i).join('/')}/`;
62
+ for (let partCount = Math.min(parts.length, maxParts) - 1; partCount >= 3; partCount--) {
63
+ const key = `${parts.slice(0, partCount).join('/')}/`;
64
64
  if (authHeaders[key])
65
65
  return authHeaders[key];
66
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/network.auth-header",
3
- "version": "1101.1.15",
3
+ "version": "1101.1.16",
4
4
  "description": "Gets the authorization header for the given URI",
5
5
  "keywords": [
6
6
  "pnpm",
@@ -29,12 +29,12 @@
29
29
  ],
30
30
  "dependencies": {
31
31
  "@pnpm/config.registry-auth-key": "1100.0.0",
32
- "@pnpm/error": "1100.2.1",
32
+ "@pnpm/error": "1100.2.2",
33
33
  "@pnpm/types": "1102.1.1"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@jest/globals": "30.4.1",
37
- "@pnpm/network.auth-header": "1101.1.15",
37
+ "@pnpm/network.auth-header": "1101.1.16",
38
38
  "safe-buffer": "5.2.1"
39
39
  },
40
40
  "engines": {