deps: upgrade npm to 10.5.2

PR-URL: https://github.com/nodejs/node/pull/52458
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
This commit is contained in:
npm CLI robot authored and Richard Lau committed 2024-05-07 17:05:03 +00:00
1 parent 71616e8a8a
commit 8fd5a35364
89 files changed
+3297 -2573

No files matched your search

+1 -1
View File
@@ -90,7 +90,7 @@ The `sig` is generated using the following template: `${package.name}@${package.
Keys response:
- `expires`: null or a simplified extended [ISO 8601 format](https://en.wikipedia.org/wiki/ISO_8601"): `YYYY-MM-DDTHH:mm:ss.sssZ`
- `expires`: null or a simplified extended [ISO 8601 format](https://en.wikipedia.org/wiki/ISO_8601): `YYYY-MM-DDTHH:mm:ss.sssZ`
- `keydid`: sha256 fingerprint of the public key
- `keytype`: only `ecdsa-sha2-nistp256` is currently supported by the npm CLI
- `scheme`: only `ecdsa-sha2-nistp256` is currently supported by the npm CLI
+1 -1
View File
@@ -27,7 +27,7 @@ packages will *also* show the paths to the specified packages. For
example, running `npm ls promzard` in npm's source tree will show:
```bash
npm@10.5.1 /path/to/npm
npm@10.5.2 /path/to/npm
└─┬ init-package-json@0.0.4
└── promzard@0.1.5
```
+1 -1
View File
@@ -14,7 +14,7 @@ Note: This command is unaware of workspaces.
### Version
10.5.1
10.5.2
### Description
+1 -1
View File
@@ -209,7 +209,7 @@ means updating npm beyond the version that ships with Node.js.</p>
</code></pre>
<p>Keys response:</p>
<ul>
<li><code>expires</code>: null or a simplified extended <a href="https://en.wikipedia.org/wiki/ISO_8601%22">ISO 8601 format</a>: <code>YYYY-MM-DDTHH:mm:ss.sssZ</code></li>
<li><code>expires</code>: null or a simplified extended <a href="https://en.wikipedia.org/wiki/ISO_8601">ISO 8601 format</a>: <code>YYYY-MM-DDTHH:mm:ss.sssZ</code></li>
<li><code>keydid</code>: sha256 fingerprint of the public key</li>
<li><code>keytype</code>: only <code>ecdsa-sha2-nistp256</code> is currently supported by the npm CLI</li>
<li><code>scheme</code>: only <code>ecdsa-sha2-nistp256</code> is currently supported by the npm CLI</li>
+1 -1
View File
@@ -160,7 +160,7 @@ tree at all, use <a href="../commands/npm-explain.html"><code>npm explain</code>
the results to only the paths to the packages named. Note that nested
packages will <em>also</em> show the paths to the specified packages. For
example, running <code>npm ls promzard</code> in npm's source tree will show:</p>
<pre><code class="language-bash">npm@10.5.1 /path/to/npm
<pre><code class="language-bash">npm@10.5.2 /path/to/npm
└─┬ init-package-json@0.0.4
└── promzard@0.1.5
</code></pre>
+1 -1
View File
@@ -150,7 +150,7 @@ npm command-line interface
</code></pre>
<p>Note: This command is unaware of workspaces.</p>
<h3 id="version">Version</h3>
<p>10.5.1</p>
<p>10.5.2</p>
<h3 id="description">Description</h3>
<p>npm is the package manager for the Node JavaScript platform. It puts
modules in place so that node can find them, and manages dependency
+1 -1
View File
@@ -3,7 +3,6 @@
const { relative } = require('path')
const { definitions } = require('@npmcli/config/lib/definitions')
const getWorkspaces = require('./workspaces/get-workspaces.js')
const { aliases: cmdAliases } = require('./utils/cmd-list')
const log = require('./utils/log-shim.js')
@@ -170,6 +169,7 @@ class BaseCommand {
const relativeFrom = prefixInsideCwd ? this.npm.localPrefix : process.cwd()
const filters = this.npm.config.get('workspace')
const getWorkspaces = require('./workspaces/get-workspaces.js')
const ws = await getWorkspaces(filters, {
path: this.npm.localPrefix,
includeWorkspaceRoot,
+2 -1
View File
@@ -5,6 +5,7 @@ const log = require('../utils/log-shim')
const otplease = require('../utils/otplease.js')
const pkgJson = require('@npmcli/package-json')
const BaseCommand = require('../base-command.js')
const { redact } = require('@npmcli/redact')
const readJson = async (path) => {
try {
@@ -119,7 +120,7 @@ class Owner extends BaseCommand {
this.npm.output(maintainers.map(m => `${m.name} <${m.email}>`).join('\n'))
}
} catch (err) {
log.error('owner ls', "Couldn't get owner data", npmFetch.cleanUrl(pkg))
log.error('owner ls', "Couldn't get owner data", redact(pkg))
throw err
}
}
+2 -2
View File
@@ -1,4 +1,4 @@
const { cleanUrl } = require('npm-registry-fetch')
const { redact } = require('@npmcli/redact')
const log = require('../utils/log-shim')
const pingUtil = require('../utils/ping.js')
const BaseCommand = require('../base-command.js')
@@ -9,7 +9,7 @@ class Ping extends BaseCommand {
static name = 'ping'
async exec (args) {
const cleanRegistry = cleanUrl(this.npm.config.get('registry'))
const cleanRegistry = redact(this.npm.config.get('registry'))
log.notice('PING', cleanRegistry)
const start = Date.now()
const details = await pingUtil({ ...this.npm.flatOptions })
+6 -1
View File
@@ -220,7 +220,12 @@ class Publish extends BaseCommand {
})
}
if (manifest.publishConfig) {
flatten(manifest.publishConfig, opts)
const cliFlags = this.npm.config.data.get('cli').raw
// Filter out properties set in CLI flags to prioritize them over
// corresponding `publishConfig` settings
const filteredPublishConfig = Object.fromEntries(
Object.entries(manifest.publishConfig).filter(([key]) => !(key in cliFlags)))
flatten(filteredPublishConfig, opts)
}
return manifest
}
+6 -1
View File
@@ -141,7 +141,12 @@ class Unpublish extends BaseCommand {
// If localPrefix has a package.json with a name that matches the package
// being unpublished, load up the publishConfig
if (manifest?.name === spec.name && manifest.publishConfig) {
flatten(manifest.publishConfig, opts)
const cliFlags = this.npm.config.data.get('cli').raw
// Filter out properties set in CLI flags to prioritize them over
// corresponding `publishConfig` settings
const filteredPublishConfig = Object.fromEntries(
Object.entries(manifest.publishConfig).filter(([key]) => !(key in cliFlags)))
flatten(filteredPublishConfig, opts)
}
const versions = await Unpublish.getKeysOfVersions(spec.name, opts)
+1 -1
View File
@@ -1,6 +1,5 @@
const { format } = require('util')
const { resolve } = require('path')
const nameValidator = require('validate-npm-package-name')
const { redactLog: replaceInfo } = require('@npmcli/redact')
const { report } = require('./explain-eresolve.js')
const log = require('./log-shim')
@@ -215,6 +214,7 @@ const errorMessage = (er, npm) => {
detail.push(['404', ''])
detail.push(['404', '', `'${replaceInfo(er.pkgid)}' is not in this registry.`])
const nameValidator = require('validate-npm-package-name')
const valResult = nameValidator(pkg)
if (!valResult.validForNewPackages) {
+32 -10
View File
@@ -1,7 +1,6 @@
const os = require('os')
const { join, dirname, basename } = require('path')
const { format } = require('util')
const { glob } = require('glob')
const { Minipass } = require('minipass')
const fsMiniPass = require('fs-minipass')
const fs = require('fs/promises')
@@ -9,7 +8,6 @@ const log = require('./log-shim')
const Display = require('./display')
const padZero = (n, length) => n.toString().padStart(length.toString().length, '0')
const globify = pattern => pattern.split('\\').join('/')
class LogFiles {
// Default to a plain minipass stream so we can buffer
@@ -199,17 +197,41 @@ class LogFiles {
try {
const logPath = this.#getLogFilePath()
const logGlob = join(dirname(logPath), basename(logPath)
const patternFileName = basename(logPath)
// tell glob to only match digits
.replace(/\d/g, '[0123456789]')
.replace(/\d/g, 'd')
// Handle the old (prior to 8.2.0) log file names which did not have a
// counter suffix
.replace(/-\.log$/, '*.log')
)
.replace('-.log', '')
// Always ignore the currently written files
const files = await glob(globify(logGlob), { ignore: this.#files.map(globify), silent: true })
const toDelete = files.length - this.#logsMax
let files = await fs.readdir(
dirname(logPath), {
withFileTypes: true,
encoding: 'utf-8',
})
files = files.sort((a, b) => basename(a.name).localeCompare(basename(b.name), 'en'))
const logFiles = []
for (const file of files) {
if (!file.isFile()) {
continue
}
const genericFileName = file.name.replace(/\d/g, 'd')
const filePath = join(dirname(logPath), basename(file.name))
// Always ignore the currently written files
if (
genericFileName.includes(patternFileName)
&& genericFileName.endsWith('.log')
&& !this.#files.includes(filePath)
) {
logFiles.push(filePath)
}
}
const toDelete = logFiles.length - this.#logsMax
if (toDelete <= 0) {
return
@@ -217,7 +239,7 @@ class LogFiles {
log.silly('logfile', `start cleaning logs, removing ${toDelete} files`)
for (const file of files.slice(0, toDelete)) {
for (const file of logFiles.slice(0, toDelete)) {
try {
await fs.rm(file, { force: true })
} catch (e) {
+7 -5
View File
@@ -3,7 +3,9 @@
// Check daily for betas, and weekly otherwise.
const ciInfo = require('ci-info')
const semver = require('semver')
const gt = require('semver/functions/gt')
const gte = require('semver/functions/gte')
const parse = require('semver/functions/parse')
const { stat, writeFile } = require('fs/promises')
const { resolve } = require('path')
@@ -38,12 +40,12 @@ const updateCheck = async (npm, spec, version, current) => {
// and should get the updates from that release train.
// Note that this isn't another http request over the network, because
// the packument will be cached by pacote from previous request.
if (semver.gt(version, latest) && spec === 'latest') {
if (gt(version, latest) && spec === 'latest') {
return updateNotifier(npm, `^${version}`)
}
// if we already have something >= the desired spec, then we're done
if (semver.gte(version, latest)) {
if (gte(version, latest)) {
return null
}
@@ -53,7 +55,7 @@ const updateCheck = async (npm, spec, version, current) => {
// ok! notify the user about this update they should get.
// The message is saved for printing at process exit so it will not get
// lost in any other messages being printed as part of the command.
const update = semver.parse(mani.version)
const update = parse(mani.version)
const type = update.major !== current.major ? 'major'
: update.minor !== current.minor ? 'minor'
: update.patch !== current.patch ? 'patch'
@@ -79,7 +81,7 @@ const updateNotifier = async (npm, spec = 'latest') => {
// if we're on a prerelease train, then updates are coming fast
// check for a new one daily. otherwise, weekly.
const { version } = npm
const current = semver.parse(version)
const current = parse(version)
// if we're on a beta train, always get the next beta
if (current.prerelease.length) {
+1 -1
View File
@@ -80,7 +80,7 @@ Public signing keys are provided at \fBregistry-host.tld/-/npm/v1/keys\fR in the
Keys response:
.RS 0
.IP \(bu 4
\fBexpires\fR: null or a simplified extended \fBISO 8601 format\fR \fI\(lahttps://en.wikipedia.org/wiki/ISO_8601"\(ra\fR: \fBYYYY-MM-DDTHH:mm:ss.sssZ\fR
\fBexpires\fR: null or a simplified extended \fBISO 8601 format\fR \fI\(lahttps://en.wikipedia.org/wiki/ISO_8601\(ra\fR: \fBYYYY-MM-DDTHH:mm:ss.sssZ\fR
.IP \(bu 4
\fBkeydid\fR: sha256 fingerprint of the public key
.IP \(bu 4
+1 -1
View File
@@ -20,7 +20,7 @@ Positional arguments are \fBname@version-range\fR identifiers, which will limit
.P
.RS 2
.nf
npm@10.5.1 /path/to/npm
npm@10.5.2 /path/to/npm
└─┬ init-package-json@0.0.4
└── promzard@0.1.5
.fi
+1 -1
View File
@@ -12,7 +12,7 @@ npm
Note: This command is unaware of workspaces.
.SS "Version"
.P
10.5.1
10.5.2
.SS "Description"
.P
npm is the package manager for the Node JavaScript platform. It puts modules in place so that node can find them, and manages dependency conflicts intelligently.
+4 -1
View File
@@ -65,7 +65,10 @@ module.exports = class Agent extends AgentBase {
ProxyAgent = this.isSecureEndpoint(options) ? ProxyAgent[1] : ProxyAgent[0]
}
const proxyAgent = new ProxyAgent(proxy, this.#options)
const proxyAgent = new ProxyAgent(proxy, {
...this.#options,
socketOptions: { family: this.#options.family },
})
proxyCache.set(cacheKey, proxyAgent)
return proxyAgent
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@npmcli/agent",
"version": "2.2.1",
"version": "2.2.2",
"description": "the http/https agent used by the npm cli",
"main": "lib/index.js",
"scripts": {
@@ -36,7 +36,7 @@
"http-proxy-agent": "^7.0.0",
"https-proxy-agent": "^7.0.1",
"lru-cache": "^10.0.1",
"socks-proxy-agent": "^8.0.1"
"socks-proxy-agent": "^8.0.3"
},
"devDependencies": {
"@npmcli/eslint-config": "^4.0.0",
+2 -2
View File
@@ -12,7 +12,7 @@ const { readdirScoped } = require('@npmcli/fs')
const { lstat, readlink } = require('fs/promises')
const { depth } = require('treeverse')
const log = require('proc-log')
const { cleanUrl } = require('npm-registry-fetch')
const { redact } = require('@npmcli/redact')
const {
OK,
@@ -1213,7 +1213,7 @@ This is a one-time fix-up, please be patient...
if (this.#manifests.has(spec.raw)) {
return this.#manifests.get(spec.raw)
} else {
const cleanRawSpec = cleanUrl(spec.rawSpec)
const cleanRawSpec = redact(spec.rawSpec)
log.silly('fetch manifest', spec.raw.replace(spec.rawSpec, cleanRawSpec))
const o = {
...options,
+2 -2
View File
@@ -9,7 +9,7 @@
const localeCompare = require('@isaacs/string-locale-compare')('en')
const log = require('proc-log')
const { cleanUrl } = require('npm-registry-fetch')
const { redact } = require('@npmcli/redact')
const deepestNestingTarget = require('./deepest-nesting-target.js')
const CanPlaceDep = require('./can-place-dep.js')
const {
@@ -188,7 +188,7 @@ class PlaceDep {
`${this.dep.name}@${this.dep.version}`,
this.canPlace.description,
`for: ${this.edge.from.package._id || this.edge.from.location}`,
`want: ${cleanUrl(this.edge.spec || '*')}`
`want: ${redact(this.edge.spec || '*')}`
)
const placementType = this.canPlace.canPlace === CONFLICT
+2 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@npmcli/arborist",
"version": "7.4.1",
"version": "7.4.2",
"description": "Manage node_modules trees",
"dependencies": {
"@isaacs/string-locale-compare": "^1.1.0",
@@ -12,6 +12,7 @@
"@npmcli/node-gyp": "^3.0.0",
"@npmcli/package-json": "^5.0.0",
"@npmcli/query": "^3.1.0",
"@npmcli/redact": "^1.1.0",
"@npmcli/run-script": "^7.0.2",
"bin-links": "^4.0.1",
"cacache": "^18.0.0",
File diff suppressed because it is too large. Load diff
+21 -28
View File
@@ -2,12 +2,10 @@
const { walkUp } = require('walk-up-path')
const ini = require('ini')
const nopt = require('nopt')
const mapWorkspaces = require('@npmcli/map-workspaces')
const rpj = require('read-package-json-fast')
const log = require('proc-log')
const { resolve, dirname, join } = require('path')
const { homedir } = require('os')
const { resolve, dirname, join } = require('node:path')
const { homedir } = require('node:os')
const {
readFile,
writeFile,
@@ -28,35 +26,12 @@ const dirExists = (...p) => stat(resolve(...p))
const hasOwnProperty = (obj, key) =>
Object.prototype.hasOwnProperty.call(obj, key)
// define a custom getter, but turn into a normal prop
// if we set it. otherwise it can't be set on child objects
const settableGetter = (obj, key, get) => {
Object.defineProperty(obj, key, {
get,
set (value) {
Object.defineProperty(obj, key, {
value,
configurable: true,
writable: true,
enumerable: true,
})
},
configurable: true,
enumerable: true,
})
}
const typeDefs = require('./type-defs.js')
const nerfDart = require('./nerf-dart.js')
const envReplace = require('./env-replace.js')
const parseField = require('./parse-field.js')
const typeDescription = require('./type-description.js')
const setEnvs = require('./set-envs.js')
const {
ErrInvalidAuth,
} = require('./errors.js')
// types that can be saved back to
const confFileTypes = new Set([
'global',
@@ -329,7 +304,21 @@ class Config {
// default the globalconfig file to that location, instead of the default
// global prefix. It's weird that `npm get globalconfig --prefix=/foo`
// returns `/foo/etc/npmrc`, but better to not change it at this point.
settableGetter(data, 'globalconfig', () => resolve(this.#get('prefix'), 'etc/npmrc'))
// define a custom getter, but turn into a normal prop
// if we set it. otherwise it can't be set on child objects
Object.defineProperty(data, 'globalconfig', {
get: () => resolve(this.#get('prefix'), 'etc/npmrc'),
set (value) {
Object.defineProperty(data, 'globalconfig', {
value,
configurable: true,
writable: true,
enumerable: true,
})
},
configurable: true,
enumerable: true,
})
}
loadHome () {
@@ -444,6 +433,7 @@ class Config {
}
if (authProblems.length) {
const { ErrInvalidAuth } = require('./errors.js')
throw new ErrInvalidAuth(authProblems)
}
@@ -512,6 +502,7 @@ class Config {
}
invalidHandler (k, val, type, source, where) {
const typeDescription = require('./type-description.js')
log.warn(
'invalid config',
k + '=' + JSON.stringify(val),
@@ -696,6 +687,7 @@ class Config {
}
if (this.localPrefix && hasPackageJson) {
const rpj = require('read-package-json-fast')
// if we already set localPrefix but this dir has a package.json
// then we need to see if `p` is a workspace root by reading its package.json
// however, if reading it fails then we should just move on
@@ -704,6 +696,7 @@ class Config {
continue
}
const mapWorkspaces = require('@npmcli/map-workspaces')
const workspaces = await mapWorkspaces({ cwd: p, pkg })
for (const w of workspaces.values()) {
if (w === this.localPrefix) {
+1 -1
View File
@@ -1,4 +1,4 @@
const { URL } = require('url')
const { URL } = require('node:url')
/**
* Maps a URL to an identifier.
+1 -1
View File
@@ -1,7 +1,7 @@
// Parse a field, coercing it to the best type available.
const typeDefs = require('./type-defs.js')
const envReplace = require('./env-replace.js')
const { resolve } = require('path')
const { resolve } = require('node:path')
const { parse: umaskParse } = require('./umask.js')
+6 -4
View File
@@ -1,10 +1,12 @@
const nopt = require('nopt')
const { Umask, validate: validateUmask } = require('./umask.js')
const { validate: validateUmask } = require('./umask.js')
const semver = require('semver')
class Umask {}
class Semver {}
const semverValid = require('semver/functions/valid')
const validateSemver = (data, k, val) => {
const valid = semver.valid(val)
const valid = semverValid(val)
if (!valid) {
return false
}
@@ -23,7 +25,7 @@ const validatePath = (data, k, val) => {
module.exports = {
...nopt.typeDefs,
semver: {
type: semver,
type: Semver,
validate: validateSemver,
description: 'full valid SemVer string',
},
+1 -2
View File
@@ -1,4 +1,3 @@
class Umask {}
const parse = val => {
// this is run via nopt and parse field where everything is
// converted to a string first, ignoring coverage for now
@@ -33,4 +32,4 @@ const validate = (data, k, val) => {
}
}
module.exports = { Umask, parse, validate }
module.exports = { parse, validate }
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@npmcli/config",
"version": "8.2.1",
"version": "8.2.2",
"files": [
"bin/",
"lib/"
+1 -3
View File
@@ -1,6 +1,4 @@
// not an airtight indicator, but a good gut-check to even bother trying
const { promisify } = require('util')
const fs = require('fs')
const stat = promisify(fs.stat)
const { stat } = require('fs/promises')
module.exports = ({ cwd = process.cwd() } = {}) =>
stat(cwd + '/.git').then(() => true, () => false)
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@npmcli/git",
"version": "5.0.4",
"version": "5.0.5",
"main": "lib/index.js",
"files": [
"bin/",
+83 -60
View File
@@ -5,23 +5,49 @@ const { minimatch } = require('minimatch')
const rpj = require('read-package-json-fast')
const { glob } = require('glob')
function appendNegatedPatterns (patterns) {
const results = []
for (let pattern of patterns) {
function appendNegatedPatterns (allPatterns) {
const patterns = []
const negatedPatterns = []
for (let pattern of allPatterns) {
const excl = pattern.match(/^!+/)
if (excl) {
pattern = pattern.slice(excl[0].length)
}
// strip off any / from the start of the pattern. /foo => foo
pattern = pattern.replace(/^\/+/, '')
// strip off any / or ./ from the start of the pattern. /foo => foo
pattern = pattern.replace(/^\.?\/+/, '')
// an odd number of ! means a negated pattern. !!foo ==> foo
const negate = excl && excl[0].length % 2 === 1
results.push({ pattern, negate })
if (negate) {
negatedPatterns.push(pattern)
} else {
// remove negated patterns that appeared before this pattern to avoid
// ignoring paths that were matched afterwards
// e.g: ['packages/**', '!packages/b/**', 'packages/b/a']
// in the above list, the last pattern overrides the negated pattern
// right before it. In effect, the above list would become:
// ['packages/**', 'packages/b/a']
// The order matters here which is why we must do it inside the loop
// as opposed to doing it all together at the end.
for (let i = 0; i < negatedPatterns.length; ++i) {
const negatedPattern = negatedPatterns[i]
if (minimatch(pattern, negatedPattern)) {
negatedPatterns.splice(i, 1)
}
}
patterns.push(pattern)
}
}
return results
// use the negated patterns to eagerly remove all the patterns that
// can be removed to avoid unnecessary crawling
for (const negated of negatedPatterns) {
for (const pattern of minimatch.match(patterns, negated)) {
patterns.splice(patterns.indexOf(pattern), 1)
}
}
return { patterns, negatedPatterns }
}
function getPatterns (workspaces) {
@@ -77,11 +103,11 @@ async function mapWorkspaces (opts = {}) {
}
const { workspaces = [] } = opts.pkg
const patterns = getPatterns(workspaces)
const { patterns, negatedPatterns } = getPatterns(workspaces)
const results = new Map()
const seen = new Map()
if (!patterns.length) {
if (!patterns.length && !negatedPatterns.length) {
return results
}
@@ -89,52 +115,54 @@ async function mapWorkspaces (opts = {}) {
...opts,
ignore: [
...opts.ignore || [],
...['**/node_modules/**'],
'**/node_modules/**',
// just ignore the negated patterns to avoid unnecessary crawling
...negatedPatterns,
],
})
const getPackagePathname = pkgPathmame(opts)
for (const item of patterns) {
let matches = await glob(getGlobPattern(item.pattern), getGlobOpts())
// preserves glob@8 behavior
matches = matches.sort((a, b) => a.localeCompare(b, 'en'))
let matches = await glob(patterns.map((p) => getGlobPattern(p)), getGlobOpts())
// preserves glob@8 behavior
matches = matches.sort((a, b) => a.localeCompare(b, 'en'))
for (const match of matches) {
let pkg
const packageJsonPathname = getPackagePathname(match, 'package.json')
const packagePathname = path.dirname(packageJsonPathname)
// we must preserve the order of results according to the given list of
// workspace patterns
const orderedMatches = []
for (const pattern of patterns) {
orderedMatches.push(...matches.filter((m) => {
return minimatch(m, pattern, { partial: true, windowsPathsNoEscape: true })
}))
}
try {
pkg = await rpj(packageJsonPathname)
} catch (err) {
if (err.code === 'ENOENT') {
continue
} else {
throw err
}
}
for (const match of orderedMatches) {
let pkg
const packageJsonPathname = getPackagePathname(match, 'package.json')
const name = getPackageName(pkg, packagePathname)
let seenPackagePathnames = seen.get(name)
if (!seenPackagePathnames) {
seenPackagePathnames = new Set()
seen.set(name, seenPackagePathnames)
}
if (item.negate) {
seenPackagePathnames.delete(packagePathname)
try {
pkg = await rpj(packageJsonPathname)
} catch (err) {
if (err.code === 'ENOENT') {
continue
} else {
seenPackagePathnames.add(packagePathname)
throw err
}
}
const packagePathname = path.dirname(packageJsonPathname)
const name = getPackageName(pkg, packagePathname)
let seenPackagePathnames = seen.get(name)
if (!seenPackagePathnames) {
seenPackagePathnames = new Set()
seen.set(name, seenPackagePathnames)
}
seenPackagePathnames.add(packagePathname)
}
const errorMessageArray = ['must not have multiple workspaces with the same name']
for (const [packageName, seenPackagePathnames] of seen) {
if (seenPackagePathnames.size === 0) {
continue
}
if (seenPackagePathnames.size > 1) {
addDuplicateErrorMessages(errorMessageArray, packageName, seenPackagePathnames)
} else {
@@ -177,30 +205,25 @@ mapWorkspaces.virtual = function (opts = {}) {
const { workspaces = [] } = packages[''] || {}
// uses a pathname-keyed map in order to negate the exact items
const results = new Map()
const patterns = getPatterns(workspaces)
if (!patterns.length) {
const { patterns, negatedPatterns } = getPatterns(workspaces)
if (!patterns.length && !negatedPatterns.length) {
return results
}
patterns.push({ pattern: '**/node_modules/**', negate: true })
negatedPatterns.push('**/node_modules/**')
const packageKeys = Object.keys(packages)
for (const pattern of negatedPatterns) {
for (const packageKey of minimatch.match(packageKeys, pattern)) {
packageKeys.splice(packageKeys.indexOf(packageKey), 1)
}
}
const getPackagePathname = pkgPathmame(opts)
for (const packageKey of Object.keys(packages)) {
if (packageKey === '') {
continue
}
for (const item of patterns) {
if (minimatch(packageKey, item.pattern)) {
const packagePathname = getPackagePathname(packageKey)
const name = getPackageName(packages[packageKey], packagePathname)
if (item.negate) {
results.delete(packagePathname)
} else {
results.set(packagePathname, name)
}
}
for (const pattern of patterns) {
for (const packageKey of minimatch.match(packageKeys, pattern)) {
const packagePathname = getPackagePathname(packageKey)
const name = getPackageName(packages[packageKey], packagePathname)
results.set(packagePathname, name)
}
}
+4 -4
View File
@@ -1,6 +1,6 @@
{
"name": "@npmcli/map-workspaces",
"version": "3.0.4",
"version": "3.0.6",
"main": "lib/index.js",
"files": [
"bin/",
@@ -25,7 +25,7 @@
"author": "GitHub Inc.",
"license": "ISC",
"scripts": {
"lint": "eslint \"**/*.js\"",
"lint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"",
"pretest": "npm run lint",
"test": "tap",
"snap": "tap",
@@ -43,7 +43,7 @@
},
"devDependencies": {
"@npmcli/eslint-config": "^4.0.0",
"@npmcli/template-oss": "4.14.1",
"@npmcli/template-oss": "4.21.3",
"tap": "^16.0.1"
},
"dependencies": {
@@ -54,7 +54,7 @@
},
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "4.14.1",
"version": "4.21.3",
"publish": "true"
}
}
+39 -14
View File
@@ -1,12 +1,30 @@
const semver = require('semver')
const valid = require('semver/functions/valid')
const clean = require('semver/functions/clean')
const fs = require('fs/promises')
const { glob } = require('glob')
const legacyFixer = require('normalize-package-data/lib/fixer.js')
const legacyMakeWarning = require('normalize-package-data/lib/make_warning.js')
const path = require('path')
const log = require('proc-log')
const git = require('@npmcli/git')
const hostedGitInfo = require('hosted-git-info')
/**
* @type {import('hosted-git-info')}
*/
let _hostedGitInfo
function lazyHostedGitInfo () {
if (!_hostedGitInfo) {
_hostedGitInfo = require('hosted-git-info')
}
return _hostedGitInfo
}
/**
* @type {import('glob').glob}
*/
let _glob
function lazyLoadGlob () {
if (!_glob) {
_glob = require('glob').glob
}
return _glob
}
// used to be npm-normalize-package-bin
function normalizePackageBin (pkg, changes) {
@@ -130,10 +148,10 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
if (!data.version) {
data.version = ''
} else {
if (!semver.valid(data.version, loose)) {
if (!valid(data.version, loose)) {
throw new Error(`Invalid version: "${data.version}"`)
}
const version = semver.clean(data.version, loose)
const version = clean(data.version, loose)
if (version !== data.version) {
changes?.push(`"version" was cleaned and set to "${version}"`)
data.version = version
@@ -208,7 +226,7 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
// add "install" attribute if any "*.gyp" files exist
if (steps.includes('gypfile')) {
if (!scripts.install && !scripts.preinstall && data.gypfile !== false) {
const files = await glob('*.gyp', { cwd: pkg.path })
const files = await lazyLoadGlob()('*.gyp', { cwd: pkg.path })
if (files.length) {
scripts.install = 'node-gyp rebuild'
data.scripts = scripts
@@ -275,7 +293,11 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
// populate "readme" attribute
if (steps.includes('readme') && !data.readme) {
const mdre = /\.m?a?r?k?d?o?w?n?$/i
const files = await glob('{README,README.*}', { cwd: pkg.path, nocase: true, mark: true })
const files = await lazyLoadGlob()('{README,README.*}', {
cwd: pkg.path,
nocase: true,
mark: true,
})
let readmeFile
for (const file of files) {
// don't accept directories.
@@ -306,7 +328,7 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
if (steps.includes('mans') && !data.man && data.directories?.man) {
const manDir = data.directories.man
const cwd = path.resolve(pkg.path, manDir)
const files = await glob('**/*.[0-9]', { cwd })
const files = await lazyLoadGlob()('**/*.[0-9]', { cwd })
data.man = files.map(man =>
path.relative(pkg.path, path.join(cwd, man)).split(path.sep).join('/')
)
@@ -319,7 +341,7 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
// expand "directories.bin"
if (steps.includes('binDir') && data.directories?.bin && !data.bin) {
const binsDir = path.resolve(pkg.path, path.join('.', path.join('/', data.directories.bin)))
const bins = await glob('**', { cwd: binsDir })
const bins = await lazyLoadGlob()('**', { cwd: binsDir })
data.bin = bins.reduce((acc, binFile) => {
if (binFile && !binFile.startsWith('.')) {
const binName = path.basename(binFile)
@@ -333,6 +355,7 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
// populate "gitHead" attribute
if (steps.includes('gitHead') && !data.gitHead) {
const git = require('@npmcli/git')
const gitRoot = await git.find({ cwd: pkg.path, root })
let head
if (gitRoot) {
@@ -446,7 +469,7 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
}
}
if (data.repository.url) {
const hosted = hostedGitInfo.fromUrl(data.repository.url)
const hosted = lazyHostedGitInfo().fromUrl(data.repository.url)
let r
if (hosted) {
if (hosted.getDefaultRepresentation() === 'shortcut') {
@@ -506,7 +529,7 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
changes?.push(`Removed invalid "${deps}.${d}"`)
delete data[deps][d]
}
const hosted = hostedGitInfo.fromUrl(data[deps][d])?.toString()
const hosted = lazyHostedGitInfo().fromUrl(data[deps][d])?.toString()
if (hosted && hosted !== data[deps][d]) {
changes?.push(`Normalized git reference to "${deps}.${d}"`)
data[deps][d] = hosted.toString()
@@ -518,6 +541,8 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
}
if (steps.includes('normalizeData')) {
const legacyFixer = require('normalize-package-data/lib/fixer.js')
const legacyMakeWarning = require('normalize-package-data/lib/make_warning.js')
legacyFixer.warn = function () {
changes?.push(legacyMakeWarning.apply(null, arguments))
}
+6 -12
View File
@@ -1,6 +1,6 @@
{
"name": "@npmcli/package-json",
"version": "5.0.0",
"version": "5.0.2",
"description": "Programmatic API to update package.json",
"main": "lib/index.js",
"files": [
@@ -10,7 +10,7 @@
"scripts": {
"snap": "tap",
"test": "tap",
"lint": "eslint \"**/*.js\"",
"lint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"",
"lintfix": "npm run lint -- --fix",
"posttest": "npm run lint",
"postsnap": "npm run lintfix --",
@@ -25,8 +25,8 @@
"license": "ISC",
"devDependencies": {
"@npmcli/eslint-config": "^4.0.0",
"@npmcli/template-oss": "4.18.0",
"read-package-json": "^6.0.4",
"@npmcli/template-oss": "4.21.3",
"read-package-json": "^7.0.0",
"read-package-json-fast": "^3.0.2",
"tap": "^16.0.1"
},
@@ -48,14 +48,8 @@
},
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "4.18.0",
"publish": "true",
"ciVersions": [
"16.14.0",
"16.x",
"18.0.0",
"18.x"
]
"version": "4.21.3",
"publish": "true"
},
"tap": {
"nyc-arg": [
+20 -8
View File
@@ -21,7 +21,9 @@ const bundle_1 = require("./bundle");
// Message signature bundle - $case: 'messageSignature'
function toMessageSignatureBundle(options) {
return {
mediaType: bundle_1.BUNDLE_V02_MEDIA_TYPE,
mediaType: options.singleCertificate
? bundle_1.BUNDLE_V03_MEDIA_TYPE
: bundle_1.BUNDLE_V02_MEDIA_TYPE,
content: {
$case: 'messageSignature',
messageSignature: {
@@ -39,7 +41,9 @@ exports.toMessageSignatureBundle = toMessageSignatureBundle;
// DSSE envelope bundle - $case: 'dsseEnvelope'
function toDSSEBundle(options) {
return {
mediaType: bundle_1.BUNDLE_V02_MEDIA_TYPE,
mediaType: options.singleCertificate
? bundle_1.BUNDLE_V03_MEDIA_TYPE
: bundle_1.BUNDLE_V02_MEDIA_TYPE,
content: {
$case: 'dsseEnvelope',
dsseEnvelope: toEnvelope(options),
@@ -71,12 +75,20 @@ function toVerificationMaterial(options) {
}
function toKeyContent(options) {
if (options.certificate) {
return {
$case: 'x509CertificateChain',
x509CertificateChain: {
certificates: [{ rawBytes: options.certificate }],
},
};
if (options.singleCertificate) {
return {
$case: 'certificate',
certificate: { rawBytes: options.certificate },
};
}
else {
return {
$case: 'x509CertificateChain',
x509CertificateChain: {
certificates: [{ rawBytes: options.certificate }],
},
};
}
}
else {
return {
+3 -2
View File
@@ -1,9 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isBundleWithDsseEnvelope = exports.isBundleWithMessageSignature = exports.isBundleWithPublicKey = exports.isBundleWithCertificateChain = exports.BUNDLE_V03_MEDIA_TYPE = exports.BUNDLE_V02_MEDIA_TYPE = exports.BUNDLE_V01_MEDIA_TYPE = void 0;
exports.isBundleWithDsseEnvelope = exports.isBundleWithMessageSignature = exports.isBundleWithPublicKey = exports.isBundleWithCertificateChain = exports.BUNDLE_V03_MEDIA_TYPE = exports.BUNDLE_V03_LEGACY_MEDIA_TYPE = exports.BUNDLE_V02_MEDIA_TYPE = exports.BUNDLE_V01_MEDIA_TYPE = void 0;
exports.BUNDLE_V01_MEDIA_TYPE = 'application/vnd.dev.sigstore.bundle+json;version=0.1';
exports.BUNDLE_V02_MEDIA_TYPE = 'application/vnd.dev.sigstore.bundle+json;version=0.2';
exports.BUNDLE_V03_MEDIA_TYPE = 'application/vnd.dev.sigstore.bundle+json;version=0.3';
exports.BUNDLE_V03_LEGACY_MEDIA_TYPE = 'application/vnd.dev.sigstore.bundle+json;version=0.3';
exports.BUNDLE_V03_MEDIA_TYPE = 'application/vnd.dev.sigstore.bundle.v0.3+json';
// Type guards for bundle variants.
function isBundleWithCertificateChain(b) {
return b.verificationMaterial.content.$case === 'x509CertificateChain';
+2 -1
View File
@@ -1,6 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isBundleV01 = exports.assertBundleV02 = exports.assertBundleV01 = exports.assertBundleLatest = exports.assertBundle = exports.envelopeToJSON = exports.envelopeFromJSON = exports.bundleToJSON = exports.bundleFromJSON = exports.ValidationError = exports.isBundleWithPublicKey = exports.isBundleWithMessageSignature = exports.isBundleWithDsseEnvelope = exports.isBundleWithCertificateChain = exports.BUNDLE_V03_MEDIA_TYPE = exports.BUNDLE_V02_MEDIA_TYPE = exports.BUNDLE_V01_MEDIA_TYPE = exports.toMessageSignatureBundle = exports.toDSSEBundle = void 0;
exports.isBundleV01 = exports.assertBundleV02 = exports.assertBundleV01 = exports.assertBundleLatest = exports.assertBundle = exports.envelopeToJSON = exports.envelopeFromJSON = exports.bundleToJSON = exports.bundleFromJSON = exports.ValidationError = exports.isBundleWithPublicKey = exports.isBundleWithMessageSignature = exports.isBundleWithDsseEnvelope = exports.isBundleWithCertificateChain = exports.BUNDLE_V03_MEDIA_TYPE = exports.BUNDLE_V03_LEGACY_MEDIA_TYPE = exports.BUNDLE_V02_MEDIA_TYPE = exports.BUNDLE_V01_MEDIA_TYPE = exports.toMessageSignatureBundle = exports.toDSSEBundle = void 0;
/*
Copyright 2023 The Sigstore Authors.
@@ -22,6 +22,7 @@ Object.defineProperty(exports, "toMessageSignatureBundle", { enumerable: true, g
var bundle_1 = require("./bundle");
Object.defineProperty(exports, "BUNDLE_V01_MEDIA_TYPE", { enumerable: true, get: function () { return bundle_1.BUNDLE_V01_MEDIA_TYPE; } });
Object.defineProperty(exports, "BUNDLE_V02_MEDIA_TYPE", { enumerable: true, get: function () { return bundle_1.BUNDLE_V02_MEDIA_TYPE; } });
Object.defineProperty(exports, "BUNDLE_V03_LEGACY_MEDIA_TYPE", { enumerable: true, get: function () { return bundle_1.BUNDLE_V03_LEGACY_MEDIA_TYPE; } });
Object.defineProperty(exports, "BUNDLE_V03_MEDIA_TYPE", { enumerable: true, get: function () { return bundle_1.BUNDLE_V03_MEDIA_TYPE; } });
Object.defineProperty(exports, "isBundleWithCertificateChain", { enumerable: true, get: function () { return bundle_1.isBundleWithCertificateChain; } });
Object.defineProperty(exports, "isBundleWithDsseEnvelope", { enumerable: true, get: function () { return bundle_1.isBundleWithDsseEnvelope; } });
+2 -1
View File
@@ -74,7 +74,8 @@ function validateBundleBase(b) {
const invalidValues = [];
// Media type validation
if (b.mediaType === undefined ||
!b.mediaType.startsWith('application/vnd.dev.sigstore.bundle+json;version=')) {
(!b.mediaType.match(/^application\/vnd\.dev\.sigstore\.bundle\+json;version=\d\.\d/) &&
!b.mediaType.match(/^application\/vnd\.dev\.sigstore\.bundle\.v\d\.\d\+json/))) {
invalidValues.push('mediaType');
}
// Content-related validation
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@sigstore/bundle",
"version": "2.2.0",
"version": "2.3.1",
"description": "Sigstore bundle type",
"main": "dist/index.js",
"types": "dist/index.d.ts",
@@ -27,7 +27,7 @@
"provenance": true
},
"dependencies": {
"@sigstore/protobuf-specs": "^0.3.0"
"@sigstore/protobuf-specs": "^0.3.1"
},
"engines": {
"node": "^16.14.0 || >=18.0.0"
+2 -2
View File
@@ -21,12 +21,12 @@ limitations under the License.
*/
const crypto_1 = __importDefault(require("crypto"));
const SHA256_ALGORITHM = 'sha256';
function createPublicKey(key) {
function createPublicKey(key, type = 'spki') {
if (typeof key === 'string') {
return crypto_1.default.createPublicKey(key);
}
else {
return crypto_1.default.createPublicKey({ key, format: 'der', type: 'spki' });
return crypto_1.default.createPublicKey({ key, format: 'der', type: type });
}
}
exports.createPublicKey = createPublicKey;
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@sigstore/core",
"version": "1.0.0",
"version": "1.1.0",
"description": "Base library for Sigstore",
"main": "dist/index.js",
"types": "dist/index.d.ts",
@@ -1,6 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TrustedRoot = exports.CertificateAuthority = exports.TransparencyLogInstance = void 0;
exports.ClientTrustConfig = exports.SigningConfig = exports.TrustedRoot = exports.CertificateAuthority = exports.TransparencyLogInstance = void 0;
/* eslint-disable */
const sigstore_common_1 = require("./sigstore_common");
function createBaseTransparencyLogInstance() {
@@ -98,6 +98,58 @@ exports.TrustedRoot = {
return obj;
},
};
function createBaseSigningConfig() {
return { caUrl: "", oidcUrl: "", tlogUrls: [], tsaUrls: [] };
}
exports.SigningConfig = {
fromJSON(object) {
return {
caUrl: isSet(object.caUrl) ? String(object.caUrl) : "",
oidcUrl: isSet(object.oidcUrl) ? String(object.oidcUrl) : "",
tlogUrls: Array.isArray(object?.tlogUrls) ? object.tlogUrls.map((e) => String(e)) : [],
tsaUrls: Array.isArray(object?.tsaUrls) ? object.tsaUrls.map((e) => String(e)) : [],
};
},
toJSON(message) {
const obj = {};
message.caUrl !== undefined && (obj.caUrl = message.caUrl);
message.oidcUrl !== undefined && (obj.oidcUrl = message.oidcUrl);
if (message.tlogUrls) {
obj.tlogUrls = message.tlogUrls.map((e) => e);
}
else {
obj.tlogUrls = [];
}
if (message.tsaUrls) {
obj.tsaUrls = message.tsaUrls.map((e) => e);
}
else {
obj.tsaUrls = [];
}
return obj;
},
};
function createBaseClientTrustConfig() {
return { mediaType: "", trustedRoot: undefined, signingConfig: undefined };
}
exports.ClientTrustConfig = {
fromJSON(object) {
return {
mediaType: isSet(object.mediaType) ? String(object.mediaType) : "",
trustedRoot: isSet(object.trustedRoot) ? exports.TrustedRoot.fromJSON(object.trustedRoot) : undefined,
signingConfig: isSet(object.signingConfig) ? exports.SigningConfig.fromJSON(object.signingConfig) : undefined,
};
},
toJSON(message) {
const obj = {};
message.mediaType !== undefined && (obj.mediaType = message.mediaType);
message.trustedRoot !== undefined &&
(obj.trustedRoot = message.trustedRoot ? exports.TrustedRoot.toJSON(message.trustedRoot) : undefined);
message.signingConfig !== undefined &&
(obj.signingConfig = message.signingConfig ? exports.SigningConfig.toJSON(message.signingConfig) : undefined);
return obj;
},
};
function isSet(value) {
return value !== null && value !== undefined;
}
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@sigstore/protobuf-specs",
"version": "0.3.0",
"version": "0.3.1",
"description": "code-signing for npm packages",
"main": "dist/index.js",
"types": "dist/index.d.ts",
@@ -21,11 +21,11 @@
},
"homepage": "https://github.com/sigstore/protobuf-specs#readme",
"devDependencies": {
"@tsconfig/node14": "^1.0.3",
"@tsconfig/node16": "^16.1.1",
"@types/node": "^18.14.0",
"typescript": "^4.9.5"
},
"engines": {
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
"node": "^16.14.0 || >=18.0.0"
}
}
+2 -1
View File
@@ -56,7 +56,7 @@ function toMessageSignatureBundle(artifact, signature) {
}
exports.toMessageSignatureBundle = toMessageSignatureBundle;
// DSSE envelope bundle - $case: 'dsseEnvelope'
function toDSSEBundle(artifact, signature) {
function toDSSEBundle(artifact, signature, singleCertificate) {
return sigstore.toDSSEBundle({
artifact: artifact.data,
artifactType: artifact.type,
@@ -65,6 +65,7 @@ function toDSSEBundle(artifact, signature) {
? util_1.pem.toDER(signature.key.certificate)
: undefined,
keyHint: signature.key.$case === 'publicKey' ? signature.key.hint : undefined,
singleCertificate,
});
}
exports.toDSSEBundle = toDSSEBundle;
+2 -1
View File
@@ -23,6 +23,7 @@ const bundle_1 = require("./bundle");
class DSSEBundleBuilder extends base_1.BaseBundleBuilder {
constructor(options) {
super(options);
this.singleCertificate = options.singleCertificate ?? false;
}
// DSSE requires the artifact to be pre-encoded with the payload type
// before the signature is generated.
@@ -32,7 +33,7 @@ class DSSEBundleBuilder extends base_1.BaseBundleBuilder {
}
// Packages the artifact and signature into a DSSE bundle
async package(artifact, signature) {
return (0, bundle_1.toDSSEBundle)(artifactDefaults(artifact), signature);
return (0, bundle_1.toDSSEBundle)(artifactDefaults(artifact), signature, this.singleCertificate);
}
}
exports.DSSEBundleBuilder = DSSEBundleBuilder;
+4 -4
View File
@@ -1,6 +1,6 @@
{
"name": "@sigstore/sign",
"version": "2.2.3",
"version": "2.3.0",
"description": "Sigstore signing library",
"main": "dist/index.js",
"types": "dist/index.d.ts",
@@ -27,14 +27,14 @@
},
"devDependencies": {
"@sigstore/jest": "^0.0.0",
"@sigstore/mock": "^0.6.5",
"@sigstore/mock": "^0.7.0",
"@sigstore/rekor-types": "^2.0.0",
"@types/make-fetch-happen": "^10.0.4"
},
"dependencies": {
"@sigstore/bundle": "^2.2.0",
"@sigstore/bundle": "^2.3.0",
"@sigstore/core": "^1.0.0",
"@sigstore/protobuf-specs": "^0.3.0",
"@sigstore/protobuf-specs": "^0.3.1",
"make-fetch-happen": "^13.0.0"
},
"engines": {
+2 -1
View File
@@ -42,11 +42,12 @@ function verifyIntoto002TLogBody(tlogEntry, content) {
// Signature is double-base64-encoded in the tlog entry
const tlogSig = base64Decode(tlogEntry.spec.content.envelope.signatures[0].sig);
// Ensure that the signature in the bundle's DSSE matches tlog entry
if (!content.compareSignature(Buffer.from(tlogSig, 'base64')))
if (!content.compareSignature(Buffer.from(tlogSig, 'base64'))) {
throw new error_1.VerificationError({
code: 'TLOG_BODY_ERROR',
message: 'tlog entry signature mismatch',
});
}
// Ensure the digest of the bundle's DSSE payload matches the digest in the
// tlog entry
const tlogHash = tlogEntry.spec.content.payloadHash?.value || '';
+10 -1
View File
@@ -17,6 +17,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
const core_1 = require("@sigstore/core");
const protobuf_specs_1 = require("@sigstore/protobuf-specs");
const error_1 = require("../error");
const BEGINNING_OF_TIME = new Date(0);
const END_OF_TIME = new Date(8640000000000000);
@@ -35,9 +36,17 @@ function toTrustMaterial(root, keys) {
}
exports.toTrustMaterial = toTrustMaterial;
function createTLogAuthority(tlogInstance) {
const keyDetails = tlogInstance.publicKey.keyDetails;
const keyType = keyDetails === protobuf_specs_1.PublicKeyDetails.PKCS1_RSA_PKCS1V5 ||
keyDetails === protobuf_specs_1.PublicKeyDetails.PKIX_RSA_PKCS1V5 ||
keyDetails === protobuf_specs_1.PublicKeyDetails.PKIX_RSA_PKCS1V15_2048_SHA256 ||
keyDetails === protobuf_specs_1.PublicKeyDetails.PKIX_RSA_PKCS1V15_3072_SHA256 ||
keyDetails === protobuf_specs_1.PublicKeyDetails.PKIX_RSA_PKCS1V15_4096_SHA256
? 'pkcs1'
: 'spki';
return {
logID: tlogInstance.logId.keyId,
publicKey: core_1.crypto.createPublicKey(tlogInstance.publicKey.rawBytes),
publicKey: core_1.crypto.createPublicKey(tlogInstance.publicKey.rawBytes, keyType),
validFor: {
start: tlogInstance.publicKey.validFor?.start || BEGINNING_OF_TIME,
end: tlogInstance.publicKey.validFor?.end || END_OF_TIME,
+4 -4
View File
@@ -1,6 +1,6 @@
{
"name": "@sigstore/verify",
"version": "1.1.0",
"version": "1.2.0",
"description": "Verification of Sigstore signatures",
"main": "dist/index.js",
"types": "dist/index.d.ts",
@@ -26,9 +26,9 @@
"provenance": true
},
"dependencies": {
"@sigstore/protobuf-specs": "^0.3.0",
"@sigstore/bundle": "^2.2.0",
"@sigstore/core": "^1.0.0"
"@sigstore/protobuf-specs": "^0.3.1",
"@sigstore/bundle": "^2.3.1",
"@sigstore/core": "^1.1.0"
},
"engines": {
"node": "^16.14.0 || >=18.0.0"
+3 -3
View File
@@ -1,6 +1,6 @@
'use strict'
const semver = require('semver')
const satisfies = require('semver/functions/satisfies')
const permanentModules = [
'assert',
@@ -60,7 +60,7 @@ module.exports = ({ version = process.version, experimental = false } = {}) => {
const builtins = [...permanentModules]
for (const [name, semverRange] of Object.entries(versionLockedModules)) {
if (version === '*' || semver.satisfies(version, semverRange)) {
if (version === '*' || satisfies(version, semverRange)) {
builtins.push(name)
}
}
@@ -69,7 +69,7 @@ module.exports = ({ version = process.version, experimental = false } = {}) => {
for (const [name, semverRange] of Object.entries(experimentalModules)) {
if (
!builtins.includes(name) &&
(version === '*' || semver.satisfies(version, semverRange))
(version === '*' || satisfies(version, semverRange))
) {
builtins.push(name)
}
+4 -5
View File
@@ -1,20 +1,19 @@
{
"name": "builtins",
"version": "5.0.1",
"version": "5.1.0",
"description": "List of node.js builtin modules",
"repository": "juliangruber/builtins",
"license": "MIT",
"main": "index.js",
"files": [],
"scripts": {
"test": "prettier-standard && standard && node-core-test"
"test": "standard --fix && node--test"
},
"dependencies": {
"semver": "^7.0.0"
},
"devDependencies": {
"node-core-test": "^1.4.0",
"prettier-standard": "^15.0.1",
"standard": "^14.3.4"
"standard": "^17.0.0",
"test": "^3.0.0"
}
}
+8 -7
View File
@@ -1,6 +1,6 @@
{
"name": "cidr-regex",
"version": "4.0.3",
"version": "4.0.5",
"description": "Regular expression for matching IP addresses in CIDR notation",
"author": "silverwind <me@silverwind.io>",
"contributors": [
@@ -22,11 +22,12 @@
"ip-regex": "^5.0.0"
},
"devDependencies": {
"eslint": "8.37.0",
"eslint-config-silverwind": "65.1.3",
"tsd": "0.28.1",
"updates": "13.2.9",
"versions": "10.4.2",
"vitest": "0.29.8"
"eslint": "8.57.0",
"eslint-config-silverwind": "83.0.1",
"tsd": "0.31.0",
"updates": "16.0.0",
"versions": "12.0.1",
"vitest": "1.4.0",
"vitest-config-silverwind": "7.0.3"
}
}
+5 -2
View File
@@ -1,6 +1,6 @@
{
"name": "hasown",
"version": "2.0.1",
"version": "2.0.2",
"description": "A robust, ES3 compatible, \"has own property\" predicate.",
"main": "index.js",
"exports": {
@@ -18,6 +18,7 @@
"postlint": "npm run tsc",
"pretest": "npm run lint",
"tsc": "tsc -p .",
"posttsc": "attw -P",
"tests-only": "nyc tape 'test/**/*.js'",
"test": "npm run tests-only",
"posttest": "aud --production",
@@ -50,7 +51,9 @@
"function-bind": "^1.1.2"
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.15.1",
"@ljharb/eslint-config": "^21.1.0",
"@ljharb/tsconfig": "^0.2.0",
"@types/function-bind": "^1.1.10",
"@types/mock-property": "^1.0.2",
"@types/tape": "^5.6.4",
@@ -63,7 +66,7 @@
"npmignore": "^0.3.1",
"nyc": "^10.3.2",
"safe-publish-latest": "^2.0.0",
"tape": "^5.7.4",
"tape": "^5.7.5",
"typescript": "next"
},
"engines": {
+3 -46
View File
@@ -1,49 +1,6 @@
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig to read more about this file */
/* Projects */
/* Language and Environment */
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
"useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
/* Modules */
"module": "commonjs", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
"typeRoots": ["types"], /* Specify multiple folders that act like './node_modules/@types'. */
"resolveJsonModule": true, /* Enable importing .json files. */
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
/* JavaScript Support */
"allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
"checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
"maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
/* Emit */
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
"declarationMap": true, /* Create sourcemaps for d.ts files. */
"noEmit": true, /* Disable emitting files from a compilation. */
/* Interop Constraints */
"allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
/* Completeness */
//"skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"extends": "@ljharb/tsconfig",
"exclude": [
"coverage"
]
"coverage",
],
}
-22
View File
@@ -1,22 +0,0 @@
Copyright (c) silverwind
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+9 -8
View File
@@ -1,6 +1,6 @@
{
"name": "is-cidr",
"version": "5.0.3",
"version": "5.0.5",
"description": "Check if a string is an IP address in CIDR notation",
"author": "silverwind <me@silverwind.io>",
"contributors": [
@@ -19,14 +19,15 @@
"index.d.ts"
],
"dependencies": {
"cidr-regex": "4.0.3"
"cidr-regex": "^4.0.4"
},
"devDependencies": {
"eslint": "8.37.0",
"eslint-config-silverwind": "65.1.3",
"tsd": "0.28.1",
"updates": "13.2.9",
"versions": "10.4.2",
"vitest": "0.29.8"
"eslint": "8.57.0",
"eslint-config-silverwind": "83.0.1",
"tsd": "0.31.0",
"updates": "16.0.0",
"versions": "12.0.1",
"vitest": "1.4.0",
"vitest-config-silverwind": "7.0.3"
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "libnpmdiff",
"version": "6.0.8",
"version": "6.0.9",
"description": "The registry diff",
"repository": {
"type": "git",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "libnpmexec",
"version": "7.0.9",
"version": "7.0.10",
"files": [
"bin/",
"lib/"
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "libnpmfund",
"version": "5.0.6",
"version": "5.0.7",
"main": "lib/index.js",
"files": [
"bin/",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "libnpmpack",
"version": "6.0.8",
"version": "6.0.9",
"description": "Programmatic API for the bits behind npm pack",
"author": "GitHub Inc.",
"main": "lib/index.js",
+3 -2
View File
@@ -1,6 +1,6 @@
{
"name": "postcss-selector-parser",
"version": "6.0.15",
"version": "6.0.16",
"devDependencies": {
"@babel/cli": "^7.11.6",
"@babel/core": "^7.11.6",
@@ -33,7 +33,8 @@
"!**/__tests__"
],
"scripts": {
"pretest": "eslint src && tsc --noEmit postcss-selector-parser.d.ts",
"typecheck": "tsc --noEmit --strict postcss-selector-parser.d.ts postcss-selector-parser.test.ts",
"pretest": "eslint src && npm run typecheck",
"prepare": "del-cli dist && BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/",
"lintfix": "eslint --fix src",
"report": "nyc report --reporter=html",
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "sigstore",
"version": "2.2.2",
"version": "2.3.0",
"description": "code-signing for npm packages",
"main": "dist/index.js",
"types": "dist/index.d.ts",
@@ -29,17 +29,17 @@
"devDependencies": {
"@sigstore/rekor-types": "^2.0.0",
"@sigstore/jest": "^0.0.0",
"@sigstore/mock": "^0.6.5",
"@sigstore/mock": "^0.7.0",
"@tufjs/repo-mock": "^2.0.0",
"@types/make-fetch-happen": "^10.0.4"
},
"dependencies": {
"@sigstore/bundle": "^2.2.0",
"@sigstore/bundle": "^2.3.1",
"@sigstore/core": "^1.0.0",
"@sigstore/protobuf-specs": "^0.3.0",
"@sigstore/sign": "^2.2.3",
"@sigstore/protobuf-specs": "^0.3.1",
"@sigstore/sign": "^2.3.0",
"@sigstore/tuf": "^2.3.1",
"@sigstore/verify": "^1.1.0"
"@sigstore/verify": "^1.2.0"
},
"engines": {
"node": "^16.14.0 || >=18.0.0"
+22
View File
@@ -0,0 +1,22 @@
(The MIT License)
Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+4
View File
@@ -94,6 +94,7 @@ class SocksProxyAgent extends agent_base_1.Agent {
this.shouldLookup = lookup;
this.proxy = proxy;
this.timeout = opts?.timeout ?? null;
this.socketOptions = opts?.socketOptions ?? null;
}
/**
* Initiates a SOCKS connection to the specified SOCKS proxy server,
@@ -128,6 +129,9 @@ class SocksProxyAgent extends agent_base_1.Agent {
},
command: 'connect',
timeout: timeout ?? undefined,
// @ts-expect-error the type supplied by socks for socket_options is wider
// than necessary since socks will always override the host and port
socket_options: this.socketOptions ?? undefined,
};
const cleanup = (tlsSocket) => {
req.destroy();
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "socks-proxy-agent",
"version": "8.0.2",
"version": "8.0.3",
"description": "A SOCKS proxy `http.Agent` implementation for HTTP and HTTPS",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
@@ -107,7 +107,7 @@
"socks5h"
],
"dependencies": {
"agent-base": "^7.0.2",
"agent-base": "^7.1.1",
"debug": "^4.3.4",
"socks": "^2.7.1"
},
+5 -1
View File
@@ -152,7 +152,11 @@ function ipToBuffer(ip) {
else if (net.isIPv6(ip)) {
// Handle IPv6 addresses
const address = new ip_address_1.Address6(ip);
return Buffer.from(address.toByteArray());
return Buffer.from(address
.canonicalForm()
.split(':')
.map((segment) => segment.padStart(4, '0'))
.join(''), 'hex');
}
else {
throw new Error('Invalid IP address format');
+4 -3
View File
@@ -1,7 +1,7 @@
{
"name": "socks",
"private": false,
"version": "2.8.0",
"version": "2.8.3",
"description": "Fully featured SOCKS proxy client supporting SOCKSv4, SOCKSv4a, and SOCKSv5. Includes Bind and Associate functionality.",
"main": "build/index.js",
"typings": "typings/index.d.ts",
@@ -23,7 +23,7 @@
"socks5"
],
"engines": {
"node": ">= 16.0.0",
"node": ">= 10.0.0",
"npm": ">= 3.0.0"
},
"author": "Josh Glazebrook",
@@ -52,6 +52,7 @@
"test": "NODE_ENV=test mocha --recursive --require ts-node/register test/**/*.ts",
"prettier": "prettier --write ./src/**/*.ts --config .prettierrc.yaml",
"lint": "eslint 'src/**/*.ts'",
"build": "rm -rf build typings && prettier --write ./src/**/*.ts --config .prettierrc.yaml && tsc -p ."
"build": "rm -rf build typings && prettier --write ./src/**/*.ts --config .prettierrc.yaml && tsc -p .",
"build-raw": "rm -rf build typings && tsc -p ."
}
}
@@ -0,0 +1,4 @@
C. Scott Ananian <cscott@cscott.net> (http://cscott.net)
Kyle E. Mitchell <kyle@kemitchell.com> (https://kemitchell.com)
Shinnosuke Watanabe <snnskwtnb@gmail.com>
Antoine Motet <antoine.motet@gmail.com>
@@ -0,0 +1,22 @@
The MIT License
Copyright (c) 2015 Kyle E. Mitchell & other authors listed in AUTHORS
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,8 @@
'use strict'
var scan = require('./scan')
var parse = require('./parse')
module.exports = function (source) {
return parse(scan(source))
}
@@ -0,0 +1,39 @@
{
"name": "spdx-expression-parse",
"description": "parse SPDX license expressions",
"version": "3.0.1",
"author": "Kyle E. Mitchell <kyle@kemitchell.com> (https://kemitchell.com)",
"files": [
"AUTHORS",
"index.js",
"parse.js",
"scan.js"
],
"dependencies": {
"spdx-exceptions": "^2.1.0",
"spdx-license-ids": "^3.0.0"
},
"devDependencies": {
"defence-cli": "^3.0.1",
"replace-require-self": "^1.0.0",
"standard": "^14.1.0"
},
"keywords": [
"SPDX",
"law",
"legal",
"license",
"metadata",
"package",
"package.json",
"standards"
],
"license": "MIT",
"repository": "jslicense/spdx-expression-parse.js",
"scripts": {
"lint": "standard",
"test:readme": "defence -i javascript README.md | replace-require-self | node",
"test:suite": "node test.js",
"test": "npm run test:suite && npm run test:readme"
}
}
@@ -0,0 +1,138 @@
'use strict'
// The ABNF grammar in the spec is totally ambiguous.
//
// This parser follows the operator precedence defined in the
// `Order of Precedence and Parentheses` section.
module.exports = function (tokens) {
var index = 0
function hasMore () {
return index < tokens.length
}
function token () {
return hasMore() ? tokens[index] : null
}
function next () {
if (!hasMore()) {
throw new Error()
}
index++
}
function parseOperator (operator) {
var t = token()
if (t && t.type === 'OPERATOR' && operator === t.string) {
next()
return t.string
}
}
function parseWith () {
if (parseOperator('WITH')) {
var t = token()
if (t && t.type === 'EXCEPTION') {
next()
return t.string
}
throw new Error('Expected exception after `WITH`')
}
}
function parseLicenseRef () {
// TODO: Actually, everything is concatenated into one string
// for backward-compatibility but it could be better to return
// a nice structure.
var begin = index
var string = ''
var t = token()
if (t.type === 'DOCUMENTREF') {
next()
string += 'DocumentRef-' + t.string + ':'
if (!parseOperator(':')) {
throw new Error('Expected `:` after `DocumentRef-...`')
}
}
t = token()
if (t.type === 'LICENSEREF') {
next()
string += 'LicenseRef-' + t.string
return { license: string }
}
index = begin
}
function parseLicense () {
var t = token()
if (t && t.type === 'LICENSE') {
next()
var node = { license: t.string }
if (parseOperator('+')) {
node.plus = true
}
var exception = parseWith()
if (exception) {
node.exception = exception
}
return node
}
}
function parseParenthesizedExpression () {
var left = parseOperator('(')
if (!left) {
return
}
var expr = parseExpression()
if (!parseOperator(')')) {
throw new Error('Expected `)`')
}
return expr
}
function parseAtom () {
return (
parseParenthesizedExpression() ||
parseLicenseRef() ||
parseLicense()
)
}
function makeBinaryOpParser (operator, nextParser) {
return function parseBinaryOp () {
var left = nextParser()
if (!left) {
return
}
if (!parseOperator(operator)) {
return left
}
var right = parseBinaryOp()
if (!right) {
throw new Error('Expected expression')
}
return {
left: left,
conjunction: operator.toLowerCase(),
right: right
}
}
}
var parseAnd = makeBinaryOpParser('AND', parseAtom)
var parseExpression = makeBinaryOpParser('OR', parseAnd)
var node = parseExpression()
if (!node || hasMore()) {
throw new Error('Syntax error')
}
return node
}
@@ -0,0 +1,131 @@
'use strict'
var licenses = []
.concat(require('spdx-license-ids'))
.concat(require('spdx-license-ids/deprecated'))
var exceptions = require('spdx-exceptions')
module.exports = function (source) {
var index = 0
function hasMore () {
return index < source.length
}
// `value` can be a regexp or a string.
// If it is recognized, the matching source string is returned and
// the index is incremented. Otherwise `undefined` is returned.
function read (value) {
if (value instanceof RegExp) {
var chars = source.slice(index)
var match = chars.match(value)
if (match) {
index += match[0].length
return match[0]
}
} else {
if (source.indexOf(value, index) === index) {
index += value.length
return value
}
}
}
function skipWhitespace () {
read(/[ ]*/)
}
function operator () {
var string
var possibilities = ['WITH', 'AND', 'OR', '(', ')', ':', '+']
for (var i = 0; i < possibilities.length; i++) {
string = read(possibilities[i])
if (string) {
break
}
}
if (string === '+' && index > 1 && source[index - 2] === ' ') {
throw new Error('Space before `+`')
}
return string && {
type: 'OPERATOR',
string: string
}
}
function idstring () {
return read(/[A-Za-z0-9-.]+/)
}
function expectIdstring () {
var string = idstring()
if (!string) {
throw new Error('Expected idstring at offset ' + index)
}
return string
}
function documentRef () {
if (read('DocumentRef-')) {
var string = expectIdstring()
return { type: 'DOCUMENTREF', string: string }
}
}
function licenseRef () {
if (read('LicenseRef-')) {
var string = expectIdstring()
return { type: 'LICENSEREF', string: string }
}
}
function identifier () {
var begin = index
var string = idstring()
if (licenses.indexOf(string) !== -1) {
return {
type: 'LICENSE',
string: string
}
} else if (exceptions.indexOf(string) !== -1) {
return {
type: 'EXCEPTION',
string: string
}
}
index = begin
}
// Tries to read the next token. Returns `undefined` if no token is
// recognized.
function parseToken () {
// Ordering matters
return (
operator() ||
documentRef() ||
licenseRef() ||
identifier()
)
}
var tokens = []
while (hasMore()) {
skipWhitespace()
if (!hasMore()) {
break
}
var token = parseToken()
if (!token) {
throw new Error('Unexpected `' + source[index] +
'` at offset ' + index)
}
tokens.push(token)
}
return tokens
}
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "spdx-expression-parse",
"description": "parse SPDX license expressions",
"version": "3.0.1",
"version": "4.0.0",
"author": "Kyle E. Mitchell <kyle@kemitchell.com> (https://kemitchell.com)",
"files": [
"AUTHORS",
+2 -2
View File
@@ -37,7 +37,7 @@ module.exports = function (source) {
function operator () {
var string
var possibilities = ['WITH', 'AND', 'OR', '(', ')', ':', '+']
var possibilities = [/^WITH/i, /^AND/i, /^OR/i, '(', ')', ':', '+']
for (var i = 0; i < possibilities.length; i++) {
string = read(possibilities[i])
if (string) {
@@ -51,7 +51,7 @@ module.exports = function (source) {
return string && {
type: 'OPERATOR',
string: string
string: string.toUpperCase()
}
}
@@ -0,0 +1,4 @@
C. Scott Ananian <cscott@cscott.net> (http://cscott.net)
Kyle E. Mitchell <kyle@kemitchell.com> (https://kemitchell.com)
Shinnosuke Watanabe <snnskwtnb@gmail.com>
Antoine Motet <antoine.motet@gmail.com>
@@ -0,0 +1,22 @@
The MIT License
Copyright (c) 2015 Kyle E. Mitchell & other authors listed in AUTHORS
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,8 @@
'use strict'
var scan = require('./scan')
var parse = require('./parse')
module.exports = function (source) {
return parse(scan(source))
}
@@ -0,0 +1,39 @@
{
"name": "spdx-expression-parse",
"description": "parse SPDX license expressions",
"version": "3.0.1",
"author": "Kyle E. Mitchell <kyle@kemitchell.com> (https://kemitchell.com)",
"files": [
"AUTHORS",
"index.js",
"parse.js",
"scan.js"
],
"dependencies": {
"spdx-exceptions": "^2.1.0",
"spdx-license-ids": "^3.0.0"
},
"devDependencies": {
"defence-cli": "^3.0.1",
"replace-require-self": "^1.0.0",
"standard": "^14.1.0"
},
"keywords": [
"SPDX",
"law",
"legal",
"license",
"metadata",
"package",
"package.json",
"standards"
],
"license": "MIT",
"repository": "jslicense/spdx-expression-parse.js",
"scripts": {
"lint": "standard",
"test:readme": "defence -i javascript README.md | replace-require-self | node",
"test:suite": "node test.js",
"test": "npm run test:suite && npm run test:readme"
}
}
@@ -0,0 +1,138 @@
'use strict'
// The ABNF grammar in the spec is totally ambiguous.
//
// This parser follows the operator precedence defined in the
// `Order of Precedence and Parentheses` section.
module.exports = function (tokens) {
var index = 0
function hasMore () {
return index < tokens.length
}
function token () {
return hasMore() ? tokens[index] : null
}
function next () {
if (!hasMore()) {
throw new Error()
}
index++
}
function parseOperator (operator) {
var t = token()
if (t && t.type === 'OPERATOR' && operator === t.string) {
next()
return t.string
}
}
function parseWith () {
if (parseOperator('WITH')) {
var t = token()
if (t && t.type === 'EXCEPTION') {
next()
return t.string
}
throw new Error('Expected exception after `WITH`')
}
}
function parseLicenseRef () {
// TODO: Actually, everything is concatenated into one string
// for backward-compatibility but it could be better to return
// a nice structure.
var begin = index
var string = ''
var t = token()
if (t.type === 'DOCUMENTREF') {
next()
string += 'DocumentRef-' + t.string + ':'
if (!parseOperator(':')) {
throw new Error('Expected `:` after `DocumentRef-...`')
}
}
t = token()
if (t.type === 'LICENSEREF') {
next()
string += 'LicenseRef-' + t.string
return { license: string }
}
index = begin
}
function parseLicense () {
var t = token()
if (t && t.type === 'LICENSE') {
next()
var node = { license: t.string }
if (parseOperator('+')) {
node.plus = true
}
var exception = parseWith()
if (exception) {
node.exception = exception
}
return node
}
}
function parseParenthesizedExpression () {
var left = parseOperator('(')
if (!left) {
return
}
var expr = parseExpression()
if (!parseOperator(')')) {
throw new Error('Expected `)`')
}
return expr
}
function parseAtom () {
return (
parseParenthesizedExpression() ||
parseLicenseRef() ||
parseLicense()
)
}
function makeBinaryOpParser (operator, nextParser) {
return function parseBinaryOp () {
var left = nextParser()
if (!left) {
return
}
if (!parseOperator(operator)) {
return left
}
var right = parseBinaryOp()
if (!right) {
throw new Error('Expected expression')
}
return {
left: left,
conjunction: operator.toLowerCase(),
right: right
}
}
}
var parseAnd = makeBinaryOpParser('AND', parseAtom)
var parseExpression = makeBinaryOpParser('OR', parseAnd)
var node = parseExpression()
if (!node || hasMore()) {
throw new Error('Syntax error')
}
return node
}
@@ -0,0 +1,131 @@
'use strict'
var licenses = []
.concat(require('spdx-license-ids'))
.concat(require('spdx-license-ids/deprecated'))
var exceptions = require('spdx-exceptions')
module.exports = function (source) {
var index = 0
function hasMore () {
return index < source.length
}
// `value` can be a regexp or a string.
// If it is recognized, the matching source string is returned and
// the index is incremented. Otherwise `undefined` is returned.
function read (value) {
if (value instanceof RegExp) {
var chars = source.slice(index)
var match = chars.match(value)
if (match) {
index += match[0].length
return match[0]
}
} else {
if (source.indexOf(value, index) === index) {
index += value.length
return value
}
}
}
function skipWhitespace () {
read(/[ ]*/)
}
function operator () {
var string
var possibilities = ['WITH', 'AND', 'OR', '(', ')', ':', '+']
for (var i = 0; i < possibilities.length; i++) {
string = read(possibilities[i])
if (string) {
break
}
}
if (string === '+' && index > 1 && source[index - 2] === ' ') {
throw new Error('Space before `+`')
}
return string && {
type: 'OPERATOR',
string: string
}
}
function idstring () {
return read(/[A-Za-z0-9-.]+/)
}
function expectIdstring () {
var string = idstring()
if (!string) {
throw new Error('Expected idstring at offset ' + index)
}
return string
}
function documentRef () {
if (read('DocumentRef-')) {
var string = expectIdstring()
return { type: 'DOCUMENTREF', string: string }
}
}
function licenseRef () {
if (read('LicenseRef-')) {
var string = expectIdstring()
return { type: 'LICENSEREF', string: string }
}
}
function identifier () {
var begin = index
var string = idstring()
if (licenses.indexOf(string) !== -1) {
return {
type: 'LICENSE',
string: string
}
} else if (exceptions.indexOf(string) !== -1) {
return {
type: 'EXCEPTION',
string: string
}
}
index = begin
}
// Tries to read the next token. Returns `undefined` if no token is
// recognized.
function parseToken () {
// Ordering matters
return (
operator() ||
documentRef() ||
licenseRef() ||
identifier()
)
}
var tokens = []
while (hasMore()) {
skipWhitespace()
if (!hasMore()) {
break
}
var token = parseToken()
if (!token) {
throw new Error('Unexpected `' + source[index] +
'` at offset ' + index)
}
tokens.push(token)
}
return tokens
}
+6 -6
View File
@@ -1,5 +1,5 @@
{
"version": "10.5.1",
"version": "10.5.2",
"name": "npm",
"description": "a package manager for JavaScript",
"workspaces": [
@@ -55,8 +55,8 @@
"@npmcli/arborist": "^7.2.1",
"@npmcli/config": "^8.0.2",
"@npmcli/fs": "^3.1.0",
"@npmcli/map-workspaces": "^3.0.4",
"@npmcli/package-json": "^5.0.0",
"@npmcli/map-workspaces": "^3.0.6",
"@npmcli/package-json": "^5.0.2",
"@npmcli/promise-spawn": "^7.0.1",
"@npmcli/redact": "^1.1.0",
"@npmcli/run-script": "^7.0.4",
@@ -76,7 +76,7 @@
"hosted-git-info": "^7.0.1",
"ini": "^4.1.2",
"init-package-json": "^6.0.2",
"is-cidr": "^5.0.3",
"is-cidr": "^5.0.5",
"json-parse-even-better-errors": "^3.0.1",
"libnpmaccess": "^8.0.1",
"libnpmdiff": "^6.0.3",
@@ -112,7 +112,7 @@
"qrcode-terminal": "^0.12.0",
"read": "^3.0.1",
"semver": "^7.6.0",
"spdx-expression-parse": "^3.0.1",
"spdx-expression-parse": "^4.0.0",
"ssri": "^10.0.5",
"supports-color": "^9.4.0",
"tar": "^6.2.1",
@@ -199,7 +199,7 @@
"devDependencies": {
"@npmcli/docs": "^1.0.0",
"@npmcli/eslint-config": "^4.0.2",
"@npmcli/git": "^5.0.4",
"@npmcli/git": "^5.0.5",
"@npmcli/mock-globals": "^1.0.0",
"@npmcli/mock-registry": "^1.0.0",
"@npmcli/template-oss": "4.21.3",
@@ -34,8 +34,6 @@ exports[`test/lib/commands/config.js TAP config list --json > output matches sna
"color": true,
"commit-hooks": true,
"cpu": null,
"os": null,
"libc": null,
"depth": null,
"description": true,
"dev": false,
@@ -50,8 +48,8 @@ exports[`test/lib/commands/config.js TAP config list --json > output matches sna
"dry-run": false,
"editor": "{EDITOR}",
"engine-strict": false,
"expect-results": null,
"expect-result-count": null,
"expect-results": null,
"fetch-retries": 2,
"fetch-retry-factor": 10,
"fetch-retry-maxtimeout": 60000,
@@ -90,10 +88,9 @@ exports[`test/lib/commands/config.js TAP config list --json > output matches sna
"key": null,
"legacy-bundling": false,
"legacy-peer-deps": false,
"libc": null,
"link": false,
"local-address": null,
"sbom-format": null,
"sbom-type": "library",
"location": "user",
"lockfile-version": null,
"loglevel": "notice",
@@ -111,6 +108,7 @@ exports[`test/lib/commands/config.js TAP config list --json > output matches sna
"omit-lockfile-registry-resolved": false,
"only": null,
"optional": null,
"os": null,
"otp": null,
"package": [],
"package-lock": true,
@@ -138,6 +136,8 @@ exports[`test/lib/commands/config.js TAP config list --json > output matches sna
"save-peer": false,
"save-prefix": "^",
"save-prod": false,
"sbom-format": null,
"sbom-type": "library",
"scope": "",
"script-shell": null,
"searchexclude": "",
@@ -350,6 +350,10 @@ Array [
]
`
exports[`test/lib/commands/publish.js TAP prioritize CLI flags over publishConfig > new package version 1`] = `
+ test-package@1.0.0
`
exports[`test/lib/commands/publish.js TAP public access > must match snapshot 1`] = `
Array [
Array [
+10 -10
View File
@@ -2078,8 +2078,6 @@ Array [
"color",
"commit-hooks",
"cpu",
"os",
"libc",
"depth",
"description",
"dev",
@@ -2094,8 +2092,8 @@ Array [
"dry-run",
"editor",
"engine-strict",
"expect-results",
"expect-result-count",
"expect-results",
"fetch-retries",
"fetch-retry-factor",
"fetch-retry-maxtimeout",
@@ -2135,10 +2133,9 @@ Array [
"key",
"legacy-bundling",
"legacy-peer-deps",
"libc",
"link",
"local-address",
"sbom-format",
"sbom-type",
"location",
"lockfile-version",
"loglevel",
@@ -2154,6 +2151,7 @@ Array [
"omit-lockfile-registry-resolved",
"only",
"optional",
"os",
"otp",
"package",
"package-lock",
@@ -2182,6 +2180,8 @@ Array [
"save-peer",
"save-prefix",
"save-prod",
"sbom-format",
"sbom-type",
"scope",
"script-shell",
"searchexclude",
@@ -2238,8 +2238,6 @@ Array [
"color",
"commit-hooks",
"cpu",
"os",
"libc",
"depth",
"description",
"dev",
@@ -2281,9 +2279,8 @@ Array [
"key",
"legacy-bundling",
"legacy-peer-deps",
"libc",
"local-address",
"sbom-format",
"sbom-type",
"location",
"lockfile-version",
"loglevel",
@@ -2295,6 +2292,7 @@ Array [
"omit-lockfile-registry-resolved",
"only",
"optional",
"os",
"otp",
"package",
"package-lock",
@@ -2322,6 +2320,8 @@ Array [
"save-peer",
"save-prefix",
"save-prod",
"sbom-format",
"sbom-type",
"scope",
"script-shell",
"searchexclude",
@@ -2347,8 +2347,8 @@ Array [
exports[`test/lib/docs.js TAP config > keys that are not flattened 1`] = `
Array [
"expect-results",
"expect-result-count",
"expect-results",
"init-author-email",
"init-author-name",
"init-author-url",
+52
View File
@@ -131,6 +131,58 @@ t.test('re-loads publishConfig.registry if added during script process', async t
t.matchSnapshot(joinedOutput(), 'new package version')
})
t.test('prioritize CLI flags over publishConfig', async t => {
const publishConfig = { registry: 'http://publishconfig' }
const { joinedOutput, npm } = await loadMockNpm(t, {
config: {
[`${alternateRegistry.slice(6)}/:_authToken`]: 'test-other-token',
},
prefixDir: {
'package.json': JSON.stringify({
...pkgJson,
scripts: {
prepare: 'cp new.json package.json',
},
}, null, 2),
'new.json': JSON.stringify({
...pkgJson,
publishConfig,
}),
},
argv: ['--registry', alternateRegistry],
})
const registry = new MockRegistry({
tap: t,
registry: alternateRegistry,
authorization: 'test-other-token',
})
registry.nock.put(`/${pkg}`, body => {
return t.match(body, {
_id: pkg,
name: pkg,
'dist-tags': { latest: '1.0.0' },
access: null,
versions: {
'1.0.0': {
name: pkg,
version: '1.0.0',
_id: `${pkg}@1.0.0`,
dist: {
shasum: /\.*/,
tarball: `http:${alternateRegistry.slice(6)}/test-package/-/test-package-1.0.0.tgz`,
},
publishConfig,
},
},
_attachments: {
[`${pkg}-1.0.0.tgz`]: {},
},
})
}).reply(200, {})
await npm.exec('publish', [])
t.matchSnapshot(joinedOutput(), 'new package version')
})
t.test('json', async t => {
const { joinedOutput, npm, logs } = await loadMockNpm(t, {
config: {
+30
View File
@@ -408,6 +408,36 @@ t.test('publishConfig no spec', async t => {
t.equal(joinedOutput(), '- test-package')
})
t.test('prioritize CLI flags over publishConfig no spec', async t => {
const alternateRegistry = 'https://other.registry.npmjs.org'
const publishConfig = { registry: 'http://publishconfig' }
const { joinedOutput, npm } = await loadMockNpm(t, {
config: {
force: true,
'//other.registry.npmjs.org/:_authToken': 'test-other-token',
},
prefixDir: {
'package.json': JSON.stringify({
name: pkg,
version: '1.0.0',
publishConfig,
}, null, 2),
},
argv: ['--registry', alternateRegistry],
})
const registry = new MockRegistry({
tap: t,
registry: alternateRegistry,
authorization: 'test-other-token',
})
const manifest = registry.manifest({ name: pkg })
await registry.package({ manifest, query: { write: true }, times: 2 })
registry.unpublish({ manifest })
await npm.exec('unpublish', [])
t.equal(joinedOutput(), '- test-package')
})
t.test('publishConfig with spec', async t => {
const alternateRegistry = 'https://other.registry.npmjs.org'
const { joinedOutput, npm } = await loadMockNpm(t, {
+21 -31
View File
@@ -57,8 +57,10 @@ const loadLogFile = async (t, { buffer = [], mocks, testdir = {}, ...options } =
logFile,
LogFile,
readLogs: async () => {
const logDir = await fs.readdir(root)
const logFiles = logDir.map((f) => path.join(root, f))
const logDir = await fs.readdir(root, { withFileTypes: true })
const logFiles = logDir
.filter(f => f.isFile())
.map((f) => path.join(root, f.name))
.filter((f) => _fs.existsSync(f))
return Promise.all(logFiles.map(async (f) => {
const content = await fs.readFile(f, 'utf8')
@@ -202,6 +204,22 @@ t.test('cleans logs', async t => {
t.equal(logs.length, logsMax + 1)
})
t.test('cleans logs even when find folder inside logs folder', async t => {
const logsMax = 5
const { readLogs } = await loadLogFile(t, {
logsMax,
testdir: {
...makeOldLogs(10),
ignore_folder: {
'ignored-file.txt': 'hello',
},
},
})
const logs = await readLogs()
t.equal(logs.length, logsMax + 1)
})
t.test('doesnt clean current log by default', async t => {
const logsMax = 1
const { readLogs, logFile } = await loadLogFile(t, {
@@ -240,35 +258,6 @@ t.test('doesnt need to clean', async t => {
t.equal(logs.length, oldLogs + 1)
})
t.test('glob error', async t => {
const { readLogs } = await loadLogFile(t, {
logsMax: 5,
mocks: {
glob: { glob: () => {
throw new Error('bad glob')
} },
},
})
const logs = await readLogs()
t.equal(logs.length, 1)
t.match(last(logs).content, /error cleaning log files .* bad glob/)
})
t.test('do not log cleaning errors when logging is disabled', async t => {
const { readLogs } = await loadLogFile(t, {
logsMax: 0,
mocks: {
glob: () => {
throw new Error('should not be logged')
},
},
})
const logs = await readLogs()
t.equal(logs.length, 0)
})
t.test('cleans old style logs too', async t => {
const logsMax = 5
const oldLogs = 10
@@ -290,6 +279,7 @@ t.test('rimraf error', async t => {
testdir: makeOldLogs(oldLogs),
mocks: {
'fs/promises': {
readdir: fs.readdir,
rm: async (...args) => {
if (count >= 3) {
throw new Error('bad rimraf')