diff --git a/lib/api.js b/lib/api.js index f663bdc..4865d05 100644 --- a/lib/api.js +++ b/lib/api.js @@ -34,7 +34,7 @@ async function apiRequest({method = 'GET', endpoint, json, authorize = true, ful url: `${options.api}${endpoint}`, responseType: 'json', timeout: { - request: CONSTANTS.REQUEST_TIMEOUT + response: options.responseTimeout } } diff --git a/lib/args.js b/lib/args.js index 9ef150c..cdf8c5e 100644 --- a/lib/args.js +++ b/lib/args.js @@ -112,6 +112,7 @@ program .option('--no-ignore-dot', 'Do not ignore dotfiles in the path (`WATCHER_IGNORE_DOT=0`).') .option('--strict-revision-check', 'For CKL, ignore checklist of uninstalled STIG revision (`WATCHER_STRICT_REVISION_CHECK=1`). Negate with `--no-strict-revision-check`.', getBoolean('WATCHER_STRICT_REVISION_CHECK', false)) .option('--no-strict-revision-check', 'For CKL, allow checklist of uninstalled STIG revision (`WATCHER_STRICT_REVISION_CHECK=0`). This is the default behavior.') +.option('--response-timeout ', 'Specify the timeout duration in milliseconds for an API response to begin. If a response takes longer than this time, an error will be thrown.', parseIntegerArg, parseIntegerEnv(pe.WATCHER_RESPONSE_TIMEOUT) ?? 20000) // 20 secs // Parse ARGV and get the parsed options object // Options properties are created as camelCase versions of the long option name diff --git a/lib/auth.js b/lib/auth.js index f3c039d..01be618 100644 --- a/lib/auth.js +++ b/lib/auth.js @@ -51,7 +51,7 @@ async function getOpenIDConfiguration () { const requestOptions = { responseType: 'json', timeout: { - request: CONSTANTS.REQUEST_TIMEOUT + response: options.responseTimeout } } let response @@ -122,7 +122,7 @@ async function authenticateClientSecret () { password: options.clientSecret, responseType: 'json', timeout: { - request: CONSTANTS.REQUEST_TIMEOUT + response: options.responseTimeout } } @@ -180,7 +180,7 @@ async function authenticateSignedJwt () { }, responseType: 'json', timeout: { - request: CONSTANTS.REQUEST_TIMEOUT + response: options.responseTimeout } } logger.debug({ diff --git a/lib/consts.js b/lib/consts.js index a584ca2..ee4e86a 100644 --- a/lib/consts.js +++ b/lib/consts.js @@ -3,5 +3,4 @@ export const ERR_AUTHOFFLINE = 2 export const ERR_NOTOKEN = 3 export const ERR_NOGRANT = 4 export const ERR_UNKNOWN = 5 -export const ERR_FAILINIT = 6 -export const REQUEST_TIMEOUT = 5000 +export const ERR_FAILINIT = 6 \ No newline at end of file