Skip to content

Commit

Permalink
deps: update [email protected]
Browse files Browse the repository at this point in the history
  • Loading branch information
reggi committed Oct 2, 2024
1 parent 7214149 commit eae4f57
Show file tree
Hide file tree
Showing 241 changed files with 18,806 additions and 87 deletions.
46 changes: 40 additions & 6 deletions node_modules/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@
!/@sigstore/core
!/@sigstore/protobuf-specs
!/@sigstore/sign
!/@sigstore/sign/node_modules/
/@sigstore/sign/node_modules/*
!/@sigstore/sign/node_modules/@npmcli/
/@sigstore/sign/node_modules/@npmcli/*
!/@sigstore/sign/node_modules/@npmcli/agent
!/@sigstore/sign/node_modules/@npmcli/fs
!/@sigstore/sign/node_modules/cacache
!/@sigstore/sign/node_modules/make-fetch-happen
!/@sigstore/sign/node_modules/unique-filename
!/@sigstore/sign/node_modules/unique-slug
!/@sigstore/tuf
!/@sigstore/verify
!/@tufjs/
Expand Down Expand Up @@ -176,12 +186,10 @@
!/make-fetch-happen
!/make-fetch-happen/node_modules/
/make-fetch-happen/node_modules/*
!/make-fetch-happen/node_modules/@npmcli/
/make-fetch-happen/node_modules/@npmcli/*
!/make-fetch-happen/node_modules/@npmcli/fs
!/make-fetch-happen/node_modules/cacache
!/make-fetch-happen/node_modules/unique-filename
!/make-fetch-happen/node_modules/unique-slug
!/make-fetch-happen/node_modules/minipass-fetch
!/make-fetch-happen/node_modules/minizlib
!/make-fetch-happen/node_modules/proc-log
!/make-fetch-happen/node_modules/ssri
!/minimatch
!/minipass-collect
!/minipass-fetch
Expand All @@ -207,6 +215,16 @@
!/mute-stream
!/negotiator
!/node-gyp
!/node-gyp/node_modules/
/node-gyp/node_modules/*
!/node-gyp/node_modules/@npmcli/
/node-gyp/node_modules/@npmcli/*
!/node-gyp/node_modules/@npmcli/agent
!/node-gyp/node_modules/@npmcli/fs
!/node-gyp/node_modules/cacache
!/node-gyp/node_modules/make-fetch-happen
!/node-gyp/node_modules/unique-filename
!/node-gyp/node_modules/unique-slug
!/nopt
!/nopt/node_modules/
/nopt/node_modules/*
Expand All @@ -231,7 +249,13 @@
/npm-registry-fetch/node_modules/*
!/npm-registry-fetch/node_modules/@npmcli/
/npm-registry-fetch/node_modules/@npmcli/*
!/npm-registry-fetch/node_modules/@npmcli/agent
!/npm-registry-fetch/node_modules/@npmcli/fs
!/npm-registry-fetch/node_modules/@npmcli/redact
!/npm-registry-fetch/node_modules/cacache
!/npm-registry-fetch/node_modules/make-fetch-happen
!/npm-registry-fetch/node_modules/unique-filename
!/npm-registry-fetch/node_modules/unique-slug
!/npm-user-validate
!/p-map
!/package-json-from-dist
Expand Down Expand Up @@ -311,6 +335,16 @@
!/tiny-relative-date
!/treeverse
!/tuf-js
!/tuf-js/node_modules/
/tuf-js/node_modules/*
!/tuf-js/node_modules/@npmcli/
/tuf-js/node_modules/@npmcli/*
!/tuf-js/node_modules/@npmcli/agent
!/tuf-js/node_modules/@npmcli/fs
!/tuf-js/node_modules/cacache
!/tuf-js/node_modules/make-fetch-happen
!/tuf-js/node_modules/unique-filename
!/tuf-js/node_modules/unique-slug
!/unique-filename
!/unique-slug
!/util-deprecate
Expand Down
22 changes: 11 additions & 11 deletions node_modules/@npmcli/agent/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
{
"name": "@npmcli/agent",
"version": "2.2.2",
"version": "3.0.0",
"description": "the http/https agent used by the npm cli",
"main": "lib/index.js",
"scripts": {
"gencerts": "bash scripts/create-cert.sh",
"test": "tap",
"lint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"",
"lint": "npm run eslint",
"postlint": "template-oss-check",
"template-oss-apply": "template-oss-apply --force",
"lintfix": "npm run lint -- --fix",
"lintfix": "npm run eslint -- --fix",
"snap": "tap",
"posttest": "npm run lint"
"posttest": "npm run lint",
"eslint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\""
},
"author": "GitHub Inc.",
"license": "ISC",
Expand All @@ -24,11 +25,11 @@
"lib/"
],
"engines": {
"node": "^16.14.0 || >=18.0.0"
"node": "^18.17.0 || >=20.5.0"
},
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "4.21.3",
"version": "4.23.1",
"publish": "true"
},
"dependencies": {
Expand All @@ -39,17 +40,16 @@
"socks-proxy-agent": "^8.0.3"
},
"devDependencies": {
"@npmcli/eslint-config": "^4.0.0",
"@npmcli/template-oss": "4.21.3",
"@npmcli/eslint-config": "^5.0.0",
"@npmcli/template-oss": "4.23.1",
"minipass-fetch": "^3.0.3",
"nock": "^13.2.7",
"semver": "^7.5.4",
"simple-socks": "^3.1.0",
"socksv5": "^0.0.6",
"tap": "^16.3.0"
},
"repository": {
"type": "git",
"url": "https://github.com/npm/agent.git"
"url": "git+https://github.com/npm/agent.git"
},
"tap": {
"nyc-arg": [
Expand Down
206 changes: 206 additions & 0 deletions node_modules/@sigstore/sign/node_modules/@npmcli/agent/lib/agents.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
'use strict'

const net = require('net')
const tls = require('tls')
const { once } = require('events')
const timers = require('timers/promises')
const { normalizeOptions, cacheOptions } = require('./options')
const { getProxy, getProxyAgent, proxyCache } = require('./proxy.js')
const Errors = require('./errors.js')
const { Agent: AgentBase } = require('agent-base')

module.exports = class Agent extends AgentBase {
#options
#timeouts
#proxy
#noProxy
#ProxyAgent

constructor (options = {}) {
const { timeouts, proxy, noProxy, ...normalizedOptions } = normalizeOptions(options)

super(normalizedOptions)

this.#options = normalizedOptions
this.#timeouts = timeouts

if (proxy) {
this.#proxy = new URL(proxy)
this.#noProxy = noProxy
this.#ProxyAgent = getProxyAgent(proxy)
}
}

get proxy () {
return this.#proxy ? { url: this.#proxy } : {}
}

#getProxy (options) {
if (!this.#proxy) {
return
}

const proxy = getProxy(`${options.protocol}//${options.host}:${options.port}`, {
proxy: this.#proxy,
noProxy: this.#noProxy,
})

if (!proxy) {
return
}

const cacheKey = cacheOptions({
...options,
...this.#options,
timeouts: this.#timeouts,
proxy,
})

if (proxyCache.has(cacheKey)) {
return proxyCache.get(cacheKey)
}

let ProxyAgent = this.#ProxyAgent
if (Array.isArray(ProxyAgent)) {
ProxyAgent = this.isSecureEndpoint(options) ? ProxyAgent[1] : ProxyAgent[0]
}

const proxyAgent = new ProxyAgent(proxy, {
...this.#options,
socketOptions: { family: this.#options.family },
})
proxyCache.set(cacheKey, proxyAgent)

return proxyAgent
}

// takes an array of promises and races them against the connection timeout
// which will throw the necessary error if it is hit. This will return the
// result of the promise race.
async #timeoutConnection ({ promises, options, timeout }, ac = new AbortController()) {
if (timeout) {
const connectionTimeout = timers.setTimeout(timeout, null, { signal: ac.signal })
.then(() => {
throw new Errors.ConnectionTimeoutError(`${options.host}:${options.port}`)
}).catch((err) => {
if (err.name === 'AbortError') {
return
}
throw err
})
promises.push(connectionTimeout)
}

let result
try {
result = await Promise.race(promises)
ac.abort()
} catch (err) {
ac.abort()
throw err
}
return result
}

async connect (request, options) {
// if the connection does not have its own lookup function
// set, then use the one from our options
options.lookup ??= this.#options.lookup

let socket
let timeout = this.#timeouts.connection
const isSecureEndpoint = this.isSecureEndpoint(options)

const proxy = this.#getProxy(options)
if (proxy) {
// some of the proxies will wait for the socket to fully connect before
// returning so we have to await this while also racing it against the
// connection timeout.
const start = Date.now()
socket = await this.#timeoutConnection({
options,
timeout,
promises: [proxy.connect(request, options)],
})
// see how much time proxy.connect took and subtract it from
// the timeout
if (timeout) {
timeout = timeout - (Date.now() - start)
}
} else {
socket = (isSecureEndpoint ? tls : net).connect(options)
}

socket.setKeepAlive(this.keepAlive, this.keepAliveMsecs)
socket.setNoDelay(this.keepAlive)

const abortController = new AbortController()
const { signal } = abortController

const connectPromise = socket[isSecureEndpoint ? 'secureConnecting' : 'connecting']
? once(socket, isSecureEndpoint ? 'secureConnect' : 'connect', { signal })
: Promise.resolve()

await this.#timeoutConnection({
options,
timeout,
promises: [
connectPromise,
once(socket, 'error', { signal }).then((err) => {
throw err[0]
}),
],
}, abortController)

if (this.#timeouts.idle) {
socket.setTimeout(this.#timeouts.idle, () => {
socket.destroy(new Errors.IdleTimeoutError(`${options.host}:${options.port}`))
})
}

return socket
}

addRequest (request, options) {
const proxy = this.#getProxy(options)
// it would be better to call proxy.addRequest here but this causes the
// http-proxy-agent to call its super.addRequest which causes the request
// to be added to the agent twice. since we only support 3 agents
// currently (see the required agents in proxy.js) we have manually
// checked that the only public methods we need to call are called in the
// next block. this could change in the future and presumably we would get
// failing tests until we have properly called the necessary methods on
// each of our proxy agents
if (proxy?.setRequestProps) {
proxy.setRequestProps(request, options)
}

request.setHeader('connection', this.keepAlive ? 'keep-alive' : 'close')

if (this.#timeouts.response) {
let responseTimeout
request.once('finish', () => {
setTimeout(() => {
request.destroy(new Errors.ResponseTimeoutError(request, this.#proxy))
}, this.#timeouts.response)
})
request.once('response', () => {
clearTimeout(responseTimeout)
})
}

if (this.#timeouts.transfer) {
let transferTimeout
request.once('response', (res) => {
setTimeout(() => {
res.destroy(new Errors.TransferTimeoutError(request, this.#proxy))
}, this.#timeouts.transfer)
res.once('close', () => {
clearTimeout(transferTimeout)
})
})
}

return super.addRequest(request, options)
}
}
Loading

0 comments on commit eae4f57

Please sign in to comment.