Skip to content

Commit 3c5bb22

Browse files
committed
Add SOCKET_CLI_API_TIMEOUT env var
1 parent dc01d74 commit 3c5bb22

File tree

7 files changed

+23
-13
lines changed

7 files changed

+23
-13
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,10 @@ npm exec socket
9292

9393
- `SOCKET_CLI_API_BASE_URL` - Change the base URL for Socket API calls<br>
9494
*Defaults:* The "apiBaseUrl" value of socket/settings local app data if present, else `https://api.socket.dev/v0/`<br>
95-
- `SOCKET_CLI_API_PROXY` - Set the proxy all requests are routed through, e.g. if set to<br>
95+
- `SOCKET_CLI_API_PROXY` - Set the proxy Socket API requests are routed through, e.g. if set to<br>
9696
[`http://127.0.0.1:9090`](https://docs.proxyman.io/troubleshooting/couldnt-see-any-requests-from-3rd-party-network-libraries), then all request are passed through that proxy<br>
9797
*Aliases:* `HTTPS_PROXY`, `https_proxy`, `HTTP_PROXY`, and `http_proxy`<br>
98+
- `SOCKET_CLI_API_TIMEOUT` - Set the timeout in milliseconds for Socket API requests
9899
- `SOCKET_CLI_DEBUG` - Enable debug logging in Socket CLI
99100
- `DEBUG` - Enable debug logging based on the [`debug`](https://socket.dev/npm/package/debug) package
100101

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@
112112
"@socketregistry/is-interactive": "1.0.6",
113113
"@socketregistry/packageurl-js": "1.0.9",
114114
"@socketsecurity/config": "3.0.1",
115-
"@socketsecurity/registry": "1.0.273",
116-
"@socketsecurity/sdk": "1.4.76",
115+
"@socketsecurity/registry": "1.0.274",
116+
"@socketsecurity/sdk": "1.4.77",
117117
"@types/blessed": "0.1.25",
118118
"@types/cmd-shim": "5.0.2",
119119
"@types/js-yaml": "4.0.9",

src/commands/cli.test.mts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@ describe('socket root command', async () => {
8282
SOCKET_CLI_API_BASE_URL Change the base URL for Socket API calls
8383
Defaults: The "apiBaseUrl" value of socket/settings local app data
8484
if present, else https://api.socket.dev/v0/
85-
SOCKET_CLI_API_PROXY Set the proxy all requests are routed through, e.g. if set to
85+
SOCKET_CLI_API_PROXY Set the proxy Socket API requests are routed through, e.g. if set to
8686
http://127.0.0.1:9090 (\\u200bhttps://docs.proxyman.io/troubleshooting/couldnt-see-any-requests-from-3rd-party-network-libraries\\u200b) then all request are passed through that proxy
8787
Aliases: HTTPS_PROXY, https_proxy, HTTP_PROXY, and http_proxy
88+
SOCKET_CLI_API_TIMEOUT Set the timeout in milliseconds for Socket API requests
8889
SOCKET_CLI_DEBUG Enable debug logging in Socket CLI
8990
DEBUG Enable debug logging based on the debug (\\u200bhttps://socket.dev/npm/package/debug\\u200b) package"
9091
`)

src/constants.mts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ type ENV = Remap<
7373
SOCKET_CLI_ACCEPT_RISKS: boolean
7474
SOCKET_CLI_API_BASE_URL: string
7575
SOCKET_CLI_API_PROXY: string
76+
SOCKET_CLI_API_TIMEOUT: number
7677
SOCKET_CLI_API_TOKEN: string
7778
SOCKET_CLI_CONFIG: string
7879
SOCKET_CLI_GIT_USER_EMAIL: string
@@ -229,6 +230,7 @@ const LAZY_ENV = () => {
229230
path.join(constants.rootPath, 'dist/utils.js'),
230231
)
231232
const envAsBoolean = envHelpers.envAsBoolean
233+
const envAsNumber = envHelpers.envAsNumber
232234
const envAsString = envHelpers.envAsString
233235
const getConfigValueOrUndef = utils.getConfigValueOrUndef
234236
const readOrDefaultSocketJson = utils.readOrDefaultSocketJson
@@ -363,6 +365,9 @@ const LAZY_ENV = () => {
363365
envAsString(processEnv['https_proxy']) ||
364366
envAsString(processEnv['HTTP_PROXY']) ||
365367
envAsString(processEnv['http_proxy']),
368+
// Set the timeout in milliseconds for Socket API requests.
369+
// https://nodejs.org/api/http.html#httprequesturl-options-callback
370+
SOCKET_CLI_API_TIMEOUT: envAsNumber(processEnv['SOCKET_CLI_API_TOKEN']),
366371
// Set the Socket API token.
367372
// https://github.com/SocketDev/socket-cli?tab=readme-ov-file#environment-variables
368373
SOCKET_CLI_API_TOKEN:

src/utils/meow-with-subcommands.mts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,9 +488,10 @@ export async function meowWithSubcommands(
488488
' SOCKET_CLI_API_BASE_URL Change the base URL for Socket API calls',
489489
` ${colors.italic('Defaults:')} The "apiBaseUrl" value of socket/settings local app data`,
490490
' if present, else https://api.socket.dev/v0/',
491-
' SOCKET_CLI_API_PROXY Set the proxy all requests are routed through, e.g. if set to',
491+
' SOCKET_CLI_API_PROXY Set the proxy Socket API requests are routed through, e.g. if set to',
492492
` ${terminalLink('http://127.0.0.1:9090', 'https://docs.proxyman.io/troubleshooting/couldnt-see-any-requests-from-3rd-party-network-libraries')} then all request are passed through that proxy`,
493493
` ${colors.italic('Aliases:')} HTTPS_PROXY, https_proxy, HTTP_PROXY, and http_proxy`,
494+
' SOCKET_CLI_API_TIMEOUT Set the timeout in milliseconds for Socket API requests',
494495
' SOCKET_CLI_DEBUG Enable debug logging in Socket CLI',
495496
` DEBUG Enable debug logging based on the ${terminalLink('debug', 'https://socket.dev/npm/package/debug')} package`,
496497
)

src/utils/sdk.mts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ export async function setupSdk(
122122
data: new SocketSdk(apiToken, {
123123
agent: apiProxy ? new ProxyAgent({ proxy: apiProxy }) : undefined,
124124
baseUrl: apiBaseUrl,
125+
// Lazily access constants.ENV.SOCKET_CLI_API_TIMEOUT.
126+
timeout: constants.ENV.SOCKET_CLI_API_TIMEOUT,
125127
userAgent: createUserAgentFromPkgJson({
126128
// Lazily access constants.ENV.INLINED_SOCKET_CLI_NAME.
127129
name: constants.ENV.INLINED_SOCKET_CLI_NAME,

0 commit comments

Comments
 (0)