@preventive/upstream 1.0.0-alpha.12 → 1.0.0-alpha.13
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/npm.d.ts +3 -2
- package/package.json +1 -1
- package/src/npm/registry.js +4 -1
package/npm.d.ts
CHANGED
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
// a timeout, as github.d.ts describes, and lookups for many names go to
|
|
8
8
|
// the registry eight at a time.
|
|
9
9
|
//
|
|
10
|
-
// Where
|
|
11
|
-
//
|
|
10
|
+
// Where PREVENTIVE_MEASURES_NPM_TOKEN, STASIS_NPM_TOKEN or NPM_TOKEN is
|
|
11
|
+
// set, the first of them not empty, in that order, is sent with the
|
|
12
|
+
// requests for a scoped package, so a private one can be read.
|
|
12
13
|
|
|
13
14
|
// Where a program called `name` keeps its cache for this user, as each
|
|
14
15
|
// platform has it, read from the environment when called. macOS:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@preventive/upstream",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.13",
|
|
4
4
|
"description": "Minimal npm, crates.io and Soldeer registry clients, a GitHub client, and a git checkout reader: the calls we use, nothing more",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
package/src/npm/registry.js
CHANGED
|
@@ -3,12 +3,15 @@ import assert from 'node:assert/strict'
|
|
|
3
3
|
import { show } from '../args.js'
|
|
4
4
|
import { NPM_REGISTRY, buildUrl, request } from '../http.js'
|
|
5
5
|
|
|
6
|
+
// The first of these that is set and not empty.
|
|
7
|
+
const npmToken = () => process.env.PREVENTIVE_MEASURES_NPM_TOKEN || process.env.STASIS_NPM_TOKEN || process.env.NPM_TOKEN
|
|
8
|
+
|
|
6
9
|
// Private packages are always scoped.
|
|
7
10
|
export function withNpmToken(name, url, options = {}) {
|
|
8
11
|
const method = options.method ?? 'GET'
|
|
9
12
|
const own = url === `${NPM_REGISTRY}/${name}` || url.startsWith(`${NPM_REGISTRY}/${name}/`)
|
|
10
13
|
assert.ok(method === 'GET' && `${new URL(url)}` === url && own, `Unexpected request for ${name}: ${method} ${url}`)
|
|
11
|
-
const token =
|
|
14
|
+
const token = npmToken()
|
|
12
15
|
return token && name.startsWith('@') ? { ...options, method, headers: { ...options.headers, Authorization: `Bearer ${token}` } } : options
|
|
13
16
|
}
|
|
14
17
|
|